hapi-cas-jwt

1.0.1 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i hapi-cas-jwt

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • davidmartinho