FFFF User attributes with a text more than 255 characters · Issue #9758 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

User attributes with a text more than 255 characters #9758

Closed

Description

@moolsbytheway

Description

we need to have user attributes with a text more than 255 characters.

Discussion

No response

Motivation

we want to have user attributes with a text more than 255 characters.

Details

Implementation:
when creating user attributes, the value field is limited to 255 characters, we want to remove this limitation by changing the type of the field "value" in the table "user_attribute" from varchar(255) to TEXT.

Activity

  1. meden commented on Feb 2, 2022

    @meden
  2. meden commented on Mar 29, 2022

    @meden

    Here another valid use case. In this case this issue breaks an officially supported broker integration.

  3. iudex- commented on Apr 8, 2022

    @iudex-

    I'm running into the exact same issue as linked above.

    Nothing crazy, just trying to store the link to the profile image as a user attribute:
    image
    image

    We are not asking for 10k chars in a user attribute, but storing a link should surely be possible, no?


    Edit:
    I'm not sure if I didn't create even bigger issues for the future, but I altered the data type of the table. (Using the build in h2 database and the normal keycloak docker image)

    Getting a sql shell

    cd /opt/jboss/keycloak
    java -cp ./modules/system/layers/base/com/h2database/h2/main/h2-*.jar org.h2.tools.Shell -url "jdbc:h2:./standalone/data/keycloak;AUTO_SERVER=TRUE" -user sa -password sa
    

    to run this sql command (docs):

    ALTER TABLE user_attribute ALTER COLUMN value SET DATA TYPE NVARCHAR(1000);
    

    and check on it:

    SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='USER_ATTRIBUTE';
    
  4. myalcinkuru commented on Sep 5, 2022

    @myalcinkuru

    We also faced with same issue while importing LDAP users. Keycloak writes LDAP_ENTRY_DN to user attributes by default. Thus, value might exist the 255 chars and import fails.

  5. mhuin commented on Sep 12, 2022

    @mhuin

    To expand on @iudex- 's answer, if using mysql as a backend the workaround requires an extra step to recreate an index:

    alter table USER_ATTRIBUTE drop index IDX_USER_ATTRIBUTE_NAME; 
    alter table USER_ATTRIBUTE modify VALUE TEXT(100000) CHARACTER SET utf8 COLLATE utf8_general_ci;
    alter table USER_ATTRIBUTE ADD KEY `IDX_USER_ATTRIBUTE_NAME` (`NAME`, VALUE(400));
    

    In this example I set the max size of the chunk of text to 100K characters (equivalent to mediumtext type); note that in order to ease indexing only the 400 first characters will be used to build the index. Adapt these values as seems sensible in your use cases.

  6. Iodun commented on Nov 2, 2022

    @Iodun

    I am using "openssh-lpk" schema on my OpenLDAP to store the users SSH public keys. With the 255 character limit its impossible to map this into Keycloak. That is yet another very simple and legitimate use case which needs the character limit to be increased or removed.

  7. kapalex commented on Feb 6, 2023

    @kapalex

    In case anyone needs the postgres variant for the same solution provided by @mhuin -

    DROP INDEX idx_user_attribute_name; 
    ALTER TABLE user_attribute ALTER COLUMN value SET DATA TYPE VARCHAR(10000);
    CREATE INDEX idx_user_attribute_name ON user_attribute (name, left(value, 1000));
    

    Removes the index, changes the type to 10k characters and creates an index on the first 1k characters of the value.

    Hoping this can be officially supported in the future by keycloak.

  8. vramik commented on Feb 6, 2023

    @vramik
    Contributor

    Capability to store long attribute values will be supported in new store. There is no plan to add support to legacy store regarding it.

  9. hmlnarik commented on Feb 6, 2023

    @hmlnarik
    Contributor

    Duplicate of https://issues.redhat.com/browse/KEYCLOAK-9515. Thank you for your requirement. As @vramik mentioned above, this will only be addressed in the new store.

  10. zhengyang1988 commented on Jun 14, 2023

    @zhengyang1988

    I found the following solution for this problem on stackoverflow:

    https://stackoverflow.com/questions/44851052/max-size-of-custom-user-attribute-in-keycloak#:~:text=Keycloak%27s%20attribute%20values%20maximum%20length,the%20field%20type%20to%20text%20.

    Is it good to solve the problem this way? Since this requires modify the data type of a database field, will it cause any trouble in the future? (I've already tested that this change won't cause any problem for the automatic db migration from 18.0.2 to 21.1.1 by runing keycloak 21.1.1 directly on the database after making this db column datatype change)

  11. ahus1 commented on Aug 3, 2023

    @ahus1
    Member

    As the new store hasn't arrived yet, re-opening it for evaluating it.

    We're investigating if the column can be enlarged; still it wouldn't hold unlimited amount of text.

  12. 14 remaining items

  13. added a commit that references this issue on Feb 8, 2024
    ac15402
  14. added a commit that references this issue on Feb 16, 2024
    7645355
  15. moved this from 👀 In Progress to ✅ Done in Storageon Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/storageStorage layer — JPA entities, database schemas, Liquibase migrations, cachingkind/enhancementCategorizes a PR related to an enhancementrelease/24.0.0team/core-iam

Type

No type

Fields

No fields configured for issues without a type.

Projects

  • Status
    ✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

0