Skip to content

Commit

Permalink
Merge pull request #37 from brunotot/hotfix-keycloak-dao-client-id-app
Browse files Browse the repository at this point in the history
chore: hotfix
  • Loading branch information
brunotot authored Nov 26, 2024
2 parents f51621a + 8fe1d50 commit 2c44f7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/app-node-express/src/lib/keycloak/KeycloakDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { env } from "@/server/env";
export class KeycloakDao {
private readonly TOKEN_MANAGER: KeycloakTokenManager;
private readonly ADMIN_API_URL: string;

public static readonly KC_CLIENT_ID = "9943a0fd-de66-4247-a7b8-c0a94a70b393";
private readonly KC_CLIENT_ID: string;

protected ROLES: Record<string, string>;

constructor() {
const { KEYCLOAK_URL, KEYCLOAK_REALM } = env;
this.TOKEN_MANAGER = new KeycloakTokenManager();
this.ADMIN_API_URL = `${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}`;
this.KC_CLIENT_ID = env.KEYCLOAK_APP_CLIENT_ID;
this.initRoles();
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export class KeycloakDao {

private async initRoles() {
const res = await this.get<{ id: string; name: string }[]>(
`/clients/${KeycloakDao.KC_CLIENT_ID}/roles`,
`/clients/${this.KC_CLIENT_ID}/roles`,
);
this.ROLES = res.reduce(
(acc, role) => {
Expand Down
2 changes: 2 additions & 0 deletions apps/app-node-express/src/server/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ const ENVIRONMENT_VARS = z.object({
*/
KEYCLOAK_TOKEN_ENDPOINT: z.string().default("/token").transform(Transform.URL),

KEYCLOAK_APP_CLIENT_ID: z.string(),

/**
* Allowed origins for CORS requests.
* @default "*"
Expand Down

0 comments on commit 2c44f7c

Please sign in to comment.