npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webtask/jwt-middleware

v1.5.2

Published

Webtask middleware for authenticating execution using JWT V2 token

Downloads

8

Readme

JSON Web Token Middleware

This middleware allows you to secure execution of a webtask using JWT tokens by validating issuer, audience, and scope claims.

Usage

  1. Set the wt-node-dependencies metadata property to the stringified JSON of an object with names of modules as the keys and values set to the latest version for the corresponding module.

    {
        "@webtask/middleware-compiler": "1.3.0", 
        "@webtask/jwt-middleware": "1.0.0"
    }
  2. Set the wt-compiler metadata property on your webtask to @webtask/middleware-compiler.

  3. Set the wt-middleware metadata property to @webtask/jwt-middleware.

  4. Set the wt-authorize-execution metadata property to any value other than 0 to require either the wt:owner:<container> or wt:admin or the custom scope encoded in the wt-execution-scope metadata property. You can disable any authorization checks for the execution of the webtask by setting wt-authorize-execution metadata property to 0 or not including it in your request.

  5. Set the wt-execution-iss metadata property to the value of authorization_server property obtained from the discovery endpoint of your deployment (located at {deployment_url}/api/description).

  6. Set the wt-execution-aud metadata property to the value of audience property obtained from the discovery endpoint of your deployment (located at {deployment_url}/api/description).

  7. Optionally, set the wt-execution-scope metadata property to the name of a custom scope that can be used for authorization of webtask execution.

  8. Optionally, set the wt-debug metadata property to a comma-separated list of debug references that contains wt-middleware. This will result in additional debug information being sent to real-time logs.

Creating and securing a webtask using CLI

  1. Determine which profile you will use when creating the webtask or create a new one by running wt init. For more options please refer to https://webtask.io/docs/wt-cli or wt init -h.

  2. Save your webtask code into a file f.e. echo "module.exports = function (cb) { cb(null, 'Hello'); }" > hello.js.

  3. In the same folder create a file meta with all the metadata properties. Each property should be on its own line structured as KEY=VALUE pair.

    wt-authorize-execution=1
    wt-node-dependencies={"@webtask/middleware-compiler":"^1.3.0","@webtask/jwt-middleware":"^1.0.0"}
    wt-compiler=@webtask/middleware-compiler
    wt-middleware=@webtask/jwt-middleware
    wt-execution-iss={ISSUER_URI}
    wt-execution-aud={AUDIENCE_URI}
    wt-execution-scope={EXECUTION_SCOPE}
  4. Run the create command wt create hello.js --meta-file meta -p {profile_name}.