How to use the @authx/authx/dist/util/scopes.createV2AuthXScope function in @authx/authx

To help you get started, we’ve selected a few @authx/authx 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 / strategy-password / src / server / graphql / mutation / authenticatePassword.ts View on Github external
const authorizationId = v4();

      const values = {
        currentAuthorizationId: authorizationId,
        currentUserId: credential.userId,
        currentGrantId: null,
        currentClientId: null
      };

      // Make sure the user can create new authorizations.
      const user = await User.read(tx, credential.userId);
      if (
        !isSuperset(
          await user.access(tx, values),
          createV2AuthXScope(
            realm,
            {
              type: "authorization",
              authorizationId: "",
              grantId: "",
              clientId: "",
              userId: user.id
            },
            {
              basic: "*",
              scopes: "*",
              secrets: "*"
            }
          )
        )
      ) {
github the-control-group / authx / packages / strategy-email / src / server / graphql / mutation / authenticateEmail.ts View on Github external
const authorizationId = v4();

      const values = {
        currentAuthorizationId: authorizationId,
        currentUserId: credential.userId,
        currentGrantId: null,
        currentClientId: null
      };

      // Make sure the user can create new authorizations.
      const user = await User.read(tx, credential.userId);
      if (
        !isSuperset(
          await user.access(tx, values),
          createV2AuthXScope(
            realm,
            {
              type: "authorization",
              authorizationId: "",
              grantId: "",
              clientId: "",
              userId: user.id
            },
            {
              basic: "*",
              scopes: "*",
              secrets: "*"
            }
          )
        )
      ) {
github the-control-group / authx / packages / strategy-openid / src / server / graphql / mutation / authenticateOpenId.ts View on Github external
throw new AuthenticationError("No such credential exists.");
      }

      const values = {
        currentAuthorizationId: authorizationId,
        currentUserId: credential.userId,
        currentGrantId: null,
        currentClientId: null
      };

      // Make sure the user can create new authorizations.
      const user = await User.read(tx, credential.userId);
      if (
        !isSuperset(
          await user.access(tx, values),
          createV2AuthXScope(
            realm,
            {
              type: "authorization",
              authorizationId: "",
              grantId: "",
              clientId: "",
              userId: user.id
            },
            {
              basic: "*",
              scopes: "*",
              secrets: "*"
            }
          )
        )
      ) {
github the-control-group / authx / packages / strategy-password / src / server / graphql / mutation / createPasswordCredentials.ts View on Github external
const tx = await pool.connect();
      try {
        const values = {
          currentAuthorizationId: a.id,
          currentUserId: a.userId,
          currentGrantId: a.grantId,
          currentClientId: (await a.grant(tx))?.clientId ?? null
        };

        // The user cannot create a credential for this user and authority.
        if (
          !(await a.can(
            tx,
            values,
            createV2AuthXScope(
              realm,
              {
                type: "credential",
                credentialId: "",
                authorityId: input.authorityId,
                userId: input.userId
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ))
        ) {
          throw new ForbiddenError(
            "You do not have permission to create this credential."
github the-control-group / authx / packages / strategy-openid / src / server / graphql / mutation / createOpenIdCredentials.ts View on Github external
)
          ))
        ) {
          throw new ForbiddenError(
            "You do not have permission to create this credential."
          );
        }

        // The user doesn't have permission to change the credentials of all
        // users, so in order to save this credential, she must prove control of
        // the account with the OpenID provider.
        if (
          !(await a.can(
            tx,
            values,
            createV2AuthXScope(
              realm,
              {
                type: "credential",
                credentialId: "",
                authorityId: input.authorityId,
                userId: "*"
              },
              {
                basic: "*",
                details: "*"
              }
            )
          )) &&
          !input.code
        ) {
          throw new ForbiddenError(
github the-control-group / authx / packages / strategy-password / src / server / graphql / mutation / createPasswordAuthorities.ts View on Github external
}

      const tx = await pool.connect();
      try {
        const values = {
          currentAuthorizationId: a.id,
          currentUserId: a.userId,
          currentGrantId: a.grantId,
          currentClientId: (await a.grant(tx))?.clientId ?? null
        };

        if (
          !(await a.can(
            tx,
            values,
            createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: ""
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ))
        ) {
          throw new ForbiddenError(
            "You do not have permission to create an authority."
          );
        }
github the-control-group / authx / packages / strategy-openid / src / server / graphql / mutation / createOpenIdCredentials.ts View on Github external
}
          ),
          createV2AuthXScope(
            realm,
            {
              type: "credential",
              authorityId: credential.authorityId,
              credentialId: id,
              userId: credential.userId
            },
            {
              basic: "w",
              details: ""
            }
          ),
          createV2AuthXScope(
            realm,
            {
              type: "credential",
              authorityId: credential.authorityId,
              credentialId: id,
              userId: credential.userId
            },
            {
              basic: "w",
              details: "w"
            }
          ),
          createV2AuthXScope(
            realm,
            {
              type: "credential",
github the-control-group / authx / packages / strategy-password / src / server / graphql / mutation / createPasswordCredentials.ts View on Github external
}
            ),
            createV2AuthXScope(
              realm,
              {
                type: "credential",
                authorityId: credential.authorityId,
                credentialId: id,
                userId: credential.userId
              },
              {
                basic: "r",
                details: "*"
              }
            ),
            createV2AuthXScope(
              realm,
              {
                type: "credential",
                authorityId: credential.authorityId,
                credentialId: id,
                userId: credential.userId
              },
              {
                basic: "w",
                details: ""
              }
            ),
            createV2AuthXScope(
              realm,
              {
                type: "credential",
github the-control-group / authx / packages / strategy-password / src / server / graphql / mutation / createPasswordAuthorities.ts View on Github external
}
          );

          const possibleAdministrationScopes = [
            createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: id
              },
              {
                basic: "r",
                details: ""
              }
            ),
            createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: id
              },
              {
                basic: "r",
                details: "r"
              }
            ),
            createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: id
              },
github the-control-group / authx / packages / strategy-email / src / server / graphql / mutation / createEmailAuthorities.ts View on Github external
}

      const tx = await pool.connect();
      try {
        const values = {
          currentAuthorizationId: a.id,
          currentUserId: a.userId,
          currentGrantId: a.grantId,
          currentClientId: (await a.grant(tx))?.clientId ?? null
        };

        if (
          !(await a.can(
            tx,
            values,
            createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: ""
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ))
        ) {
          throw new ForbiddenError(
            "You do not have permission to create an authority."
          );
        }