Skip to content

Commit

Permalink
fix: username
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurice Faber committed Mar 24, 2022
1 parent 0571c72 commit ec26f40
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/tasks/keycloak/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ProtocolMapperRepresentation } from '@redkubes/keycloak-client-node'
import axios from 'axios'

export const keycloakRealm = 'otomi'
export const adminUserName = 'admin'

export const defaultsIdpMapperTpl = (env: Record<string, unknown>): Array<Record<string, unknown>> => [
{
Expand Down Expand Up @@ -50,8 +49,8 @@ export const idpMapperTpl = (name: string, alias: string, role: string, claim: s
},
})

export const adminUserCfgTpl = (password: string): Record<string, unknown> => ({
username: adminUserName,
export const adminUserCfgTpl = (username: string, password: string): Record<string, unknown> => ({
username,
email: 'admin@oto.mi',
emailVerified: true,
enabled: true,
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/keycloak/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ async function main(): Promise<void> {
}),
)

// Create default user 'admin' in realm 'otomi'
const userConf = createAdminUser(env.KEYCLOAK_ADMIN_PASSWORD)
// Create default admin user in realm 'otomi'
const userConf = createAdminUser(env.KEYCLOAK_ADMIN, env.KEYCLOAK_ADMIN_PASSWORD)
const existingUsersByAdminEmail = (await doApiCall([], `Getting users`, () =>
api.users.realmUsersGet(keycloakRealm, false, userConf.email),
)) as UserRepresentation[]
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/keycloak/realm-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export function createClientEmailClaimMapper(): ProtocolMapperRepresentation {
return emailClaimMapper
}

export function createAdminUser(password: string): UserRepresentation {
const userRepresentation = defaultsDeep(new UserRepresentation(), adminUserCfgTpl(password))
export function createAdminUser(username: string, password: string): UserRepresentation {
const userRepresentation = defaultsDeep(new UserRepresentation(), adminUserCfgTpl(username, password))
return userRepresentation
}

Expand Down

0 comments on commit ec26f40

Please sign in to comment.