Repository navigation
feat: add role-based authorization - #84
Merged
Merged
Conversation
# Conflicts: # apps/node/ts-to-openapi.json # docs/architecture/node-env-variables.mdx # package-lock.json # packages/node-core/locales/en.json # packages/node-core/package.json # packages/node-core/src/builders/engineEnvBuilder.ts # packages/node-core/src/builders/engineServerEnvBuilder.ts # packages/node-core/src/commands/bootstrapDev.ts # packages/node-core/src/commands/userCreate.ts # packages/node-core/src/commands/userGet.ts # packages/node-core/src/commands/userUpdate.ts # packages/node-core/src/defaults.ts # packages/node-core/src/models/IEngineEnvironmentVariables.ts # packages/node-core/src/models/engineEnvironmentVariableKeys.ts # packages/node-core/src/start.ts # packages/node-core/tests/builders/engineServerEnvBuilder.spec.ts # packages/node-core/tests/builders/helper/envHelpers.spec.ts # packages/node-core/tests/cli.spec.ts # packages/node-core/tests/endpoints.spec.ts # packages/node-core/tests/endpoints/groups/global-admin-unauthorized.json # packages/node-core/tests/index.spec.ts # packages/node-core/tests/migration.spec.ts # packages/node-core/tests/startup.spec.ts # packages/node-core/tests/systemMetrics.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Adds role-based authorization to the node and makes it a required component. User scopes are replaced by authorization roles, default RBAC policies are seeded from the REST route declarations on every startup, and existing users are migrated from scopes to roles. Nodes now fail to start with
node.migrationAuthorizationComponentunless an authorization connector is configured.🔄 Type of Change
🛠️ Changes Made
configureAuthorizationtoengineEnvBuilder, registering the entity storage or Casbin authorization connector and the authorization service, and throwing whenTWIN_AUTHORIZATION_CONNECTORis not setTWIN_AUTHORIZATION_*andTWIN_CASBIN_*environment variables, includingTWIN_AUTHORIZATION_MODELandTWIN_AUTHORIZATION_MODEL_MODE(mergeorreplace) for supplying a custom authorization modelseedAuthorizationDefaults, which runs after startup and derives policies and role inheritances from each route'sdefaultAuthorization, falling back touser:readanduser:writeby HTTP verb, across all tenants in multi-tenant modedefaults.ts:global-admin,tenant-admin,user-admin,identity-admin,identity-profile-admin,devopsanduser, withglobal-admininheriting every role and every other role inheritinguserAuthorizationREST and socket route processors whenever authorization is configured, withTenantOverridenow added only in multi-tenant modescopeproperty onAuthenticationUserinto authorization role assignments--scopeoption with--roleson theuser-createanduser-updatecommands, and changeduser-get,org-users-listandbootstrap-devto read roles from the authorization componentTWIN_ADMIN_USER_SCOPEwithTWIN_ADMIN_USER_ROLESforbootstrap-devand the soak harnessauthorizationModelIdandescalatedPrivilegeRole, and the obsoleteTWIN_IDENTITY_PROFILE_ADMIN_SCOPESvariable has been removedTWIN_WEB_SERVER_TYPE(fastify,honoornative) andTWIN_AUTH_MIN_PASSWORD_LENGTH/TWIN_AUTH_MAX_PASSWORD_LENGTH.env.example-*files and removed stale onesauthorization-defaults.mdxarchitecture article with role hierarchy and permission diagrams, and updatednode-env-variables.mdx@3sixty/authorization-modelsdependency and removed unused dependencies fromnode-coreandnode🧪 Testing