How to use the @authx/authx.Role.read 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 / createPasswordAuthorities.ts View on Github external
createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: id
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ];

          // Add administration scopes.
          for (const { roleId, scopes } of input.administration) {
            const role = await Role.read(tx, roleId, { forUpdate: true });

            if (
              !role.isAccessibleBy(realm, a, tx, {
                basic: "w",
                scopes: "w",
                users: ""
              })
            ) {
              throw new ForbiddenError(
                `You do not have permission to modify the scopes of role ${roleId}.`
              );
            }

            await Role.write(
              tx,
              {
github the-control-group / authx / packages / strategy-openid / src / server / graphql / mutation / createOpenIdAuthorities.ts View on Github external
createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: id
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ];

          // Add administration scopes.
          for (const { roleId, scopes } of input.administration) {
            const role = await Role.read(tx, roleId, { forUpdate: true });

            if (
              !role.isAccessibleBy(realm, a, tx, {
                basic: "w",
                scopes: "w",
                users: ""
              })
            ) {
              throw new ForbiddenError(
                `You do not have permission to modify the scopes of role ${roleId}.`
              );
            }

            await Role.write(
              tx,
              {
github the-control-group / authx / packages / strategy-password / src / server / graphql / mutation / createPasswordCredentials.ts View on Github external
{
                type: "credential",
                authorityId: credential.authorityId,
                credentialId: id,
                userId: credential.userId
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ];

          // Add administration scopes.
          for (const { roleId, scopes } of input.administration) {
            const role = await Role.read(tx, roleId, { forUpdate: true });

            if (
              !role.isAccessibleBy(realm, a, tx, {
                basic: "w",
                scopes: "w",
                users: ""
              })
            ) {
              throw new ForbiddenError(
                `You do not have permission to modify the scopes of role ${roleId}.`
              );
            }

            await Role.write(
              tx,
              {
github the-control-group / authx / packages / strategy-email / src / server / graphql / mutation / createEmailCredentials.ts View on Github external
{
              type: "credential",
              authorityId: credential.authorityId,
              credentialId: id,
              userId: credential.userId
            },
            {
              basic: "*",
              details: "*"
            }
          )
        ];

        // Add administration scopes.
        for (const { roleId, scopes } of input.administration) {
          const role = await Role.read(tx, roleId, { forUpdate: true });

          if (
            !role.isAccessibleBy(realm, a, tx, {
              basic: "w",
              scopes: "w",
              users: ""
            })
          ) {
            throw new ForbiddenError(
              `You do not have permission to modify the scopes of role ${roleId}.`
            );
          }

          await Role.write(
            tx,
            {
github the-control-group / authx / packages / strategy-openid / src / server / graphql / mutation / createOpenIdCredentials.ts View on Github external
{
              type: "credential",
              authorityId: credential.authorityId,
              credentialId: id,
              userId: credential.userId
            },
            {
              basic: "*",
              details: "*"
            }
          )
        ];

        // Add administration scopes.
        for (const { roleId, scopes } of input.administration) {
          const role = await Role.read(tx, roleId, { forUpdate: true });

          if (
            !role.isAccessibleBy(realm, a, tx, {
              basic: "w",
              scopes: "w",
              users: ""
            })
          ) {
            throw new ForbiddenError(
              `You do not have permission to modify the scopes of role ${roleId}.`
            );
          }

          await Role.write(
            tx,
            {
github the-control-group / authx / packages / strategy-email / src / server / graphql / mutation / createEmailAuthorities.ts View on Github external
createV2AuthXScope(
              realm,
              {
                type: "authority",
                authorityId: id
              },
              {
                basic: "*",
                details: "*"
              }
            )
          ];

          // Add administration scopes.
          for (const { roleId, scopes } of input.administration) {
            const role = await Role.read(tx, roleId, { forUpdate: true });

            if (
              !role.isAccessibleBy(realm, a, tx, {
                basic: "w",
                scopes: "w",
                users: ""
              })
            ) {
              throw new ForbiddenError(
                `You do not have permission to modify the scopes of role ${roleId}.`
              );
            }

            await Role.write(
              tx,
              {
github the-control-group / authx / packages / strategy-openid / src / server / model / OpenIdAuthority.ts View on Github external
public async assignsCreatedUsersToRoles(
    tx: PoolClient,
    refresh?: boolean
  ): Promise {
    if (!refresh && this._assignsCreatedUsersToRoles) {
      return this._assignsCreatedUsersToRoles;
    }

    if (!this.details.assignsCreatedUsersToRoleIds) {
      return [];
    }

    return (this._assignsCreatedUsersToRoles = Role.read(
      tx,
      this.details.assignsCreatedUsersToRoleIds
    ));
  }
}