1.0.6 • Published 4 years ago

keycloak-authenticator v1.0.6

Weekly downloads
5
License
ISC
Repository
-
Last release
4 years ago

#keycloak-authenticator This package expose method for get access tokens from a keycloak server, also provide tools to valide those tokens against the server.

#install npm i keycloak-authenticator

#example

import { KeycloakAuthentication } from 'keycloak'

const kcauth = new KeycloakAuthentication({
    KEYCLOAK_BASE_URI: process.env.KEYCLOAK_BASE_URI, //ex: https://localhost:8080/auth
    KEYCLOAK_REALM: process.env.KEYCLOAK_REALM, //realm name (not id is a string)
    KEYCLOAK_USERNAME: process.env.KEYCLOAK_USER_NAME //realm user name
    KEYCLOAK_PASSWORD: process.env.KEYCLOAK_USER_PASSWORD, //realm user password
});

kcauth.getAccessToken('client_id', 'client_secret <search in client credentials in your keycloak server> ')
.then(async (token) => {
    //this is an example, in general you will wish use this token to authenticate against a service or exchange information
    let isValid = await kcauth.validateAccessToken(token) //at the other side you could valide any token you catch.
    console.log(isValid) //true
}); 
1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago