Socket
Socket
Sign inDemoInstall

@entur/auth-provider

Package Overview
Dependencies
Maintainers
11
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur/auth-provider

React components and helpers for authentication


Version published
Weekly downloads
14
increased by27.27%
Maintainers
11
Weekly downloads
 
Created
Source

@entur/auth-provider

Authentication provider for Entur applications. Primarily aimed at easing transition between legacy keycloak and auth0 in internal and data provider applications.

NPM JavaScript Style Guide

Install

npm install --save @entur/auth-provider

Usage

import React from 'react'
import { render } from 'react-dom';

import AuthProvider, { useAuth } from '@entur/auth-provider';

// Provide either auth0Config, keycloakConfigUrl or both
const auth0Config = {}; //<-- see auth0 docs for required fields
const auth0ClaimsNamespace = ''; // <-- required for custom roles parsing
const keycloakConfigUrl = ''; // <-- where to find keycloak config

// defaultAuthMethod is optional, kc (keycloak) is default. User can override with query parameter:
// ?authMethod=kc|auth0
const defaultAuthMethod = 'auth0';

// If set to false, app will not automatically redirect to login page
// Note: Only works on auth0 - keycloak will always redirect automatically
const loginAutomatically = false;

const App = () => {
  const {
    isAuthenticated
  } = useAuth();

  return (
    <h1>
      {isAuthenticated ? 'Yay' : 'Oh no ...'}
    </h2>
  )
}

render(
  <AuthProvider
    auth0Config={auth0Config}
    auth0ClaimsNamespace={auth0ClaimsNamespace}
    keycloakConfigUrl={keycloakConfigUrl}
    defaultAuthMethod={defaultAuthMethod}
    loginAutomatically={loginAutomatically}
  >
    <App />
  <AuthProvider>
);

License

EUPL © entur/nrp

FAQs

Package last updated on 20 May 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc