File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 11from abc import ABC , abstractmethod
22from copy import deepcopy
3+ import json
34
45
56class Dataclass (ABC ):
@@ -56,7 +57,17 @@ def get_access_token_lifespan(self) -> int:
5657 return self ._d ["accessTokenLifespan" ]
5758
5859 def get_unmanaged_attribute_policy (self ) -> str | None :
59- return self ._d ["attributes" ].get ("unmanagedAttributePolicy" )
60+ try :
61+ attribute_config = json .loads (
62+ self ._d ["components" ]
63+ .get ("org.keycloak.userprofile.UserProfileProvider" )[0 ]
64+ .get ("config" )
65+ .get ("kc.user.profile.config" )[0 ]
66+ )
67+ except TypeError : # Will be thrown if the UserProfileProvider wasn't found
68+ return None
69+ # Default value in Keycloak 26+ is "DISABLED", which will sometimes be omitted from the config file
70+ return attribute_config .get ("unmanagedAttributePolicy" , "DISABLED" )
6071
6172 def has_declarative_user_profiles_enabled_legacy_option (self ) -> bool :
6273 return self ._d ["attributes" ].get ("userProfileEnabled" , "false" ) == "true"
You can’t perform that action at this time.
0 commit comments