hapi-auth-fernet

1.0.0 • Public • Published

code style: prettier

A Hapi 17 plugin that uses a fernet created token, created using a shared secret between servers, to authenticate a request. The token is provided in the header x-token of the request. Check out fernet.

// generate a token using the secret
 
let fernet = require('fernet')
let secret = new fernet.Secret('secret-here')
let token = new fernet.Token({ secret })
let xToken = token.encode("the message, maybe a hash if only using this for auth")
// in the server receiving the request
 
let server = new Hapi.Server(config)
let authConfig = {
    secret: 'secret-here',
    ttl: 4000 // defaults to 300000, which is 5 minutes
}
 
await server.register(auth)
await server.auth.strategy('simple', 'fernet', authConfig)
await server.auth.default('simple')
 
server.route({
    method: 'GET',
    path: '/',
    handler: () => 'hello fernet auth'
})

linting

This project uses Prettier.js for code formating and linting. I would recomend installing it globally as described here and integrate it with your editor.

here is the configuration used

--no-semi: true
--single-quote: true
--tab-width: 4

check out .eslint.rc as well

Readme

Keywords

Package Sidebar

Install

npm i hapi-auth-fernet

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • alec.troemel
  • donspaulding
  • eyepulp