Skip to content
Snippets Groups Projects
Select Git revision
  • 7444496985342e06bb15b0c393a5c0e574e01b7a
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

auth

  • Clone with SSH
  • Clone with HTTPS
  • Christoph Reiter's avatar
    Reiter, Christoph authored
    The keycloak library currently only sends us an event in case the token
    is about to expire, which is problematic because there is a time window
    where we don't have a new token yet and on mobile the timers used
    might be suspended and come too late.
    
    To avoid this we check every 10 seconds that the token is valid for 30
    and to work around suspended timers we also check on "visibilitychange"
    which should trigger then the website gets visible again after the browser
    sleeps.
    74444969
    History

    Auth Web Components

    Keycloak Component

    Usage

    <dbp-auth-keycloak url="https://auth.tugraz.at/auth" realm="tugraz" client-id="some-id"></dbp-auth-keycloak>

    Attributes

    • lang (optional, default: de): set to de or en for German or English
      • example <dbp-auth-keycloak lang="de" </dbp-auth-keycloak>
    • load-person (optional, default: off): if enabled the logged in user will also be loaded as Person in the window.DBPPerson variable
      • example <dbp-auth-keycloak load-person></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>

    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.

    Events to listen to

    • dbp-auth-init: Keycloak init event - happens once
    • dbp-auth-person-init: Keycloak person init event - the person entity was loaded from the server
    • dbp-auth-keycloak-data-update: Keycloak data was updated - happens for example every time after a token refresh

    Login Button

    Usage

    <dbp-login-button></dbp-login-button>

    Local development

    # get the source
    git clone git@gitlab.tugraz.at:dbp/web-components/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.