@articulate/authentic
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.2 • Public • Published

    @articulate/authentic

    @articulate/authentic Build Status Coverage Status

    Proper validation of JWT's against JWK's.

    Motivation

    The process of validating JWT's against JWK's is quite involved, but at the end of the day, you probably have an auth server with a /.well-known/openid-configuration endpoint, and you just want to know if an incoming JWT is valid. End of story. You don't want to fumble with parsing the JWT, matching kid values, converting certs, or caching JWK's.

    Now you don't need to. Initialize authentic with an issWhitelist, and you'll receive a function that accepts a JWT and validates it. The rest is handled for you.

    Usage

    authentic :: { k: v } -> String -> Promise Boom { k: v }

    Initialize authentic with an options object containing an issWhitelist array listing the token.payload.iss values you will accept. For example:

    Provider Sample issWhitelist
    Auth0 [ 'https://${tenant}.auth0.com/' ]
    Okta [ 'https://${tenant}.oktapreview.com/oauth2/${appName}' ]

    Note: The urls in the list need to be exact matches of the payload.iss values in your JWT's.

    You'll receive a unary function which takes a JWT and returns a Promise that resolves with the parsed JWT payload if it is valid, or rejects with a 401 Boom error if it is invalid.

    const authentic = require('@articulate/authentic')({
      issWhitelist: JSON.parse(process.env.ISS_WHITELIST)
    })
    
    const handler = req =>
      authentic(req.cookies.token)
        .then(/* the JWT has been validated */)

    Options

    authentic accepts a JSON object with the following options:

    • jwks Object: options to forward to node-jwks-rsa with the following defaults:
    option default
    cache true
    rateLimit true
    • verify Object: options to forward to jwt.verify from jsonwebtoken
    • issWhitelist Array: list of trusted OIDC issuers
    • claimsInError Array: list of jwt payload claims to receive as the data propery of the error when verification fails. When a list is not provided a data property will not be added to the error.

    Keywords

    none

    Install

    npm i @articulate/authentic

    DownloadsWeekly Downloads

    646

    Version

    1.3.2

    License

    MIT

    Unpacked Size

    9.59 kB

    Total Files

    8

    Last publish

    Collaborators

    • kfurness
    • amichailevy
    • jltimm
    • jbirkholz
    • auggie
    • forrest.labrum
    • tjsimons88
    • byrdsd
    • tgrossen-articulate
    • nikoden
    • sam-gale
    • glemmi
    • chad-articulate
    • patternleaf
    • kush-articulate
    • ilovitt
    • francyarticulate
    • andrii_kyr
    • msebastiian_lohika
    • vkyianytsia
    • tylerhaas
    • deckeraga
    • toristyner
    • lmallory
    • gera-fsl
    • mmichalski
    • racheldonovan
    • jamesadams11
    • jasminabasurita
    • fromonesrc
    • spencerfdavis
    • pklingem
    • kdstew
    • tecnobrat
    • jrpz
    • flintinatux
    • olena_domchevska
    • obeliaiev
    • caprisone
    • rinatsafin
    • jestefan-fsl
    • mcurran
    • spurr
    • botzo
    • mgreystone
    • tchamblee
    • rpearce
    • patrickeakin
    • bschemmel
    • dietervds
    • vscerchia
    • tylerodonnell
    • esmitharticulate
    • matthewsecrist
    • jesspoemape
    • mwinckler-articulate
    • evil
    • cfriedel
    • dbackes
    • milogert
    • mikeswart
    • brittanystoroz
    • hobbsee
    • melhotiby
    • borbulon
    • mikeolivieri
    • efoberg
    • matty-articulate
    • slodaniel
    • tracytran
    • henryng24
    • natalizh
    • iamwill
    • jalissa
    • gpalmer00
    • prosper.dev
    • mpaupulaire-articulate
    • karlamaye
    • teisia
    • ndavidson
    • nicholasodonnell
    • dpowell
    • aerielk20
    • faylee
    • matt.loberg
    • bobshields
    • jiantjon
    • bmazarelli
    • osoverflow
    • thatpamiam
    • rwc
    • jsebring_articulate
    • pwelch
    • kalebmills
    • sbaumjr
    • lucas.adriano