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

@flit/cdk-auth0

v1.14.1

Published

A collection of AWS CDK constructs to manager your Auth0 resources programmatically

Downloads

2,260

Readme

This collection of CDK constructs allows you to manage your Auth0 resources programmatically, enabling tighter integration with CDK and giving you all the benefits of infrastructure as code together with Auth0's large feature set.

The constructs provided by this library work in the same way any native AWS CDK constructs do, and expose all of the parameters that the Auth0 Management API exposes.

Usage

Installation

The package is available on NPM and can be installed using your package manager of choice:

npm i @flit/cdk-auth0
pnpm add @flit/cdk-auth0
yarn add @flit/cdk-auth0

Setup

To get started you will manually create a Machine to Machine Application in your Auth0 account and authorize it to have access to all permissions of the Auth0 Management API. This is necessary to allow the constructs to interact with the Auth0 API and create and manage resources on your behalf.

Once you have the Machine to Machine Application created you can go into the AWS Secrets Manager and create a new secret containing the applications credentials in the following format:

{
  "domain": "...",
  "clientId": "...",
  "clientSecret": "..."
}

All constructs will require this secret to be passed as apiSecret parameter.

Example

You can now use the Auth0 constructs as you would any native AWS CDK constructs. The example below shows how to create an Auth0 API and Application, grant the Application access to the API and add an action to the post-login trigger:

import { Duration, Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
import {
  ResourceServer,
  Client,
  ClientGrant,
  Trigger,
  Action,
} from "@flit/cdk-auth0";

export class ExampleStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const auth0Secret = Secret.fromSecretNameV2(
      this,
      "Secret",
      "YourSecretName",
    );

    const resourceServer = new ResourceServer(this, "ResourceServer", {
      apiSecret: auth0Secret,
      enforcePolicies: true,
      allowOfflineAccess: true,
    });

    const webClient = new Client(this, "WebClient", {
      apiSecret: auth0Secret,
      appType: "regular_web",
      isFirstParty: true,
      tokenEndpointAuthMethod: "client_secret_basic",
      initiateLoginUri: "https://test.com/auth",
      callbacks: ["https://test.com/auth/callback"],
      allowedLogoutUrls: ["https://test.com"],
      oidcConformant: true,
      refreshToken: {
        rotationType: "rotating",
        expirationType: "expiring",
        tokenLifetime: Duration.days(7),
        idleTokenLifetime: Duration.days(1),
      },
      grantTypes: ["implicit", "authorization_code", "refresh_token"],
    });

    new ClientGrant(this, "ClientGrant", {
      apiSecret: auth0Secret,
      client: webClient,
      audience: resourceServer,
      scope: [],
    });

    new Trigger(this, "Auth0PostLoginTrigger", {
      apiSecret: auth0Secret,
      id: "post-login",
      actions: [
        new Action(this, "Auth0AugmentClaimAction", {
          apiSecret: auth0Secret,
          supportedTriggers: [{ id: "post-login", version: "v3" }],
          code: `
            exports.onExecutePostLogin = async (event, api) => {
              api.idToken.setCustomClaim("example", "test123");
              api.accessToken.setCustomClaim("example", "test123");
            }
          `,
        }),
      ],
    });
  }
}