Skip to content

Repository files navigation

Hapi Common Auth Plugin Build Status

An auth wrapper for hapi.js

Installtion

npm install @plan3-relate/hapi-common-auth

Usage

constHapi=require('hapi');constserver=newHapi.Server();constcommonAuth=require('@plan3-relate/hapi-common-auth');// register the pluginserver.register({register: commonAuth,options: {jwt: {publicKey: 'public-key',nonExpiringIds: ['allowed-id-1','allowed-id-2']// optional},bearer: {tokens: {...}},plan3Key: {tokens: {...}}}});

Adding additional credentials

Bearer and Plan3Key strategy resolves newsroom as part credentials by default. One could change this behaviour by defining addtionalCredentials object in the plugin options. Those will be merged into credentials object returned by plugin.

Example:

// register the pluginserver.register({register: commonAuth,options: {bearer: {tokens: {exampleToken: 'some newsroom'},additionalCredentials: {role: 'admin',origin: 'bearer'}}}});

That will result in request.auth.credentials Object to equal:

{
"newsroom": "some newsroom",
"role": "admin",
"origin": "bearer"
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages