Skip to content

Commit e081975

Browse files
authored
Merge pull request #409 from openwallet-foundation-labs/fix/roles
fix: optimize role handling
2 parents 127d78c + 2de9c32 commit e081975

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

apps/backend/src/auth/client/adapters/keycloak-clients.service.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InjectRepository } from "@nestjs/typeorm";
66
import { decodeJwt } from "jose";
77
import { Repository } from "typeorm";
88
import { ConfigImportOrchestratorService } from "../../../shared/utils/config-import/config-import-orchestrator.service";
9-
import { Role } from "../../roles/role.enum";
9+
import { allRoles, Role } from "../../roles/role.enum";
1010
import { ClientsProvider } from "../client.provider";
1111
import { CreateClientDto } from "../dto/create-client.dto";
1212
import { UpdateClientDto } from "../dto/update-client.dto";
@@ -66,14 +66,7 @@ export class KeycloakClientsProvider
6666
* Checks if all the roles are available in the realm. If not they will be created.
6767
*/
6868
private init() {
69-
const existingRoles: Role[] = [
70-
Role.Tenants,
71-
Role.Tenants,
72-
Role.IssuanceOffer,
73-
Role.Issuances,
74-
Role.PresentationOffer,
75-
Role.Presentations,
76-
];
69+
const existingRoles: Role[] = allRoles;
7770
return this.kc.roles
7871
.find()
7972
.then((roles) => {

apps/backend/src/auth/roles/role.enum.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Enumeration of all roles available in the system.
3+
*/
14
export enum Role {
25
//to manage presentation resources
36
Presentations = "presentation:manage",
@@ -14,3 +17,16 @@ export enum Role {
1417
// to manage registrar configuration and operations
1518
Registrar = "registrar:manage",
1619
}
20+
21+
/**
22+
* List of all roles
23+
*/
24+
export const allRoles = [
25+
Role.Tenants,
26+
Role.IssuanceOffer,
27+
Role.Issuances,
28+
Role.PresentationOffer,
29+
Role.Presentations,
30+
Role.Clients,
31+
Role.Registrar,
32+
];

0 commit comments

Comments
 (0)