3.2.2 • Published 11 months ago
@wizardtales/hapi-oidc v3.2.2
Hapi-OIDC
OpenID-Connect authentication plugin for hapi.
Configuration
This plugin needs some configuration to discover and connect to the OIDC server:
discoverUrl: The discovery URL of your OIDC serverclientId: Client ID given by your OIDC serverclientSecret: Client secret given by your OIDC servercallbackUrl: The full URL that the server will call after the authorization processcookie: Name of the cookie that will held the authentication. Defaults tohapi-oidc
Alternatively, you can manually setup your OIDC client by replacing the discover URL by:
issuer: URL of the issuerauthorization: Authorization endpointtoken: Token generation endpointuserinfo: User infos endpointjwks: JWKS endpoint
When registering the oidc scheme, you'll need to configure the cookie settings if defaults do not suits you:
password=uuid4(),path='/'ttl= 3600 * 1000encoding='iron'isSecure=true,clearInvalid=true
Example
const Hapi = require('hapi');
const uuid4 = require('uuid/v4');
const OIDC = require('hapi-oidc');
const routes = require('./routes');
const server = Hapi.server({
port: 3000,
});
const init = async () => {
await server.register([
{
plugin: OIDC,
options: {
discoverUrl: 'https://oidc-server.com/oauth2/default',
clientId: 'XXXXXXXXXXXXXXX',
clientSecret: 'XXXXXXXXXXXXXXXXXXXXXX',
callbackUrl: 'https://my-server:3000/login_callback',
},
}
]);
server.auth.strategy('oidc', 'oidc', {
password: uuid4(),
});
server.route(routes);
await server.start();
server.log(['info'], `Server running at: ${server.info.uri}`);
};
init();
module.exports = server;3.2.2
11 months ago
3.1.3
11 months ago
3.2.1
11 months ago
3.2.0
11 months ago
3.1.5
11 months ago
3.1.4
11 months ago
3.1.2
11 months ago
3.1.1
11 months ago
3.1.0
12 months ago
3.0.0
12 months ago
2.1.5
12 months ago
2.1.2
3 years ago
2.1.4
3 years ago
2.1.3
3 years ago
2.1.1
3 years ago
2.1.0
3 years ago
2.0.2
3 years ago
2.0.1
3 years ago