npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dbp-toolkit/auth

v0.3.2

Published

You can install the components via npm:

Downloads

58

Readme

Auth Web Components

You can install the components via npm:

npm i @dbp-toolkit/auth

Keycloak Component

Usage

<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/[email protected]/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.

Attributes

  • lang (optional, default: de): set to de or en for German or English
    • example <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
    • example <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).
    • example <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
    • example <dbp-auth-keycloak requested-login-status="logged-in"></dbp-auth-keycloak>
    • note: most often this should be an attribute that is not set directly, but subscribed at a provider

Keycloak Specific Attributes

  • url (required): The base URL of the Keycloak server
  • realm (required): The Keycloak realm
  • client-id (required): The Keycloak client to use
  • silent-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_adapter
  • scope (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 provider

Emitted attributes

The component emits a dbp-set-property event for the attribute auth:

  • auth.subject: Keycloak username
  • auth.login-status: Login status (unknown, logging-in, logging-out, logged-in, logged-out)
  • auth.token: Keycloak token to send with your requests
  • auth.user-full-name: Full name of the user
  • auth.user-id: Identifier of the user

Login Button

Usage

<dbp-login-button></dbp-login-button>
<script type="module" src="node_modules/@dbp-toolkit/auth/dist/dbp-auth.js"></script>

Attributes

  • lang (optional, default: de): set to de or en for German or English
    • example <dbp-auth-keycloak lang="de" </dbp-auth-keycloak>
  • auth object: you need to set that object property for the auth token
    • example auth property: {token: "THE_BEARER_TOKEN"}
    • note: most often this should be an attribute that is not set directly, but subscribed at a provider

Emitted attributes

The component emits a dbp-set-property event for the attribute requested-login-status (possible values logged-in, logged-out).

Alternative to <dbp-auth>

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!

Local development

# get the source
git clone [email protected]:digital-blueprint/toolkit.git
cd toolkit/packages/auth

# install dependencies
yarn install

# constantly build dist/bundle.js and run a local web-server on port 8002 
yarn run watch-local

# build local packages in dist directory
yarn run build

Jump to http://localhost:8002 and you should get a Single Sign On login page.