adorsys / keycloak-config-cli

Import YAML/JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak.
Apache License 2.0
703 stars 129 forks source link

Importing custom user profile config won´t work #979

Open cuberinooo opened 5 months ago

cuberinooo commented 5 months ago

Current Behavior

This is the config that I want to import:

realm: some realm
components:
      org.keycloak.userprofile.UserProfileProvider:
      - providerId: declarative-user-profile
        subComponents: {}
        config:
          kc.user.profile.config:
          - '{"attributes":[{"name":"foo","displayName":"bar","validations":{"length":{"max":255},"person-name-prohibited-characters":{}},"required":{"roles":["user"]},"permissions":{"view":["admin","user"],"edit":["admin","user"]}}'

I got no errors on importing the config. The yaml is valid. What I get is the default settings for user profile. No "foo" attribute is added

User profile is enabled and I can see it on the UI (btw. using this property: declarative_user_profile)

Expected Behavior

Custom Attribute "foo" (see example above) is imported.

Steps To Reproduce

No response

Environment

Anything else?

Btw. I use the latest Bitnami Keycloak 18.0.2 (which is keycloak 23.0.4)

EDIT: I also tried it with Bitnami Keycloak 18.1.0

imscaradh commented 1 month ago

Is there an update for this issue? We are currently experiencing exactly the same behavior with Keycloak 24.0.3

Guite commented 1 week ago

I also have trouble with this problem. Please fix this asap.

thomasdarimont commented 1 week ago

The user profile can be imported via the dedicated userProfile attribute:

The following works for me with Keycloak 24.0.5, however the latest keycloak-config-cli (6.0.2) seems to have some issues with this version, see: #1067.

realm: up-demo
enabled: true
displayName: "UP Demo"

attributes:
  userProfileEnabled: true

userProfile:
  attributes:
    - name: username
      displayName: "${username}"
      validations:
        length:
          min: 3
          max: 255
    - name: email
      displayName: "${email}"
      validations:
        length:
          max: 255
    - name: firstName
      displayName: "${firstName}"
      required:
        roles:
          - user
      permissions:
        view:
          - admin
          - user
        edit:
          - admin
          - user
      validations:
        length:
          max: 255
    - name: lastName
      displayName: "${lastName}"
      required:
        roles:
          - user
      permissions:
        view:
          - admin
          - user
        edit:
          - admin
          - user
      validations:
        length:
          max: 255
    - name: phoneNumber
      displayName: "${phoneNumber}"
      annotations:
        inputType: "html5-tel"
      validations:
        length:
          min: 6
          max: 64
      required:
        roles:
          - user
        scopes:
          - "phone"
      selector:
        scopes: [ "phone" ]
      permissions:
        view:
          - user
          - admin
        edit:
          - user
          - admin

image

Guite commented 1 week ago

Thank you very much @thomasdarimont - I was not aware of that dedicated attribute.