![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@dbp-toolkit/auth
Advanced tools
You can install the components via npm:
npm i @dbp-toolkit/auth
<dbp-auth-keycloak url="https://auth.tugraz.at/auth" realm="tugraz-vpu" client-id="some-id"></dbp-auth-keycloak>
<script type="module" src="node_modules/@dbp-toolkit/auth/dist/dbp-auth.js"></script>
Or directly via CDN:
<dbp-auth-keycloak url="https://auth.tugraz.at/auth" realm="tugraz-vpu" client-id="some-id"></dbp-auth-keycloak>
<script type="module" src="https://unpkg.com/@dbp-toolkit/auth@0.2.2/dist/dbp-auth.js"></script>
You need Keycloak to be in place to make use of the auth component. Best take a look on examples like index.html for more explanation.
lang
(optional, default: de
): set to de
or en
for German or English
<dbp-auth-keycloak lang="de" </dbp-auth-keycloak>
force-login
(optional, default: off): if enabled a login will be forced, there never will be a login button
<dbp-auth-keycloak force-login></dbp-auth-keycloak>
try-login
(optional, default: off): if enabled the a login will happen if the user is already logged in
and finishing the login process would not result in a page location change (reload/redirect).
<dbp-auth-keycloak try-login></dbp-auth-keycloak>
requested-login-status
(optional, default: unknown
): can be set to logged-in
or logged-out
to request a login or logout
<dbp-auth-keycloak requested-login-status="logged-in"></dbp-auth-keycloak>
url
(required): The base URL of the Keycloak serverrealm
(required): The Keycloak realmclient-id
(required): The Keycloak client to usesilent-check-sso-redirect-uri
(optional): URI or path to a separate page for checking the login session in an iframe, see https://www.keycloak.org/docs/latest/securing_apps/#_javascript_adapterscope
(optional): Space separated list of scopes to request. These scopes get added in addition to the default ones, assuming the scope is in the optional scopes list of the Keycloak client in use.idp-hint
(optional): Set a client suggested identity providerno-check-login-iframe
(optional): Set to true
to disable the login check iframe.The component emits a dbp-set-property
event for the attribute auth
:
auth.subject
: Keycloak usernameauth.login-status
: Login status (unknown
, logging-in
, logging-out
, logged-in
, logged-out
)auth.token
: Keycloak token to send with your requestsauth.user-full-name
: Full name of the userauth.user-id
: Identifier of the user<dbp-login-button></dbp-login-button>
<script type="module" src="node_modules/@dbp-toolkit/auth/dist/dbp-auth.js"></script>
lang
(optional, default: de
): set to de
or en
for German or English
<dbp-auth-keycloak lang="de" </dbp-auth-keycloak>
auth
object: you need to set that object property for the auth token
{token: "THE_BEARER_TOKEN"}
The component emits a dbp-set-property
event for the attribute requested-login-status
(possible values logged-in
, logged-out
).
If embedded in an external page (without <dbp-provider>
) components can also work together with a different source for the auth token:
<dbp-person-select id="ps-1"></dbp-person-select>
<script>
function onAuthHasChanged(auth) {
/* fully featured auth object */
const ps = document.getElementById('ps-1');
ps.setProperty('auth', auth);
}
/* or */
function onTokenHasChanged(token) {
/* only token available */
const auth = { token: token };
onAuthHasChanged(auth);
}
</script>
Note: Some components need information about the logged-in person too!
# get the source
git clone git@github.com:digital-blueprint/toolkit.git
cd toolkit/packages/auth
# install dependencies
npm install
# constantly build dist/bundle.js and run a local web-server on port 8002
npm run watch-local
# build local packages in dist directory
npm run build
Jump to http://localhost:8002 and you should get a Single Sign On login page.
FAQs
Unknown package
The npm package @dbp-toolkit/auth receives a total of 12 weekly downloads. As such, @dbp-toolkit/auth popularity was classified as not popular.
We found that @dbp-toolkit/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.