How to use the @authx/scopes.isEqual function in @authx/scopes

To help you get started, we’ve selected a few @authx/scopes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github the-control-group / authx / packages / http-proxy-resource / src / index.ts View on Github external
);

        // There is no valid token.
        if (!scopes) {
          response.statusCode = 401;
          meta.message =
            "Restricting access." + (warning ? ` (${warning})` : "");
          meta.rule = rule;
          meta.behavior = behavior;
          send();
          return;
        }

        // The token is valid, but lacks required scopes.
        if (
          !isEqual(scopes, behavior.requireScopes) &&
          !isSuperset(scopes, behavior.requireScopes)
        ) {
          response.statusCode = 403;
          meta.message =
            "Restricting access." + (warning ? ` (${warning})` : "");
          meta.rule = rule;
          meta.behavior = behavior;
          send();
          return;
        }
      }

      // Strip the token from the proxied request.
      if (!behavior.sendTokenToTarget || !scopes) {
        delete request.headers.authorization;
      }
github the-control-group / authx / packages / authx / src / oauth2.ts View on Github external
const possibleRequestedAuthorizations = authorizations.filter(t =>
            isEqual(
              inject(requestedScopeTemplates, {
                /* eslint-disable @typescript-eslint/camelcase */
                current_user_id: grant.userId ?? null,
                current_grant_id: grant.id ?? null,
                current_client_id: grant.clientId ?? null,
                current_authorization_id: t.id ?? null
                /* eslint-enable @typescript-eslint/camelcase */
              }),
              t.scopes
            )
          );
github the-control-group / authx / packages / authx / src / oauth2.ts View on Github external
const possibleRequestedAuthorizations = authorizations.filter(t =>
            isEqual(requestedScopes, t.scopes)
          );
github the-control-group / authx / packages / authx / src / oauth2.ts View on Github external
const possibleRootAuthorizations = authorizations.filter(t =>
            isEqual("**:**:**", t.scopes)
          );

@authx/scopes

This is a small collection of utility functions for AuthX scopes. These scopes are human-readable, fully OAuth2-compatible, and support both pattern matching and set algebra.

MIT
Latest version published 7 months ago

Package Health Score

67 / 100
Full package analysis