File tree Expand file tree Collapse file tree 4 files changed +12
-1
lines changed
src/main/java/info/unterrainer/commons/httpserver Expand file tree Collapse file tree 4 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1717
1818 <modelVersion >4.0.0</modelVersion >
1919 <artifactId >http-server</artifactId >
20- <version >0.2.6 </version >
20+ <version >0.2.7 </version >
2121 <name >HttpServer</name >
2222 <packaging >jar</packaging >
2323
Original file line number Diff line number Diff line change @@ -168,6 +168,9 @@ private TokenVerifier<AccessToken> persistUserInfoInContext(final Context ctx) {
168168 ctx .attribute (Attribute .USER_EMAIL_VERIFIED , token .getEmailVerified ());
169169 ctx .attribute (Attribute .USER_REALM_ROLES , token .getRealmAccess ().getRoles ());
170170
171+ String tenant = (String ) token .getOtherClaims ().get ("tenant" );
172+ ctx .attribute (Attribute .USER_CLIENT_ATTRIBUTE_TENANT , tenant );
173+
171174 Set <String > clientRoles = Set .of ();
172175 String key = token .getIssuedFor ();
173176 if (token .getResourceAccess ().containsKey (key ))
@@ -185,6 +188,7 @@ private TokenVerifier<AccessToken> persistUserInfoInContext(final Context ctx) {
185188 .email (token .getEmail ())
186189 .emailVerified (token .getEmailVerified ())
187190 .realmRoles (token .getRealmAccess ().getRoles ())
191+ .tenant (tenant )
188192 .clientRoles (clientRoles )
189193 .isActive (token .isActive ())
190194 .isBearer (token .getType ().equalsIgnoreCase ("bearer" ))
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public class Attribute {
1515 public static final String USER_CLIENT = "user_client" ;
1616 public static final String USER_CLIENT_ROLES = "user_client_roles" ;
1717 public static final String USER_REALM_ROLES = "user_realm_roles" ;
18+ public static final String USER_CLIENT_ATTRIBUTE_TENANT = "user_client_attribute_tenant" ;
1819
1920 public static final String KEYCLOAK_TOKEN_REJECTION_REASON = "kc_token_rejection_reason" ;
2021}
Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ public class UserDataJson {
2222
2323 private Set <String > realmRoles ;
2424 private Set <String > clientRoles ;
25+ /**
26+ * Is the custom Keycloak-attribute 'tenant' that has to be set under
27+ * user/attributes within Keycloak and then mapped using an AttributeMapper
28+ * within Keycloak as well. Is a comma-separated list of tenant-IDs.
29+ */
30+ private String tenant ;
2531
2632 private boolean isActive ;
2733 private boolean isBearer ;
You can’t perform that action at this time.
0 commit comments