permissions changes

This commit is contained in:
amentis 2024-06-03 15:13:57 +03:00
parent e8d26a04e4
commit e487ca8a02
10 changed files with 379 additions and 98 deletions

View File

@ -8,7 +8,7 @@ import java.util.List;
@ConfigurationProperties(prefix = "authorization") @ConfigurationProperties(prefix = "authorization")
public class AuthorizationProperties { public class AuthorizationProperties {
private String globalAdminRole; private List<String> globalAdminRoles;
private String tenantAdminRole; private String tenantAdminRole;
private String globalUserRole; private String globalUserRole;
private String tenantUserRole; private String tenantUserRole;
@ -16,12 +16,12 @@ public class AuthorizationProperties {
private List<String> allowedTenantRoles; private List<String> allowedTenantRoles;
private List<String> allowedGlobalRoles; private List<String> allowedGlobalRoles;
public String getGlobalAdminRole() { public List<String> getGlobalAdminRoles() {
return this.globalAdminRole; return globalAdminRoles;
} }
public void setGlobalAdminRole(String globalAdminRole) { public void setGlobalAdminRoles(List<String> globalAdminRoles) {
this.globalAdminRole = globalAdminRole; this.globalAdminRoles = globalAdminRoles;
} }
public String getTenantAdminRole() { public String getTenantAdminRole() {

View File

@ -165,7 +165,7 @@ public class TenantServiceImpl implements TenantService {
try { try {
this.entityManager.disableTenantFilters(); this.entityManager.disableTenantFilters();
existingItems = this.queryFactory.query(UserRoleQuery.class).disableTracking().tenantIsSet(false).roles(this.authorizationProperties.getGlobalAdminRole()).collect(); existingItems = this.queryFactory.query(UserRoleQuery.class).disableTracking().tenantIsSet(false).roles(this.authorizationProperties.getGlobalAdminRoles()).collect();
userCredentialEntities = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(existingItems.stream().map(UserRoleEntity::getUserId).distinct().toList()).collect(); userCredentialEntities = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(existingItems.stream().map(UserRoleEntity::getUserId).distinct().toList()).collect();
List<String> keycloakIdsToAddToTenantGroup = new ArrayList<>(); List<String> keycloakIdsToAddToTenantGroup = new ArrayList<>();

View File

@ -1,5 +1,7 @@
authorization: authorization:
globalAdminRole: Admin globalAdminRoles:
- Admin
- InstallationAdmin
tenantAdminRole: TenantAdmin tenantAdminRole: TenantAdmin
globalUserRole: User globalUserRole: User
tenantUserRole: TenantUser tenantUserRole: TenantUser
@ -7,8 +9,9 @@ authorization:
allowedTenantRoles: allowedTenantRoles:
- TenantAdmin - TenantAdmin
- TenantUser - TenantUser
- TenantManager - TenantPlanManager
- TenantDescriptionTemplateEditor - TenantConfigManager
allowedGlobalRoles: allowedGlobalRoles:
- Admin - Admin
- InstallationAdmin
- User - User

View File

@ -6,6 +6,8 @@ keycloak-resources:
groupId: a04fd333-f127-449e-8fc2-0626570a3899 groupId: a04fd333-f127-449e-8fc2-0626570a3899
Admin: Admin:
groupId: 299f18fe-e271-4625-a4c1-9c3eb313b2ea groupId: 299f18fe-e271-4625-a4c1-9c3eb313b2ea
InstallationAdmin:
groupId: 88a65fff-dffe-474a-a461-252ff4230203
tenantAuthorities: tenantAuthorities:
TenantAdmin: TenantAdmin:
parent: 1e650f57-8b7c-4f32-bf5b-e1a9147c597b parent: 1e650f57-8b7c-4f32-bf5b-e1a9147c597b
@ -13,9 +15,9 @@ keycloak-resources:
TenantUser: TenantUser:
parent: c7057c4d-e7dc-49ef-aa5d-02ad3a22bff8 parent: c7057c4d-e7dc-49ef-aa5d-02ad3a22bff8
roleAttributeValueStrategy: 'TenantUser:{tenantCode}' roleAttributeValueStrategy: 'TenantUser:{tenantCode}'
TenantManager: TenantConfigManager:
parent: d111bb2f-b4a6-4de7-ad22-5151ee1a508b parent: 09a6977b-719e-4e90-b3fc-3b394d82e05f
roleAttributeValueStrategy: 'TenantManager:{tenantCode}' roleAttributeValueStrategy: 'TenantConfigManager:{tenantCode}'
TenantDescriptionTemplateEditor: TenantPlanManager:
parent: 55cf7b17-c025-4065-8906-49f9f430f038 parent: 37d1fb0e-5e03-47bf-aefc-365c0670f84e
roleAttributeValueStrategy: 'TenantDescriptionTemplateEditor:{tenantCode}' roleAttributeValueStrategy: 'TenantPlanManager:{tenantCode}'

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,11 @@
export enum AppRole { export enum AppRole {
Admin = "Admin", Admin = "Admin",
InstallationAdmin = "InstallationAdmin",
User = "User", User = "User",
TenantAdmin = "TenantAdmin", TenantAdmin = "TenantAdmin",
TenantUser = "TenantUser", TenantUser = "TenantUser",
TenantManager = "TenantManager", // TenantManager = "TenantManager",
TenantDescriptionTemplateEditor = "TenantDescriptionTemplateEditor" // TenantDescriptionTemplateEditor = "TenantDescriptionTemplateEditor"
TenantPlanManager = "TenantPlanManager",
TenantConfigManager = "TenantConfigManager"
} }

View File

@ -58,11 +58,12 @@ export class EnumUtils {
toAppRoleString(status: AppRole): string { toAppRoleString(status: AppRole): string {
switch (status) { switch (status) {
case AppRole.Admin: return this.language.instant('TYPES.APP-ROLE.ADMIN'); case AppRole.Admin: return this.language.instant('TYPES.APP-ROLE.ADMIN');
case AppRole.InstallationAdmin: return this.language.instant('TYPES.APP-ROLE.INSTALLATION-ADMIN');
case AppRole.User: return this.language.instant('TYPES.APP-ROLE.USER'); case AppRole.User: return this.language.instant('TYPES.APP-ROLE.USER');
case AppRole.TenantAdmin: return this.language.instant('TYPES.APP-ROLE.TENANT-ADMIN'); case AppRole.TenantAdmin: return this.language.instant('TYPES.APP-ROLE.TENANT-ADMIN');
case AppRole.TenantUser: return this.language.instant('TYPES.APP-ROLE.TENANT-USER'); case AppRole.TenantUser: return this.language.instant('TYPES.APP-ROLE.TENANT-USER');
case AppRole.TenantManager: return this.language.instant('TYPES.APP-ROLE.TENANT-MANAGER'); case AppRole.TenantPlanManager: return this.language.instant('TYPES.APP-ROLE.TENANT-PLAN-MANAGER');
case AppRole.TenantDescriptionTemplateEditor: return this.language.instant('TYPES.APP-ROLE.TENANT-DESCRIPTION-TEMPLATE-EDITOR'); case AppRole.TenantConfigManager: return this.language.instant('TYPES.APP-ROLE.TENANT-CONFIG-MANAGER');
} }
} }

View File

@ -4,7 +4,7 @@
<div *ngIf="!this.nowEditing"class="roles col-8"> <div *ngIf="!this.nowEditing"class="roles col-8">
<div *ngFor="let role of this.formGroup.get('roles').value" class="row"> <div *ngFor="let role of this.formGroup.get('roles').value" class="row">
<div class="col-auto p-0"> <div class="col-auto p-0">
<span class="user-role" [ngClass]="{'user': role == appRole.User, 'tenant-manager': role == appRole.TenantManager, 'admin': role == appRole.Admin, 'tenant-description-template-editor': role == appRole.TenantDescriptionTemplateEditor, 'tenant-admin': role == appRole.TenantAdmin, 'tenant-user': role == appRole.TenantUser}"> <span class="user-role" [ngClass]="{'user': role == appRole.User, 'tenant-plan-manager': role == appRole.TenantPlanManager, 'admin': role == appRole.Admin, 'installation-admin': role == appRole.InstallationAdmin, 'tenant-config-manager': role == appRole.TenantConfigManager, 'tenant-admin': role == appRole.TenantAdmin, 'tenant-user': role == appRole.TenantUser}">
{{enumUtils.toAppRoleString(role)}} {{enumUtils.toAppRoleString(role)}}
</span> </span>
</div> </div>

View File

@ -49,12 +49,12 @@
padding-right: 10px; padding-right: 10px;
} }
.tenant-manager { .tenant-plan-manager {
// display: flex; // display: flex;
// justify-content: center; // justify-content: center;
// align-items: center; // align-items: center;
min-width: 90px; min-width: 77px;
height: 28px; min-height: 28px;
color: #568b5a; color: #568b5a;
background: #9dd1a1 0% 0% no-repeat padding-box; background: #9dd1a1 0% 0% no-repeat padding-box;
border-radius: 44px; border-radius: 44px;
@ -85,6 +85,24 @@
padding-right: 10px; padding-right: 10px;
} }
.installation-admin {
// display: flex;
// justify-content: center;
// align-items: center;
min-width: 67px;
min-height: 28px;
color: #e75d01;
background: #dbaa4e3a 0% 0% no-repeat padding-box;
border-radius: 44px;
letter-spacing: 0.11px;
font-weight: 400;
opacity: 1;
margin-top: 0.5em;
margin-bottom: 0.5em;
padding-left: 10px;
padding-right: 10px;
}
.tenant-admin { .tenant-admin {
// display: flex; // display: flex;
// justify-content: center; // justify-content: center;
@ -103,7 +121,7 @@
padding-right: 10px; padding-right: 10px;
} }
.tenant-description-template-editor { .tenant-config-manager {
// display: flex; // display: flex;
// justify-content: center; // justify-content: center;
// align-items: center; // align-items: center;

View File

@ -1788,11 +1788,12 @@
}, },
"APP-ROLE": { "APP-ROLE": {
"ADMIN": "Admin", "ADMIN": "Admin",
"INSTALLATION-ADMIN": "Installation Admin",
"USER": "User", "USER": "User",
"TENANT-ADMIN": "Tenant Admin", "TENANT-ADMIN": "Tenant Admin",
"TENANT-USER": "Tenant User", "TENANT-USER": "Tenant User",
"TENANT-MANAGER": "Manager", "TENANT-PLAN-MANAGER": "Tenant Plan Manager",
"TENANT-DESCRIPTION-TEMPLATE-EDITOR": "Description Template Editor" "TENANT-CONFIG-MANAGER": "Tenant Configuration Manager"
}, },
"IS-ACTIVE": { "IS-ACTIVE": {
"ACTIVE": "Active", "ACTIVE": "Active",