Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let user username be updated in config #810

Open
ehsantashkhisi opened this issue Nov 10, 2022 · 1 comment · May be fixed by #1204
Open

Let user username be updated in config #810

ehsantashkhisi opened this issue Nov 10, 2022 · 1 comment · May be fixed by #1204
Assignees

Comments

@ehsantashkhisi
Copy link

ehsantashkhisi commented Nov 10, 2022

Problem Statement

Imagine we want to apply the user configuration like below:

users:

- username: $(env:ADMIN_PANEL_USER)
  enabled: true
  firstName: firstname
  lastName: Admin
  realmRoles: []
  clientRoles:
    client-realm:
      - manage-users
      - view-realm
      - view-clients
      - view-users
      - view-events
      - manage-realm
  credentials:
    - type: password
      value: $(env:ADMIN_PANEL_USER_PASSWORD)
      userLabel: initial

I want to let the username be configurable and be applied and updated by the configuration, but when the username is changed on the second run it creates another user. is there any way to associate this user to an id so that the username can be updated by configuration?

Proposed Solution

No response

Environment

  • Keycloak Version: [e.g. 19.0.3]
  • keycloak-config-cli Version: [e.g. 5.3.1-19.0.1]
  • Java Version: [e.g. 11]

Additional information

No response

Acceptance Criteria

No response

@Thendo20
Copy link
Collaborator

Thendo20 commented Dec 9, 2024

A fix has been added for this issue, where the user is searched using their email address as well. This ensures an existing user can still be found even when the username is changed. The user's username will be updated as long as editUsernameAllowed is set to true in the configuration.

Here is an example of how it can be set in the configuration:

{
"enabled": true,
"realm": "realmWithUsers",
"registrationEmailAsUsername": false,
"editUsernameAllowed": true,
"users": [
{
"username": "john123",
"email": "[email protected]",
"enabled": true,
"firstName": "My firstname",
"lastName": "My lastname"
}
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants