@contember/engine-tenant-api 1.3.0-alpha.7 → 1.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/TenantContainer.d.ts +17 -3
- package/dist/src/TenantContainer.d.ts.map +1 -1
- package/dist/src/TenantContainer.js +7 -0
- package/dist/src/TenantContainer.js.map +1 -1
- package/dist/src/bridges/system/IdentityFetcher.d.ts +1 -1
- package/dist/src/bridges/system/IdentityFetcher.d.ts.map +1 -1
- package/dist/src/migrations/2023-01-20-135500-person-email-normalize.d.ts +3 -0
- package/dist/src/migrations/2023-01-20-135500-person-email-normalize.d.ts.map +1 -0
- package/dist/src/migrations/2023-01-20-135500-person-email-normalize.js +28 -0
- package/dist/src/migrations/2023-01-20-135500-person-email-normalize.js.map +1 -0
- package/dist/src/migrations/2023-06-03-104000-person-disabled.d.ts +3 -0
- package/dist/src/migrations/2023-06-03-104000-person-disabled.d.ts.map +1 -0
- package/dist/src/migrations/2023-06-03-104000-person-disabled.js +11 -0
- package/dist/src/migrations/2023-06-03-104000-person-disabled.js.map +1 -0
- package/dist/src/migrations/runner.d.ts.map +1 -1
- package/dist/src/migrations/runner.js +4 -0
- package/dist/src/migrations/runner.js.map +1 -1
- package/dist/src/migrations/snapshot.d.ts.map +1 -1
- package/dist/src/migrations/snapshot.js +1 -0
- package/dist/src/migrations/snapshot.js.map +1 -1
- package/dist/src/model/authorization/AclSchemaAccessNodeFactory.d.ts.map +1 -1
- package/dist/src/model/authorization/AclSchemaAccessNodeFactory.js +14 -9
- package/dist/src/model/authorization/AclSchemaAccessNodeFactory.js.map +1 -1
- package/dist/src/model/authorization/MembershipMatcher.d.ts +1 -1
- package/dist/src/model/authorization/MembershipMatcher.d.ts.map +1 -1
- package/dist/src/model/authorization/PermissionActions.d.ts +21 -0
- package/dist/src/model/authorization/PermissionActions.d.ts.map +1 -1
- package/dist/src/model/authorization/PermissionActions.js +4 -2
- package/dist/src/model/authorization/PermissionActions.js.map +1 -1
- package/dist/src/model/authorization/PermissionContext.d.ts +1 -1
- package/dist/src/model/authorization/PermissionContext.d.ts.map +1 -1
- package/dist/src/model/authorization/PermissionsFactory.d.ts.map +1 -1
- package/dist/src/model/authorization/PermissionsFactory.js +6 -3
- package/dist/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/src/model/authorization/Roles.js +1 -1
- package/dist/src/model/authorization/Roles.js.map +1 -1
- package/dist/src/model/commands/apiKey/CreateApiKeyCommand.d.ts +1 -1
- package/dist/src/model/commands/apiKey/CreateApiKeyCommand.d.ts.map +1 -1
- package/dist/src/model/commands/identity/PatchIdentityGlobalRoles.d.ts +9 -0
- package/dist/src/model/commands/identity/PatchIdentityGlobalRoles.d.ts.map +1 -0
- package/dist/src/model/commands/identity/PatchIdentityGlobalRoles.js +29 -0
- package/dist/src/model/commands/identity/PatchIdentityGlobalRoles.js.map +1 -0
- package/dist/src/model/commands/identity/index.d.ts +1 -0
- package/dist/src/model/commands/identity/index.d.ts.map +1 -1
- package/dist/src/model/commands/identity/index.js +1 -0
- package/dist/src/model/commands/identity/index.js.map +1 -1
- package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts +1 -1
- package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts.map +1 -1
- package/dist/src/model/commands/membership/AddProjectMemberCommand.d.ts +2 -6
- package/dist/src/model/commands/membership/AddProjectMemberCommand.d.ts.map +1 -1
- package/dist/src/model/commands/membership/AddProjectMemberCommand.js +5 -11
- package/dist/src/model/commands/membership/AddProjectMemberCommand.js.map +1 -1
- package/dist/src/model/commands/membership/RemoveProjectMemberCommand.d.ts +1 -1
- package/dist/src/model/commands/membership/RemoveProjectMemberCommand.d.ts.map +1 -1
- package/dist/src/model/commands/membership/RemoveProjectMemberCommand.js +1 -2
- package/dist/src/model/commands/membership/RemoveProjectMemberCommand.js.map +1 -1
- package/dist/src/model/commands/membership/UpdateProjectMemberCommand.d.ts +1 -1
- package/dist/src/model/commands/membership/UpdateProjectMemberCommand.d.ts.map +1 -1
- package/dist/src/model/commands/membership/UpdateProjectMemberCommand.js +2 -3
- package/dist/src/model/commands/membership/UpdateProjectMemberCommand.js.map +1 -1
- package/dist/src/model/commands/membership/types.d.ts +3 -3
- package/dist/src/model/commands/membership/types.d.ts.map +1 -1
- package/dist/src/model/commands/passwordReset/ResetPasswordCommand.d.ts +2 -6
- package/dist/src/model/commands/passwordReset/ResetPasswordCommand.d.ts.map +1 -1
- package/dist/src/model/commands/passwordReset/ResetPasswordCommand.js +5 -11
- package/dist/src/model/commands/passwordReset/ResetPasswordCommand.js.map +1 -1
- package/dist/src/model/commands/person/CreatePersonCommand.d.ts.map +1 -1
- package/dist/src/model/commands/person/CreatePersonCommand.js +10 -5
- package/dist/src/model/commands/person/CreatePersonCommand.js.map +1 -1
- package/dist/src/model/commands/person/DisablePersonCommand.d.ts +7 -0
- package/dist/src/model/commands/person/DisablePersonCommand.d.ts.map +1 -0
- package/dist/src/model/commands/person/DisablePersonCommand.js +22 -0
- package/dist/src/model/commands/person/DisablePersonCommand.js.map +1 -0
- package/dist/src/model/dtos/Password.d.ts +1 -1
- package/dist/src/model/dtos/Password.d.ts.map +1 -1
- package/dist/src/model/mailing/type.js +1 -1
- package/dist/src/model/mailing/type.js.map +1 -1
- package/dist/src/model/queries/apiKey/ApiKeyQuery.d.ts +23 -0
- package/dist/src/model/queries/apiKey/ApiKeyQuery.d.ts.map +1 -0
- package/dist/src/model/queries/apiKey/ApiKeyQuery.js +45 -0
- package/dist/src/model/queries/apiKey/ApiKeyQuery.js.map +1 -0
- package/dist/src/model/queries/apiKey/index.d.ts +1 -1
- package/dist/src/model/queries/apiKey/index.d.ts.map +1 -1
- package/dist/src/model/queries/apiKey/index.js +1 -1
- package/dist/src/model/queries/apiKey/index.js.map +1 -1
- package/dist/src/model/queries/idp/types.d.ts +4 -4
- package/dist/src/model/queries/idp/types.d.ts.map +1 -1
- package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts +1 -1
- package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts.map +1 -1
- package/dist/src/model/queries/membership/ProjectMembersQuery.js +3 -4
- package/dist/src/model/queries/membership/ProjectMembersQuery.js.map +1 -1
- package/dist/src/model/queries/person/PersonQuery.d.ts +4 -3
- package/dist/src/model/queries/person/PersonQuery.d.ts.map +1 -1
- package/dist/src/model/queries/person/PersonQuery.js +22 -0
- package/dist/src/model/queries/person/PersonQuery.js.map +1 -1
- package/dist/src/model/queries/person/PersonQueryBuilderFactory.d.ts.map +1 -1
- package/dist/src/model/queries/person/PersonQueryBuilderFactory.js +1 -0
- package/dist/src/model/queries/person/PersonQueryBuilderFactory.js.map +1 -1
- package/dist/src/model/queries/person/types.d.ts +4 -3
- package/dist/src/model/queries/person/types.d.ts.map +1 -1
- package/dist/src/model/queries/project/ProjectSecretsQuery.d.ts +1 -1
- package/dist/src/model/queries/project/ProjectSecretsQuery.d.ts.map +1 -1
- package/dist/src/model/service/IDPSignInManager.d.ts.map +1 -1
- package/dist/src/model/service/IDPSignInManager.js +8 -6
- package/dist/src/model/service/IDPSignInManager.js.map +1 -1
- package/dist/src/model/service/InviteManager.d.ts +1 -1
- package/dist/src/model/service/InviteManager.d.ts.map +1 -1
- package/dist/src/model/service/InviteManager.js +2 -3
- package/dist/src/model/service/InviteManager.js.map +1 -1
- package/dist/src/model/service/OtpAuthenticator.d.ts +1 -1
- package/dist/src/model/service/OtpAuthenticator.d.ts.map +1 -1
- package/dist/src/model/service/PasswordChangeManager.js +4 -5
- package/dist/src/model/service/PasswordChangeManager.js.map +1 -1
- package/dist/src/model/service/PasswordResetManager.d.ts +2 -4
- package/dist/src/model/service/PasswordResetManager.d.ts.map +1 -1
- package/dist/src/model/service/PasswordResetManager.js +2 -6
- package/dist/src/model/service/PasswordResetManager.js.map +1 -1
- package/dist/src/model/service/PersonAccessManager.d.ts +14 -0
- package/dist/src/model/service/PersonAccessManager.d.ts.map +1 -0
- package/dist/src/model/service/PersonAccessManager.js +42 -0
- package/dist/src/model/service/PersonAccessManager.js.map +1 -0
- package/dist/src/model/service/PersonManager.d.ts +7 -0
- package/dist/src/model/service/PersonManager.d.ts.map +1 -0
- package/dist/src/model/service/PersonManager.js +11 -0
- package/dist/src/model/service/PersonManager.js.map +1 -0
- package/dist/src/model/service/ProjectManager.d.ts +1 -1
- package/dist/src/model/service/ProjectManager.d.ts.map +1 -1
- package/dist/src/model/service/ProjectManager.js +2 -3
- package/dist/src/model/service/ProjectManager.js.map +1 -1
- package/dist/src/model/service/ProjectMemberManager.d.ts +2 -2
- package/dist/src/model/service/ProjectMemberManager.d.ts.map +1 -1
- package/dist/src/model/service/ProjectMemberManager.js +3 -16
- package/dist/src/model/service/ProjectMemberManager.js.map +1 -1
- package/dist/src/model/service/RolesManager.d.ts +11 -0
- package/dist/src/model/service/RolesManager.d.ts.map +1 -0
- package/dist/src/model/service/RolesManager.js +35 -0
- package/dist/src/model/service/RolesManager.js.map +1 -0
- package/dist/src/model/service/SignInManager.d.ts +2 -2
- package/dist/src/model/service/SignInManager.d.ts.map +1 -1
- package/dist/src/model/service/SignInManager.js +13 -8
- package/dist/src/model/service/SignInManager.js.map +1 -1
- package/dist/src/model/service/SignUpManager.d.ts +2 -2
- package/dist/src/model/service/SignUpManager.d.ts.map +1 -1
- package/dist/src/model/service/SignUpManager.js +2 -3
- package/dist/src/model/service/SignUpManager.js.map +1 -1
- package/dist/src/model/service/apiKey/ApiKeyManager.d.ts +3 -1
- package/dist/src/model/service/apiKey/ApiKeyManager.d.ts.map +1 -1
- package/dist/src/model/service/apiKey/ApiKeyManager.js +4 -1
- package/dist/src/model/service/apiKey/ApiKeyManager.js.map +1 -1
- package/dist/src/model/service/apiKey/ApiKeyService.d.ts +1 -1
- package/dist/src/model/service/apiKey/ApiKeyService.d.ts.map +1 -1
- package/dist/src/model/service/idp/IDPManager.d.ts +4 -4
- package/dist/src/model/service/idp/IDPManager.d.ts.map +1 -1
- package/dist/src/model/service/idp/IDPManager.js +7 -8
- package/dist/src/model/service/idp/IDPManager.js.map +1 -1
- package/dist/src/model/service/idp/providers/AppleProvider.d.ts +1 -1
- package/dist/src/model/service/idp/providers/AppleProvider.d.ts.map +1 -1
- package/dist/src/model/service/idp/providers/FacebookProvider.d.ts +1 -1
- package/dist/src/model/service/idp/providers/FacebookProvider.d.ts.map +1 -1
- package/dist/src/model/service/idp/providers/OIDCTypes.d.ts +3 -3
- package/dist/src/model/service/idp/providers/OIDCTypes.d.ts.map +1 -1
- package/dist/src/model/service/index.d.ts +2 -0
- package/dist/src/model/service/index.d.ts.map +1 -1
- package/dist/src/model/service/index.js +2 -0
- package/dist/src/model/service/index.js.map +1 -1
- package/dist/src/model/type/Variables.d.ts +1 -1
- package/dist/src/model/type/Variables.d.ts.map +1 -1
- package/dist/src/model/utils/Response.d.ts +2 -2
- package/dist/src/model/utils/Response.d.ts.map +1 -1
- package/dist/src/model/utils/email.d.ts +2 -0
- package/dist/src/model/utils/email.d.ts.map +1 -0
- package/dist/src/model/utils/email.js +8 -0
- package/dist/src/model/utils/email.js.map +1 -0
- package/dist/src/model/utils/tokenUtils.d.ts +1 -1
- package/dist/src/model/utils/tokenUtils.d.ts.map +1 -1
- package/dist/src/model/utils/typeUtils.d.ts +1 -1
- package/dist/src/model/utils/typeUtils.d.ts.map +1 -1
- package/dist/src/resolvers/ResolverFactory.d.ts +4 -1
- package/dist/src/resolvers/ResolverFactory.d.ts.map +1 -1
- package/dist/src/resolvers/ResolverFactory.js +3 -0
- package/dist/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/src/resolvers/errorUtils.d.ts +3 -3
- package/dist/src/resolvers/errorUtils.d.ts.map +1 -1
- package/dist/src/resolvers/errorUtils.js.map +1 -1
- package/dist/src/resolvers/membershipUtils.d.ts +4 -9
- package/dist/src/resolvers/membershipUtils.d.ts.map +1 -1
- package/dist/src/resolvers/membershipUtils.js +10 -18
- package/dist/src/resolvers/membershipUtils.js.map +1 -1
- package/dist/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/identity/GlobalRolesMutationResolver.d.ts +11 -0
- package/dist/src/resolvers/mutation/identity/GlobalRolesMutationResolver.d.ts.map +1 -0
- package/dist/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js +44 -0
- package/dist/src/resolvers/mutation/identity/GlobalRolesMutationResolver.js.map +1 -0
- package/dist/src/resolvers/mutation/identity/index.d.ts +2 -0
- package/dist/src/resolvers/mutation/identity/index.d.ts.map +1 -0
- package/dist/src/resolvers/mutation/identity/index.js +18 -0
- package/dist/src/resolvers/mutation/identity/index.js.map +1 -0
- package/dist/src/resolvers/mutation/index.d.ts +1 -0
- package/dist/src/resolvers/mutation/index.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/index.js +1 -0
- package/dist/src/resolvers/mutation/index.js.map +1 -1
- package/dist/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js +6 -7
- package/dist/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/ChangePasswordMutationResolver.js +2 -3
- package/dist/src/resolvers/mutation/person/ChangePasswordMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/DisablePersonMutationResolver.d.ts +11 -0
- package/dist/src/resolvers/mutation/person/DisablePersonMutationResolver.d.ts.map +1 -0
- package/dist/src/resolvers/mutation/person/DisablePersonMutationResolver.js +36 -0
- package/dist/src/resolvers/mutation/person/DisablePersonMutationResolver.js.map +1 -0
- package/dist/src/resolvers/mutation/person/InviteMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/person/InviteMutationResolver.js +3 -4
- package/dist/src/resolvers/mutation/person/InviteMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/OtpMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/person/OtpMutationResolver.js +3 -4
- package/dist/src/resolvers/mutation/person/OtpMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/ResetPasswordMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/person/ResetPasswordMutationResolver.js +2 -10
- package/dist/src/resolvers/mutation/person/ResetPasswordMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/SignInMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/person/SignInMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/person/SignOutMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/person/SignOutMutationResolver.js +5 -2
- package/dist/src/resolvers/mutation/person/SignOutMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/project/CreateProjectMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/project/CreateProjectMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/project/CreateProjectMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/project/SetProjectSecretMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/project/UpdateProjectMutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/mutation/project/UpdateProjectMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/project/UpdateProjectMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.js.map +1 -1
- package/dist/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js +1 -2
- package/dist/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.js.map +1 -1
- package/dist/src/resolvers/types/ProjectTypeResolver.d.ts.map +1 -1
- package/dist/src/resolvers/types/ProjectTypeResolver.js +5 -6
- package/dist/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
- package/dist/src/schema/index.d.ts +431 -397
- package/dist/src/schema/index.d.ts.map +1 -1
- package/dist/src/schema/index.js +0 -188
- package/dist/src/schema/index.js.map +1 -1
- package/dist/src/schema/tenant.graphql.d.ts.map +1 -1
- package/dist/src/schema/tenant.graphql.js +97 -21
- package/dist/src/schema/tenant.graphql.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/Mailer.d.ts +1 -1
- package/dist/src/utils/Mailer.d.ts.map +1 -1
- package/dist/src/utils/array.d.ts +1 -1
- package/dist/src/utils/array.d.ts.map +1 -1
- package/dist/src/utils/batchQuery.d.ts +2 -2
- package/dist/src/utils/batchQuery.d.ts.map +1 -1
- package/dist/tests/cases/integration/db/updateRoles.test.d.ts +2 -0
- package/dist/tests/cases/integration/db/updateRoles.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/db/updateRoles.test.js +67 -0
- package/dist/tests/cases/integration/db/updateRoles.test.js.map +1 -0
- package/dist/tests/cases/integration/mocked/confirmOtpMutation.test.js +1 -2
- package/dist/tests/cases/integration/mocked/confirmOtpMutation.test.js.map +1 -1
- package/dist/tests/cases/integration/mocked/gql/signUp.d.ts.map +1 -1
- package/dist/tests/cases/integration/mocked/gql/signUp.js +4 -0
- package/dist/tests/cases/integration/mocked/gql/signUp.js.map +1 -1
- package/dist/tests/cases/integration/mocked/gql/types.d.ts +1 -1
- package/dist/tests/cases/integration/mocked/gql/types.d.ts.map +1 -1
- package/dist/tests/cases/integration/mocked/signInMutation.test.js +36 -4
- package/dist/tests/cases/integration/mocked/signInMutation.test.js.map +1 -1
- package/dist/tests/cases/integration/mocked/signOutMutation.test.js +53 -0
- package/dist/tests/cases/integration/mocked/signOutMutation.test.js.map +1 -1
- package/dist/tests/cases/integration/mocked/signUpMutation.test.js +9 -0
- package/dist/tests/cases/integration/mocked/signUpMutation.test.js.map +1 -1
- package/dist/tests/cases/integration/mocked/sql/getApiKeySql.d.ts +11 -0
- package/dist/tests/cases/integration/mocked/sql/getApiKeySql.d.ts.map +1 -0
- package/dist/tests/cases/integration/mocked/sql/getApiKeySql.js +31 -0
- package/dist/tests/cases/integration/mocked/sql/getApiKeySql.js.map +1 -0
- package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.d.ts.map +1 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.js +2 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByEmailSql.js.map +1 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByIdSql.js +1 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByIdentity.js +1 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByIdpSql.d.ts.map +1 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByIdpSql.js +2 -1
- package/dist/tests/cases/integration/mocked/sql/getPersonByIdpSql.js.map +1 -1
- package/dist/tests/cases/unit/authorization/membershipAwareAccessNode.test.js +27 -0
- package/dist/tests/cases/unit/authorization/membershipAwareAccessNode.test.js.map +1 -1
- package/dist/tests/src/mailer.d.ts +2 -2
- package/dist/tests/src/mailer.d.ts.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/graphql-tenant.codegen.yml +2 -1
- package/package.json +14 -14
- package/src/TenantContainer.ts +19 -2
- package/src/migrations/2023-01-20-135500-person-email-normalize.ts +28 -0
- package/src/migrations/2023-06-03-104000-person-disabled.ts +10 -0
- package/src/migrations/runner.ts +4 -0
- package/src/migrations/snapshot.ts +1 -0
- package/src/model/authorization/AclSchemaAccessNodeFactory.ts +16 -6
- package/src/model/authorization/PermissionActions.ts +5 -0
- package/src/model/authorization/PermissionsFactory.ts +11 -3
- package/src/model/commands/identity/PatchIdentityGlobalRoles.ts +28 -0
- package/src/model/commands/identity/index.ts +1 -0
- package/src/model/commands/membership/AddProjectMemberCommand.ts +9 -10
- package/src/model/commands/membership/RemoveProjectMemberCommand.ts +1 -1
- package/src/model/commands/membership/UpdateProjectMemberCommand.ts +2 -2
- package/src/model/commands/passwordReset/ResetPasswordCommand.ts +9 -16
- package/src/model/commands/person/CreatePersonCommand.ts +9 -4
- package/src/model/commands/person/DisablePersonCommand.ts +18 -0
- package/src/model/queries/apiKey/ApiKeyQuery.ts +64 -0
- package/src/model/queries/apiKey/index.ts +1 -1
- package/src/model/queries/idp/types.ts +2 -2
- package/src/model/queries/membership/ProjectMembersQuery.ts +3 -3
- package/src/model/queries/person/PersonQuery.ts +30 -3
- package/src/model/queries/person/PersonQueryBuilderFactory.ts +1 -0
- package/src/model/queries/person/types.ts +3 -2
- package/src/model/service/IDPSignInManager.ts +11 -6
- package/src/model/service/InviteManager.ts +2 -2
- package/src/model/service/PasswordChangeManager.ts +4 -4
- package/src/model/service/PasswordResetManager.ts +3 -5
- package/src/model/service/PersonAccessManager.ts +56 -0
- package/src/model/service/PersonManager.ts +14 -0
- package/src/model/service/ProjectManager.ts +3 -3
- package/src/model/service/ProjectMemberManager.ts +3 -15
- package/src/model/service/RolesManager.ts +40 -0
- package/src/model/service/SignInManager.ts +25 -7
- package/src/model/service/SignUpManager.ts +2 -2
- package/src/model/service/apiKey/ApiKeyManager.ts +8 -1
- package/src/model/service/idp/IDPManager.ts +8 -8
- package/src/model/service/index.ts +2 -0
- package/src/model/utils/Response.ts +1 -1
- package/src/model/utils/email.ts +5 -0
- package/src/resolvers/ResolverFactory.ts +10 -1
- package/src/resolvers/errorUtils.ts +1 -1
- package/src/resolvers/membershipUtils.ts +21 -21
- package/src/resolvers/mutation/apiKey/CreateApiKeyMutationResolver.ts +2 -2
- package/src/resolvers/mutation/apiKey/DisableApiKeyMutationResolver.ts +1 -1
- package/src/resolvers/mutation/identity/GlobalRolesMutationResolver.ts +69 -0
- package/src/resolvers/mutation/identity/index.ts +1 -0
- package/src/resolvers/mutation/index.ts +1 -0
- package/src/resolvers/mutation/mailTemplates/MailTemplateMutationResolver.ts +6 -6
- package/src/resolvers/mutation/person/ChangePasswordMutationResolver.ts +2 -2
- package/src/resolvers/mutation/person/DisablePersonMutationResolver.ts +48 -0
- package/src/resolvers/mutation/person/InviteMutationResolver.ts +5 -12
- package/src/resolvers/mutation/person/OtpMutationResolver.ts +4 -6
- package/src/resolvers/mutation/person/ResetPasswordMutationResolver.ts +2 -10
- package/src/resolvers/mutation/person/SignInMutationResolver.ts +1 -0
- package/src/resolvers/mutation/person/SignOutMutationResolver.ts +13 -3
- package/src/resolvers/mutation/project/CreateProjectMutationResolver.ts +2 -7
- package/src/resolvers/mutation/project/SetProjectSecretMutationResolver.ts +1 -1
- package/src/resolvers/mutation/project/UpdateProjectMutationResolver.ts +2 -7
- package/src/resolvers/mutation/projectMember/AddProjectMemberMutationResolver.ts +2 -2
- package/src/resolvers/mutation/projectMember/RemoveProjectMemberMutationResolver.ts +1 -1
- package/src/resolvers/mutation/projectMember/UpdateProjectMemberMutationResolver.ts +2 -2
- package/src/resolvers/types/ProjectTypeResolver.ts +2 -2
- package/src/schema/index.ts +321 -159
- package/src/schema/tenant.graphql.ts +97 -21
- package/tests/cases/integration/db/updateRoles.test.ts +74 -0
- package/tests/cases/integration/mocked/confirmOtpMutation.test.ts +1 -1
- package/tests/cases/integration/mocked/gql/signUp.ts +4 -0
- package/tests/cases/integration/mocked/signInMutation.test.ts +37 -3
- package/tests/cases/integration/mocked/signOutMutation.test.ts +58 -0
- package/tests/cases/integration/mocked/signUpMutation.test.ts +9 -0
- package/tests/cases/integration/mocked/sql/getApiKeySql.ts +33 -0
- package/tests/cases/integration/mocked/sql/getPersonByEmailSql.ts +2 -1
- package/tests/cases/integration/mocked/sql/getPersonByIdSql.ts +1 -1
- package/tests/cases/integration/mocked/sql/getPersonByIdentity.ts +1 -1
- package/tests/cases/integration/mocked/sql/getPersonByIdpSql.ts +2 -1
- package/tests/cases/unit/authorization/membershipAwareAccessNode.test.ts +36 -0
- package/dist/src/model/queries/apiKey/ApiKeyByTokenQuery.d.ts +0 -22
- package/dist/src/model/queries/apiKey/ApiKeyByTokenQuery.d.ts.map +0 -1
- package/dist/src/model/queries/apiKey/ApiKeyByTokenQuery.js +0 -33
- package/dist/src/model/queries/apiKey/ApiKeyByTokenQuery.js.map +0 -1
- package/src/model/queries/apiKey/ApiKeyByTokenQuery.ts +0 -49
|
@@ -34,12 +34,12 @@ const schema: DocumentNode = gql`
|
|
|
34
34
|
redirectUrl: String @deprecated(reason: "use data.redirectUrl")
|
|
35
35
|
): InitSignInIDPResponse
|
|
36
36
|
signInIDP(
|
|
37
|
-
identityProvider: String!,
|
|
37
|
+
identityProvider: String!,
|
|
38
38
|
data: Json,
|
|
39
39
|
expiration: Int
|
|
40
|
-
|
|
41
|
-
redirectUrl: String @deprecated(reason: "use data.redirectUrl"),
|
|
42
|
-
sessionData: Json @deprecated(reason: "use data.sessionData"),
|
|
40
|
+
idpResponse: IDPResponseInput, @deprecated(reason: "pass idpResponse.url as data.url")
|
|
41
|
+
redirectUrl: String @deprecated(reason: "use data.redirectUrl"),
|
|
42
|
+
sessionData: Json @deprecated(reason: "use data.sessionData"),
|
|
43
43
|
): SignInIDPResponse
|
|
44
44
|
|
|
45
45
|
# IDP management
|
|
@@ -52,6 +52,8 @@ const schema: DocumentNode = gql`
|
|
|
52
52
|
confirmOtp(otpToken: String!): ConfirmOtpResponse
|
|
53
53
|
disableOtp: DisableOtpResponse
|
|
54
54
|
|
|
55
|
+
disablePerson(personId: String!): DisablePersonResponse
|
|
56
|
+
|
|
55
57
|
createResetPasswordRequest(email: String!, options: CreateResetPasswordRequestOptions): CreatePasswordResetRequestResponse
|
|
56
58
|
resetPassword(token: String!, password: String!): ResetPasswordResponse
|
|
57
59
|
|
|
@@ -73,6 +75,8 @@ const schema: DocumentNode = gql`
|
|
|
73
75
|
createApiKey(projectSlug: String!, memberships: [MembershipInput!]!, description: String!, tokenHash: String): CreateApiKeyResponse
|
|
74
76
|
createGlobalApiKey(description: String!, roles: [String!], tokenHash: String): CreateApiKeyResponse
|
|
75
77
|
disableApiKey(id: String!): DisableApiKeyResponse
|
|
78
|
+
addGlobalIdentityRoles(identityId: String!, roles: [String!]!): AddGlobalIdentityRolesResponse
|
|
79
|
+
removeGlobalIdentityRoles(identityId: String!, roles: [String!]!): RemoveGlobalIdentityRolesResponse
|
|
76
80
|
|
|
77
81
|
addMailTemplate(template: MailTemplate!): AddMailTemplateResponse
|
|
78
82
|
removeMailTemplate(templateIdentifier: MailTemplateIdentifier!): RemoveMailTemplateResponse
|
|
@@ -89,10 +93,10 @@ const schema: DocumentNode = gql`
|
|
|
89
93
|
updateProject(projectSlug: String!, name: String, config: Json, mergeConfig: Boolean): UpdateProjectResponse
|
|
90
94
|
|
|
91
95
|
addProjectMailTemplate(template: MailTemplate!): AddMailTemplateResponse
|
|
92
|
-
|
|
96
|
+
@deprecated(reason: "use addMailTemplate")
|
|
93
97
|
|
|
94
98
|
removeProjectMailTemplate(templateIdentifier: MailTemplateIdentifier!): RemoveMailTemplateResponse
|
|
95
|
-
|
|
99
|
+
@deprecated(reason: "use removeMailTemplate")
|
|
96
100
|
|
|
97
101
|
}
|
|
98
102
|
|
|
@@ -143,6 +147,7 @@ const schema: DocumentNode = gql`
|
|
|
143
147
|
enum SignInErrorCode {
|
|
144
148
|
UNKNOWN_EMAIL
|
|
145
149
|
INVALID_PASSWORD
|
|
150
|
+
PERSON_DISABLED
|
|
146
151
|
NO_PASSWORD_SET
|
|
147
152
|
OTP_REQUIRED
|
|
148
153
|
INVALID_OTP_TOKEN
|
|
@@ -169,6 +174,7 @@ const schema: DocumentNode = gql`
|
|
|
169
174
|
enum CreateSessionTokenErrorCode {
|
|
170
175
|
UNKNOWN_EMAIL
|
|
171
176
|
UNKNOWN_PERSON_ID
|
|
177
|
+
PERSON_DISABLED
|
|
172
178
|
}
|
|
173
179
|
|
|
174
180
|
type CreateSessionTokenResult implements CommonSignInResult{
|
|
@@ -191,7 +197,8 @@ const schema: DocumentNode = gql`
|
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
enum SignOutErrorCode {
|
|
194
|
-
NOT_A_PERSON
|
|
200
|
+
NOT_A_PERSON,
|
|
201
|
+
NOT_POSSIBLE_SIGN_OUT_WITH_PERMANENT_API_KEY
|
|
195
202
|
}
|
|
196
203
|
|
|
197
204
|
# === changePassword ===
|
|
@@ -253,7 +260,7 @@ const schema: DocumentNode = gql`
|
|
|
253
260
|
|
|
254
261
|
enum InitSignInIDPErrorCode {
|
|
255
262
|
PROVIDER_NOT_FOUND
|
|
256
|
-
|
|
263
|
+
IDP_VALIDATION_FAILED
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
input IDPResponseInput {
|
|
@@ -278,6 +285,7 @@ const schema: DocumentNode = gql`
|
|
|
278
285
|
IDP_VALIDATION_FAILED
|
|
279
286
|
|
|
280
287
|
PERSON_NOT_FOUND
|
|
288
|
+
PERSON_DISABLED
|
|
281
289
|
PERSON_ALREADY_EXISTS
|
|
282
290
|
}
|
|
283
291
|
|
|
@@ -329,8 +337,8 @@ const schema: DocumentNode = gql`
|
|
|
329
337
|
}
|
|
330
338
|
|
|
331
339
|
enum DisableIDPErrorCode {
|
|
332
|
-
|
|
333
|
-
|
|
340
|
+
NOT_FOUND
|
|
341
|
+
}
|
|
334
342
|
|
|
335
343
|
type EnableIDPResponse {
|
|
336
344
|
error: EnableIDPError
|
|
@@ -343,14 +351,14 @@ const schema: DocumentNode = gql`
|
|
|
343
351
|
}
|
|
344
352
|
|
|
345
353
|
enum EnableIDPErrorCode {
|
|
346
|
-
|
|
354
|
+
NOT_FOUND
|
|
347
355
|
}
|
|
348
356
|
|
|
349
357
|
type IdentityProvider {
|
|
350
358
|
slug: String!
|
|
351
359
|
type: String!
|
|
352
360
|
configuration: Json!
|
|
353
|
-
disabledAt: DateTime
|
|
361
|
+
disabledAt: DateTime
|
|
354
362
|
options: IDPOptionsOutput!
|
|
355
363
|
}
|
|
356
364
|
|
|
@@ -527,7 +535,50 @@ const schema: DocumentNode = gql`
|
|
|
527
535
|
enum DisableApiKeyErrorCode {
|
|
528
536
|
KEY_NOT_FOUND
|
|
529
537
|
}
|
|
538
|
+
# === addGlobalIdentityRoles ===
|
|
539
|
+
|
|
540
|
+
type AddGlobalIdentityRolesResponse {
|
|
541
|
+
ok: Boolean!
|
|
542
|
+
error: AddGlobalIdentityRolesError
|
|
543
|
+
result: AddGlobalIdentityRolesResult
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
type AddGlobalIdentityRolesResult {
|
|
547
|
+
identity: Identity!
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
type AddGlobalIdentityRolesError {
|
|
551
|
+
code: AddGlobalIdentityRolesErrorCode!
|
|
552
|
+
developerMessage: String!
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
enum AddGlobalIdentityRolesErrorCode {
|
|
556
|
+
IDENTITY_NOT_FOUND
|
|
557
|
+
INVALID_ROLE
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
# === removeGlobalIdentityRoles ===
|
|
562
|
+
|
|
563
|
+
type RemoveGlobalIdentityRolesResponse {
|
|
564
|
+
ok: Boolean!
|
|
565
|
+
error: RemoveGlobalIdentityRolesError
|
|
566
|
+
result: RemoveGlobalIdentityRolesResult
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
type RemoveGlobalIdentityRolesError {
|
|
570
|
+
code: RemoveGlobalIdentityRolesErrorCode!
|
|
571
|
+
developerMessage: String!
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
type RemoveGlobalIdentityRolesResult {
|
|
575
|
+
identity: Identity!
|
|
576
|
+
}
|
|
530
577
|
|
|
578
|
+
enum RemoveGlobalIdentityRolesErrorCode {
|
|
579
|
+
IDENTITY_NOT_FOUND
|
|
580
|
+
INVALID_ROLE
|
|
581
|
+
}
|
|
531
582
|
# === common ===
|
|
532
583
|
|
|
533
584
|
# === variables ===
|
|
@@ -714,6 +765,21 @@ const schema: DocumentNode = gql`
|
|
|
714
765
|
OTP_NOT_ACTIVE
|
|
715
766
|
}
|
|
716
767
|
|
|
768
|
+
type DisablePersonResponse {
|
|
769
|
+
ok: Boolean!
|
|
770
|
+
error: DisablePersonError
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
type DisablePersonError {
|
|
774
|
+
code: DisablePersonErrorCode!
|
|
775
|
+
developerMessage: String!
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
enum DisablePersonErrorCode {
|
|
779
|
+
PERSON_ALREADY_DISABLED
|
|
780
|
+
PERSON_NOT_FOUND
|
|
781
|
+
}
|
|
782
|
+
|
|
717
783
|
# === mails ===
|
|
718
784
|
|
|
719
785
|
input MailTemplate {
|
|
@@ -859,20 +925,30 @@ const schema: DocumentNode = gql`
|
|
|
859
925
|
|
|
860
926
|
type SetProjectSecretResponse {
|
|
861
927
|
ok: Boolean!
|
|
862
|
-
|
|
928
|
+
error: SetProjectSecretError
|
|
863
929
|
}
|
|
864
930
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
931
|
+
type SetProjectSecretError {
|
|
932
|
+
code: SetProjectSecretErrorCode!
|
|
933
|
+
developerMessage: String!
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
enum SetProjectSecretErrorCode {
|
|
937
|
+
PROJECT_NOT_FOUND
|
|
938
|
+
}
|
|
872
939
|
|
|
873
940
|
type UpdateProjectResponse {
|
|
874
941
|
ok: Boolean!
|
|
875
|
-
|
|
942
|
+
error: UpdateProjectError
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
type UpdateProjectError {
|
|
946
|
+
code: UpdateProjectErrorCode!
|
|
947
|
+
developerMessage: String!
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
enum UpdateProjectErrorCode {
|
|
951
|
+
PROJECT_NOT_FOUND
|
|
876
952
|
}
|
|
877
953
|
`
|
|
878
954
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { testTenantDb } from '../../../src/testTenantDb'
|
|
2
|
+
import { GQL } from '../../../src/tags'
|
|
3
|
+
import { assert, test } from 'vitest'
|
|
4
|
+
import { signUpMutation } from '../mocked/gql/signUp'
|
|
5
|
+
import { TenantRole } from '../../../../src'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
test('manage global roles', testTenantDb(async ({ tester }) => {
|
|
9
|
+
const result = await tester.execute(
|
|
10
|
+
signUpMutation({
|
|
11
|
+
email: 'john@doe.com',
|
|
12
|
+
password: 'abcdxy',
|
|
13
|
+
}),
|
|
14
|
+
{
|
|
15
|
+
roles: [TenantRole.SUPER_ADMIN],
|
|
16
|
+
},
|
|
17
|
+
)
|
|
18
|
+
assert.isOk(result.data.signUp.ok)
|
|
19
|
+
const identity = result.data.signUp.result.person.identity.id
|
|
20
|
+
assert.deepStrictEqual(result.data.signUp.result.person.identity.roles, [TenantRole.PERSON])
|
|
21
|
+
|
|
22
|
+
const resultAddRole = await tester.execute(GQL`
|
|
23
|
+
mutation {
|
|
24
|
+
addGlobalIdentityRoles(identityId: "${identity}", roles: ["project_admin", "super_admin"]) {
|
|
25
|
+
ok
|
|
26
|
+
result {
|
|
27
|
+
identity {
|
|
28
|
+
roles
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`, {
|
|
34
|
+
roles: [TenantRole.SUPER_ADMIN],
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
assert.deepStrictEqual(resultAddRole.data, {
|
|
38
|
+
addGlobalIdentityRoles: {
|
|
39
|
+
ok: true,
|
|
40
|
+
result: {
|
|
41
|
+
identity: {
|
|
42
|
+
roles: [TenantRole.PERSON, TenantRole.PROJECT_ADMIN, TenantRole.SUPER_ADMIN],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const resultRemoveRole = await tester.execute(GQL`
|
|
50
|
+
mutation {
|
|
51
|
+
removeGlobalIdentityRoles(identityId: "${identity}", roles: ["project_admin", "super_admin"]) {
|
|
52
|
+
ok
|
|
53
|
+
result {
|
|
54
|
+
identity {
|
|
55
|
+
roles
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`, {
|
|
61
|
+
roles: [TenantRole.SUPER_ADMIN],
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
assert.deepStrictEqual(resultRemoveRole.data, {
|
|
65
|
+
removeGlobalIdentityRoles: {
|
|
66
|
+
ok: true,
|
|
67
|
+
result: {
|
|
68
|
+
identity: {
|
|
69
|
+
roles: [TenantRole.PERSON],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
}))
|
|
@@ -81,6 +81,40 @@ test('signs in', async () => {
|
|
|
81
81
|
})
|
|
82
82
|
})
|
|
83
83
|
|
|
84
|
+
test('signs in - normalize email', async () => {
|
|
85
|
+
const email = 'John@doe.com '
|
|
86
|
+
const password = '123'
|
|
87
|
+
const identityId = testUuid(2)
|
|
88
|
+
const personId = testUuid(7)
|
|
89
|
+
const projectId = testUuid(10)
|
|
90
|
+
const apiKeyId = testUuid(1)
|
|
91
|
+
await executeTenantTest({
|
|
92
|
+
query: signInMutation({ email, password }),
|
|
93
|
+
executes: [
|
|
94
|
+
getPersonByEmailSql({ email, response: null }),
|
|
95
|
+
getPersonByEmailSql({ email: 'john@doe.com', response: { personId, identityId, password, roles: [] } }),
|
|
96
|
+
createSessionKeySql({ apiKeyId: apiKeyId, identityId: identityId }),
|
|
97
|
+
getIdentityProjectsSql({ identityId: identityId, projectId: projectId }),
|
|
98
|
+
selectMembershipsSql({
|
|
99
|
+
identityId: identityId,
|
|
100
|
+
projectId,
|
|
101
|
+
membershipsResponse: [{ role: 'editor', variables: [{ name: 'locale', values: ['cs'] }] }],
|
|
102
|
+
}),
|
|
103
|
+
],
|
|
104
|
+
return: {
|
|
105
|
+
data: {
|
|
106
|
+
signIn: {
|
|
107
|
+
ok: true,
|
|
108
|
+
errors: [],
|
|
109
|
+
result: {
|
|
110
|
+
token: '0000000000000000000000000000000000000000',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
|
|
84
118
|
test('sign in - invalid password', async () => {
|
|
85
119
|
const email = 'john@doe.com'
|
|
86
120
|
const password = '123'
|
|
@@ -93,7 +127,7 @@ test('sign in - invalid password', async () => {
|
|
|
93
127
|
data: {
|
|
94
128
|
signIn: {
|
|
95
129
|
ok: false,
|
|
96
|
-
errors: [{ code:
|
|
130
|
+
errors: [{ code: 'INVALID_PASSWORD' }],
|
|
97
131
|
result: null,
|
|
98
132
|
},
|
|
99
133
|
},
|
|
@@ -115,7 +149,7 @@ test('otp token not provided', async () => {
|
|
|
115
149
|
data: {
|
|
116
150
|
signIn: {
|
|
117
151
|
ok: false,
|
|
118
|
-
errors: [{ code:
|
|
152
|
+
errors: [{ code: 'OTP_REQUIRED' }],
|
|
119
153
|
result: null,
|
|
120
154
|
},
|
|
121
155
|
},
|
|
@@ -144,7 +178,7 @@ test('sign in - invalid otp token', async () => {
|
|
|
144
178
|
data: {
|
|
145
179
|
signIn: {
|
|
146
180
|
ok: false,
|
|
147
|
-
errors: [{ code:
|
|
181
|
+
errors: [{ code: 'INVALID_OTP_TOKEN' }],
|
|
148
182
|
result: null,
|
|
149
183
|
},
|
|
150
184
|
},
|
|
@@ -4,9 +4,12 @@ import { GQL, SQL } from '../../../src/tags'
|
|
|
4
4
|
import { disableApiKey } from './sql/disableApiKeySql'
|
|
5
5
|
import { getPersonByIdentity } from './sql/getPersonByIdentity'
|
|
6
6
|
import { test } from 'vitest'
|
|
7
|
+
import { getApiKeySql } from './sql/getApiKeySql'
|
|
8
|
+
import { ApiKey } from '../../../../src'
|
|
7
9
|
|
|
8
10
|
test('sign out', async () => {
|
|
9
11
|
const personId = testUuid(1)
|
|
12
|
+
|
|
10
13
|
await executeTenantTest({
|
|
11
14
|
query: GQL`mutation {
|
|
12
15
|
signOut {
|
|
@@ -23,6 +26,10 @@ test('sign out', async () => {
|
|
|
23
26
|
email: 'john@doe.com',
|
|
24
27
|
},
|
|
25
28
|
}),
|
|
29
|
+
getApiKeySql({
|
|
30
|
+
apiKeyId: authenticatedApiKeyId,
|
|
31
|
+
response: { personId: personId, identityId: authenticatedIdentityId, apiKeyType: ApiKey.Type.SESSION },
|
|
32
|
+
}),
|
|
26
33
|
disableApiKey({ id: authenticatedApiKeyId }),
|
|
27
34
|
],
|
|
28
35
|
return: {
|
|
@@ -38,6 +45,7 @@ test('sign out', async () => {
|
|
|
38
45
|
test('sign out all', async () => {
|
|
39
46
|
const identityId = authenticatedIdentityId
|
|
40
47
|
const personId = testUuid(1)
|
|
48
|
+
|
|
41
49
|
await executeTenantTest({
|
|
42
50
|
query: GQL`mutation {
|
|
43
51
|
signOut(all: true) {
|
|
@@ -54,6 +62,10 @@ test('sign out all', async () => {
|
|
|
54
62
|
roles: [],
|
|
55
63
|
},
|
|
56
64
|
}),
|
|
65
|
+
getApiKeySql({
|
|
66
|
+
apiKeyId: authenticatedApiKeyId,
|
|
67
|
+
response: { personId: personId, identityId: authenticatedIdentityId, apiKeyType: ApiKey.Type.SESSION },
|
|
68
|
+
}),
|
|
57
69
|
{
|
|
58
70
|
sql: SQL`update "tenant"."api_key" set "disabled_at" = ? where "identity_id" = ?`,
|
|
59
71
|
parameters: [(val: any) => val instanceof Date, identityId],
|
|
@@ -70,6 +82,52 @@ test('sign out all', async () => {
|
|
|
70
82
|
})
|
|
71
83
|
})
|
|
72
84
|
|
|
85
|
+
test('sign out - permanent api key', async () => {
|
|
86
|
+
const identityId = authenticatedIdentityId
|
|
87
|
+
const personId = testUuid(1)
|
|
88
|
+
|
|
89
|
+
await executeTenantTest({
|
|
90
|
+
query: GQL`mutation {
|
|
91
|
+
signOut(all: true) {
|
|
92
|
+
ok,
|
|
93
|
+
error {
|
|
94
|
+
code
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}`,
|
|
98
|
+
executes: [
|
|
99
|
+
getPersonByIdentity({
|
|
100
|
+
identityId,
|
|
101
|
+
response: {
|
|
102
|
+
password: '',
|
|
103
|
+
personId: personId,
|
|
104
|
+
email: 'john@doe.com',
|
|
105
|
+
roles: [],
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
getApiKeySql({
|
|
109
|
+
apiKeyId: authenticatedApiKeyId,
|
|
110
|
+
response: { personId: personId, identityId: authenticatedIdentityId, apiKeyType: ApiKey.Type.PERMANENT },
|
|
111
|
+
}),
|
|
112
|
+
{
|
|
113
|
+
sql: SQL`update "tenant"."api_key" set "disabled_at" = ? where "identity_id" = ?`,
|
|
114
|
+
parameters: [(val: any) => val instanceof Date, identityId],
|
|
115
|
+
response: { rowCount: 1 },
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
return: {
|
|
119
|
+
data: {
|
|
120
|
+
signOut: {
|
|
121
|
+
ok: false,
|
|
122
|
+
error: {
|
|
123
|
+
code: 'NOT_POSSIBLE_SIGN_OUT_WITH_PERMANENT_API_KEY',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
73
131
|
test('sign out - not a person', async () => {
|
|
74
132
|
await executeTenantTest({
|
|
75
133
|
query: GQL`mutation {
|
|
@@ -24,6 +24,11 @@ test('signs up a new user', async () => {
|
|
|
24
24
|
createPersonSql({ personId, email, password, identityId }),
|
|
25
25
|
),
|
|
26
26
|
disableOneOffKeySql({ id: testUuid(998) }),
|
|
27
|
+
{
|
|
28
|
+
sql: SQL`select "id", "description", "roles" from "tenant"."identity" where "id" in (?)`,
|
|
29
|
+
parameters: [testUuid(1)],
|
|
30
|
+
response: { rows: [{ id: testUuid(1), description: '', roles: ['person'] }] },
|
|
31
|
+
},
|
|
27
32
|
{
|
|
28
33
|
sql: SQL`select
|
|
29
34
|
"project"."id",
|
|
@@ -44,6 +49,10 @@ test('signs up a new user', async () => {
|
|
|
44
49
|
result: {
|
|
45
50
|
person: {
|
|
46
51
|
id: personId,
|
|
52
|
+
identity: {
|
|
53
|
+
id: identityId,
|
|
54
|
+
roles: ['person'],
|
|
55
|
+
},
|
|
47
56
|
},
|
|
48
57
|
},
|
|
49
58
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SQL } from '../../../../src/tags'
|
|
2
|
+
import { ExpectedQuery } from '@contember/database-tester'
|
|
3
|
+
import { ApiKey } from '../../../../../src'
|
|
4
|
+
|
|
5
|
+
export const getApiKeySql = (args: {
|
|
6
|
+
apiKeyId: string
|
|
7
|
+
response: { identityId: string; personId: string; apiKeyType: ApiKey.Type }
|
|
8
|
+
}): ExpectedQuery => ({
|
|
9
|
+
sql: SQL
|
|
10
|
+
`select "api_key"."id", "api_key"."type", "api_key"."identity_id", "api_key"."disabled_at", "api_key"."expires_at", "identity"."roles", "api_key"."expiration", "person"."id" as "person_id"
|
|
11
|
+
from "tenant"."api_key"
|
|
12
|
+
inner join "tenant"."identity" as "identity" on "api_key"."identity_id" = "identity"."id"
|
|
13
|
+
left join "tenant"."person" as "person" on "person"."identity_id" = "identity"."id"
|
|
14
|
+
where "api_key"."id" = ?
|
|
15
|
+
`,
|
|
16
|
+
parameters: [args.apiKeyId],
|
|
17
|
+
response: {
|
|
18
|
+
rows: args.response
|
|
19
|
+
? [
|
|
20
|
+
{
|
|
21
|
+
id: args.apiKeyId,
|
|
22
|
+
type: args.response.apiKeyType,
|
|
23
|
+
identity_id: args.response.identityId,
|
|
24
|
+
disabled_at: null,
|
|
25
|
+
expires_at: null,
|
|
26
|
+
expiration: null,
|
|
27
|
+
roles: [],
|
|
28
|
+
person_id: args.response.personId,
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
: [],
|
|
32
|
+
},
|
|
33
|
+
})
|
|
@@ -5,7 +5,7 @@ export const getPersonByEmailSql = (args: {
|
|
|
5
5
|
email: string
|
|
6
6
|
response: null | { personId: string; password: string; identityId: string; roles: string[]; otpUri?: string }
|
|
7
7
|
}): ExpectedQuery => ({
|
|
8
|
-
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "identity"."roles"
|
|
8
|
+
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "person"."disabled_at", "identity"."roles"
|
|
9
9
|
FROM "tenant"."person"
|
|
10
10
|
INNER JOIN "tenant"."identity" AS "identity" ON "identity"."id" = "person"."identity_id"
|
|
11
11
|
WHERE "person"."email" = ?`,
|
|
@@ -21,6 +21,7 @@ export const getPersonByEmailSql = (args: {
|
|
|
21
21
|
email: args.email,
|
|
22
22
|
otp_uri: args.response.otpUri,
|
|
23
23
|
otp_activated_at: args.response.otpUri ? new Date() : null,
|
|
24
|
+
disabled_at: null,
|
|
24
25
|
},
|
|
25
26
|
]
|
|
26
27
|
: [],
|
|
@@ -5,7 +5,7 @@ export const getPersonByIdSql = (args: {
|
|
|
5
5
|
personId: string
|
|
6
6
|
response: { personId: string; password: string; identityId: string; roles: string[]; email: string }
|
|
7
7
|
}): ExpectedQuery => ({
|
|
8
|
-
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "identity"."roles"
|
|
8
|
+
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "person"."disabled_at", "identity"."roles"
|
|
9
9
|
FROM "tenant"."person"
|
|
10
10
|
INNER JOIN "tenant"."identity" AS "identity" ON "identity"."id" = "person"."identity_id"
|
|
11
11
|
WHERE "person"."id" = ?`,
|
|
@@ -5,7 +5,7 @@ export const getPersonByIdentity = (args: {
|
|
|
5
5
|
identityId: string
|
|
6
6
|
response: null | { personId: string; password: string; roles: string[]; email: string; otpUri?: string }
|
|
7
7
|
}): ExpectedQuery => ({
|
|
8
|
-
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "identity"."roles"
|
|
8
|
+
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "person"."disabled_at", "identity"."roles"
|
|
9
9
|
FROM "tenant"."person"
|
|
10
10
|
INNER JOIN "tenant"."identity" AS "identity" ON "identity"."id" = "person"."identity_id"
|
|
11
11
|
WHERE "person"."identity_id" = ?`,
|
|
@@ -6,7 +6,7 @@ export const getPersonByIdpSql = (args: {
|
|
|
6
6
|
externalIdentifier: string
|
|
7
7
|
response: null | { personId: string; password?: string; identityId: string; email: string; roles: string[]; otpUri?: string }
|
|
8
8
|
}): ExpectedQuery => ({
|
|
9
|
-
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "identity"."roles"
|
|
9
|
+
sql: SQL`SELECT "person"."id", "person"."password_hash", "person"."otp_uri", "person"."otp_activated_at", "person"."identity_id", "person"."email", "person"."name", "person"."disabled_at", "identity"."roles"
|
|
10
10
|
FROM "tenant"."person"
|
|
11
11
|
INNER JOIN "tenant"."identity" AS "identity" ON "identity"."id" = "person"."identity_id"
|
|
12
12
|
INNER JOIN "tenant"."person_identity_provider" as "idp" on "idp"."person_id" = "person"."id"
|
|
@@ -24,6 +24,7 @@ export const getPersonByIdpSql = (args: {
|
|
|
24
24
|
email: args.response.email,
|
|
25
25
|
otp_uri: args.response.otpUri,
|
|
26
26
|
otp_activated_at: args.response.otpUri ? new Date() : null,
|
|
27
|
+
disabled_at: null,
|
|
27
28
|
},
|
|
28
29
|
]
|
|
29
30
|
: [],
|
|
@@ -11,6 +11,7 @@ const aclSchemaAdminCanManageEditorWithMatchingVariables: Acl.Schema = {
|
|
|
11
11
|
entities: {},
|
|
12
12
|
variables: {},
|
|
13
13
|
tenant: {
|
|
14
|
+
invite: true,
|
|
14
15
|
manage: {
|
|
15
16
|
editor: {
|
|
16
17
|
variables: { site: 'site' },
|
|
@@ -41,3 +42,38 @@ test('admin cannot assign editor role with different variable', async () => {
|
|
|
41
42
|
const node = new AclSchemaAccessNodeFactory().create(aclSchemaAdminCanManageEditorWithMatchingVariables, adminOfSiteA)
|
|
42
43
|
assert.notOk(await node.isAllowed(aclEvaluator, PermissionActions.PROJECT_ADD_MEMBER(editorOfSiteB)))
|
|
43
44
|
})
|
|
45
|
+
|
|
46
|
+
test('admin can invite editor role with matching variable', async () => {
|
|
47
|
+
const node = new AclSchemaAccessNodeFactory().create(aclSchemaAdminCanManageEditorWithMatchingVariables, adminOfSiteA)
|
|
48
|
+
|
|
49
|
+
assert.ok(await node.isAllowed(aclEvaluator, PermissionActions.PERSON_INVITE(editorOfSiteA)))
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const aclSchemaForInviteOnly: Acl.Schema = {
|
|
54
|
+
roles: {
|
|
55
|
+
admin: {
|
|
56
|
+
entities: {},
|
|
57
|
+
variables: {},
|
|
58
|
+
tenant: {
|
|
59
|
+
invite: {
|
|
60
|
+
public: true,
|
|
61
|
+
},
|
|
62
|
+
manage: {
|
|
63
|
+
lorem: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
test('admin can invite public. cannat manage public, cannot invite lorem', async () => {
|
|
72
|
+
const node = new AclSchemaAccessNodeFactory().create(aclSchemaForInviteOnly, [{ role: 'admin', variables: [] }])
|
|
73
|
+
|
|
74
|
+
assert.ok(await node.isAllowed(aclEvaluator, PermissionActions.PERSON_INVITE([{ role: 'public', variables: [] }])))
|
|
75
|
+
|
|
76
|
+
assert.notOk(await node.isAllowed(aclEvaluator, PermissionActions.PERSON_INVITE([{ role: 'lorem', variables: [] }])))
|
|
77
|
+
|
|
78
|
+
assert.notOk(await node.isAllowed(aclEvaluator, PermissionActions.PROJECT_REMOVE_MEMBER([{ role: 'public', variables: [] }])))
|
|
79
|
+
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DatabaseQueryable, DatabaseQuery } from '@contember/database';
|
|
2
|
-
import { ApiKey } from '../../type';
|
|
3
|
-
declare class ApiKeyByTokenQuery extends DatabaseQuery<ApiKeyByTokenQuery.Result> {
|
|
4
|
-
private readonly token;
|
|
5
|
-
constructor(token: string);
|
|
6
|
-
fetch({ db }: DatabaseQueryable): Promise<ApiKeyByTokenQuery.Result>;
|
|
7
|
-
}
|
|
8
|
-
declare namespace ApiKeyByTokenQuery {
|
|
9
|
-
type Result = null | Row;
|
|
10
|
-
type Row = {
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly type: ApiKey.Type;
|
|
13
|
-
readonly identity_id: string;
|
|
14
|
-
readonly disabled_at: Date | null;
|
|
15
|
-
readonly expires_at: Date | null;
|
|
16
|
-
readonly expiration: number | null;
|
|
17
|
-
readonly roles: string[];
|
|
18
|
-
readonly person_id: string | null;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export { ApiKeyByTokenQuery };
|
|
22
|
-
//# sourceMappingURL=ApiKeyByTokenQuery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiKeyByTokenQuery.d.ts","sourceRoot":"","sources":["../../../../../src/model/queries/apiKey/ApiKeyByTokenQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAA2B,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGnC,cAAM,kBAAmB,SAAQ,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAIpC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC;CAuB1E;AAED,kBAAU,kBAAkB,CAAC;IAC5B,KAAY,MAAM,GAAG,IAAI,GAAG,GAAG,CAAA;IAC/B,KAAY,GAAG,GAAG;QACjB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAA;QAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;QAC5B,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAA;QACjC,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;QAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;QAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAA;QACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KACjC,CAAA;CACD;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
|