hapi-cas-jwt
v1.0.1
Published
An HapiJS plugin that provides an authentication strategy to login in CAS and generate a JWT to be used in stateless authetication and authorization
Downloads
4
Readme
Hapi Cas JWT plugin
An HapiJS plugin that provides an authentication strategy to login in CAS and generate a JWT to be used in stateless authetication and authorization.
Install
yarn add hapi-cas-jwt
Example
server.register(require('hapi-cas-jwt'), (err) => {
const options = {
casServerUrl: 'https://example.com/cas/',
localAppUrl: 'https://127.0.0.1:8080',
ticketValidationEndpointPath: '/cas-st-handler'
jwtPayloadFromUsername": (username) => {
//fetch user from db and return the jwt payload to sign
},
jwtKey: "yoursecretkeyhere"
};
server.auth.strategy('cas', 'cas-jwt', options);
}
);
Then in your route config, specify the auth strategy:
config: {
auth: {
strategy: 'cas'
}
}
Afterwards, in the route, you can get the decoded payload via:
request.credentials
For example
request.credentials.sub will provide JWT sub property.