Giter Club home page Giter Club logo

lux-jwt's Introduction

lux-jwt

Middleware implementation of JWT for Lux.

Build Status Coverage Status Dependency Status npm version

This module lets you authenticate HTTP requests using JWT tokens in your Lux applications. JWTs are typically used to protect (stateless) API endpoints.

Install

$ npm i --save lux-jwt

Usage

The JWT authentication middleware authenticates callers using a JWT. If the token is valid, request.user will be set with the JSON object decoded to be used by later middleware for authorization and access control.

An example usage of using lux-jwt is shown below.

Secret can also be an Array of multiple valid secrets. A good use case for this is when you use automatically refreshed secrets. This way the previous secret is still valid so the token isn't immediately invalidated when the secret is refreshed. See Heroku Secure Key for more information.

import {Controller} from 'lux-framework';
import jwt from 'lux-jwt';
import unless from 'lux-unless';

class ApplicationController extends Controller {
    beforeAction = [
        jwt({secret: 'shhhhhhared-secret'})
    ];
}

lux-unless can be used to keep certain endpoints from being authorized by lux-jwt.

import {Controller} from 'lux-framework';
import jwt from 'lux-jwt';
import unless from 'lux-unless';

class ApplicationController extends Controller {
    beforeAction = [
        unless({path: ['/users/login']}, jwt({secret: 'shhhhhhared-secret'}))
    ];
}

This module also exposes the jsonwebtoken API. Currently this means the following functions are exposed:

  • sign(payload, secretOrPrivateKey, options) - Create and sign a JWT.
  • verify(token, secretOrPublicKey, [options]) - Verify whether or not the passed JWT is valid.
  • decode(token, [options]) - Decode the contents of the JWT.

For detailed documentation on these functions please refer to the jsonwebtoken README.

import {sign, verify, decode} from 'lux-jwt'

Options

An object containing the following options must be passed:

  • secret - A string or buffer containing either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA. Can also be an array with multiple valid secrets.
  • requestProperty (optional) - The key on which the payload of the JWT will be made available.
  • isRevoked(request, decodedAccessToken) (optional) - A function returning whether or not the token was revoked.
  • audience (optional) - The expected audience (aud) to be present in the token.
  • issuer (optional) - The expected issuer (iss) of the token.
  • clockTolerance (optional) - Number of seconds to tolerate when checking the nbf and exp claims, to deal with small clock differences among different servers.
  • algorithms (optional) - A list of strings with the names of the allowed algorithms. For instance, ["HS256", "HS384"].

Related Modules

Tests

$ npm install
$ npm test

License

This project is licensed under the MIT license. See the LICENSE file for more info.

lux-jwt's People

Contributors

greenkeeper[bot] avatar nickschot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

srsgores

lux-jwt's Issues

An in-range update of babel-plugin-transform-es2015-parameters is breaking the build 🚨

Version 6.24.1 of babel-plugin-transform-es2015-parameters just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-es2015-parameters
Current Version 6.23.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-es2015-parameters is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-async-to-generator is breaking the build 🚨

Version 6.24.1 of babel-plugin-transform-async-to-generator just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-async-to-generator
Current Version 6.22.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-async-to-generator is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-es2015-modules-commonjs is breaking the build 🚨

Version 6.24.1 of babel-plugin-transform-es2015-modules-commonjs just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-es2015-modules-commonjs
Current Version 6.24.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-es2015-modules-commonjs is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of mocha is breaking the build 🚨

Version 3.4.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.4.0

Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.

This week's highlights:

  • allowUncaught added to commandline as --allow-uncaught (and bugfixed)
  • warning-related Node flags

πŸŽ‰ Enhancements

πŸ› Fixes

πŸ”© Other

Commits

The new version differs by 9 commits0.

  • 7554b31 Add Changelog for v3.4.0
  • 9f7f7ed Add --trace-warnings flag
  • 92561c8 Add --no-warnings flag
  • ceee976 lint test/integration/fixtures/simple-reporter.js
  • dcfc094 Revert "use semistandard directly"
  • 93392dd no special case for macOS running Karma locally
  • 4d1d91d --allow-uncaught cli option
  • fb1e083 fix allowUncaught in browser
  • 4ed3fc5 Add license report and scan status

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-cli is breaking the build 🚨

Version 6.24.1 of babel-cli just got published.

Branch Build failing 🚨
Dependency babel-cli
Current Version 6.24.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-cli is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-es2015-modules-commonjs is breaking the build 🚨

Version 6.26.0 of babel-plugin-transform-es2015-modules-commonjs just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-es2015-modules-commonjs
Current Version 6.24.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-es2015-modules-commonjs is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-object-rest-spread is breaking the build 🚨

Version 6.26.0 of babel-plugin-transform-object-rest-spread just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-object-rest-spread
Current Version 6.23.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-object-rest-spread is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of nyc is breaking the build 🚨

Version 10.1.0 of nyc just got published.

Branch Build failing 🚨
Dependency nyc
Current Version 10.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As nyc is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ coverage/coveralls Coverage pending from Coveralls.io Details

  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 14 commits .

  • 8f7af3a chore(release): 10.1.0
  • 8c58d68 fix: address edge-cases related to --all when instrumentation is disabled (#482)
  • 8b58c05 feat: allow eager instantiation of instrumenter (#490)
  • d8d2de0 feat: upgrade to istanbul-lib-instrument with support for 'const foo = function () {}' name preservation. upgrade to istanbul-lib-hook with fix for ts-node. (#494)
  • 7708235 chore: add test and docs for high and low watermarks (#493)
  • 0a1d72a feat: reporting watermarks can now be set in nyc config stanza (#469)
  • 1022b16 fix: pass configuration options to --check-coverage (#483)
  • 7b4c090 chore(package): update tap to version 9.0.3 (#488)
  • 093963b chore(release): 10.0.2
  • e01ec8c fix: upgrade to newer istanbul-lib-instrument, with fixes for inferred function names (#479)
  • 2e39e00 chore(release): 10.0.1
  • e0ef1d5 fix: upgrade spawn-wrap and istanbul-lib-instrument (#477)
  • 8603aa9 chore(package): update is-windows to version 1.0.0 (#466)
  • 64ae4f3 chore(package): update standard-version to version 4.0.0 (#461)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-exponentiation-operator is breaking the build 🚨

Version 6.24.1 of babel-plugin-transform-exponentiation-operator just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-exponentiation-operator
Current Version 6.22.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-exponentiation-operator is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of jsonwebtoken is breaking the build 🚨

Version 7.4.2 of jsonwebtoken just got published.

Branch Build failing 🚨
Dependency jsonwebtoken
Current Version 7.4.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

jsonwebtoken is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 12 commits.

  • e56f904 update changelog
  • 480bb9b 7.4.2
  • c6a7026 Merge pull request #374 from ziluvatar/add-check-for-empty-secrets
  • c584d1c sign: add check to be sure secret has a value
  • 43739dc Merge pull request #371 from ziluvatar/docs-about-refreshing-tokens
  • 016fc10 docs: about refreshing tokens
  • 5f44a86 Merge pull request #365 from ziluvatar/information-regarding-base64-secrets
  • c25e990 docs: verifying with base64 encoded secrets
  • 2f36063 Merge pull request #360 from ziluvatar/add-ecdsa-tests
  • 00086c2 document keyid as option (#361)
  • 89900ea Add tests for ES256
  • 27a7f1d readme: Using private key with passpharase (#353)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-class-properties is breaking the build 🚨

Version 6.19.0 of babel-plugin-transform-class-properties just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-class-properties
Current Version 6.18.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-class-properties is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

  • ❌ coverage/coveralls Coverage pending from Coveralls.io Details

  • βœ… continuous-integration/travis-ci/pr The Travis CI build passed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-cli is breaking the build 🚨

Version 6.26.0 of babel-cli just got published.

Branch Build failing 🚨
Dependency babel-cli
Current Version 6.24.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-cli is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-class-properties is breaking the build 🚨

Version 6.24.1 of babel-plugin-transform-class-properties just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-class-properties
Current Version 6.23.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-class-properties is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Improve README

I.e. supported options are currently not in the readme.

  • Options
  • Exported/exposed functions

An in-range update of jsonwebtoken is breaking the build 🚨

The dependency jsonwebtoken was updated from 8.3.0 to 8.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

jsonwebtoken is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • βœ… coverage/coveralls: First build on greenkeeper/jsonwebtoken-8.4.0 at 100.0% (Details).

Commits

The new version differs by 27 commits.

  • 86334aa 8.4.0
  • e7938f0 Add verify option for nonce validation (#540)
  • 0268813 devDeps: [email protected] (#539)
  • dc89a64 Edited the README.md to make certain parts of the document for the api easier to read, emphasizing the examples. (#548)
  • 8864542 Refactor tests related to kid and keyid (#545)
  • 0906a3f Refactor tests related to iss and issuer (#543)
  • 1956c40 Update README.md (#538)
  • 7f9604a Fixed error message when empty string passed as expiresIn or notBefore option (#531)
  • cfd1079 Updating Node version in Engines spec in package.json (#528)
  • 1c8ff5a Implement async/sync tests for the aud claim (#535)
  • 88bc965 Implement async/sync tests for nbf claim (#537)
  • 9ae3f20 Implement async/sync tests for exp claim (#536)
  • 342b07b Implement async/sync tests for sub claim (#534)
  • 29cd654 Document NotBeforeError (#529)
  • 683d8a9 Create and implement async/sync test helpers (#523)

There are 27 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of nyc is breaking the build 🚨

Version 11.2.0 of nyc just got published.

Branch Build failing 🚨
Dependency nyc
Current Version 11.1.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As nyc is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 7 commits.

  • b2ff72d chore(release): 11.2.0
  • 97b962e chore: explicit update of istanbul-lib-instrument (#662)
  • 0dcceda feat: allow cwd to be configured see #620
  • 0fc6d8f chore: add support for --cwd (#542) (#620)
  • 658dba4 fix: remove excluded files from coverage before writing (#649)
  • dd40dc5 feat: add possibility to filter coverage-maps (#637)
  • fb3ab92 docs: add link to community slack (#639)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.