-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b6e0fc
commit 0f81254
Showing
83 changed files
with
138 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
health-enabled=true | ||
metrics-enabled=true | ||
|
||
# database | ||
db-pool-min-size=5 | ||
db-pool-max-size=20 | ||
|
||
# theme | ||
spi-theme-static-max-age=2592000 | ||
spi-theme-cache-themes=true | ||
spi-theme-cache-templates=true | ||
|
||
# logging | ||
log=console,file | ||
log-console-color=false | ||
log-file=/var/log/eap/${HOSTNAME}.log | ||
|
||
# root-logger-level:INFO | ||
log-level=info,com.arjuna:warn,io.jaegertracing.Configuration:warn,org.jboss.as.config:debug,org.keycloak.events:debug,sun.rmi:warn | ||
log-console-output=json | ||
log-file-output=json | ||
|
||
# SPIs | ||
spi-login-protocol-openid-connect-legacy-logout-redirect-uri=true | ||
|
||
# cache | ||
cache=ispn | ||
# DNS_PING is particularly useful in environments like Kubernetes and Red Hat OpenShift where UDP multicast, a different cluster discovery method, might not be available. This is because DNS is a standard service that's always available, making DNS_PING a reliable way for Infinispan nodes to discover each other. | ||
# The below option requires passing -Djgroups.dns.query=sso-keycloak-ping.<NAMESPACE>.svc.cluster.local to start command | ||
cache-stack=kubernetes | ||
#cache-config-file=cache-ispn-custom.xml | ||
|
||
# tls | ||
# https-key-store-file=server.keystore | ||
# https-key-store-password=password | ||
|
||
proxy-headers=forwarded|xforwarded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
quarkus.log.console.json.exception-output-type=formatted | ||
quarkus.log.console.json.key-overrides=timestamp=@timestamp | ||
quarkus.log.console.json.additional-field."@version".value=1 | ||
quarkus.log.file.json.exception-output-type=formatted | ||
quarkus.log.file.json.key-overrides=timestamp=@timestamp | ||
quarkus.log.file.json.additional-field."@version".value=1 | ||
quarkus.log.file.rotation.file-suffix=.yyyy-MM-dd | ||
# Optional: Disable rotation by size (adjust value as needed) | ||
quarkus.log.handler.file.rotation.max-file-size="10000M" | ||
quarkus.log.handler.file.rotation.max-backup-index="100" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,30 @@ | |
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Base64; | ||
|
||
/** @author <a href="mailto:[email protected]">Junmin Ahn</a> */ | ||
public class IDPUserinfoMapper extends AbstractOIDCProtocolMapper | ||
implements OIDCAccessTokenMapper, OIDCIDTokenMapper, UserInfoTokenMapper { | ||
|
||
private static final Logger logger = Logger.getLogger(IDPUserinfoMapper.class); | ||
|
||
private static final List<ProviderConfigProperty> configProperties = new ArrayList<>(); | ||
private static final String BEARER = "Bearer"; | ||
|
||
private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>(); | ||
|
||
public static final String CLAIM_VALUE = "claim.value"; | ||
|
||
public static final String USER_ATTRIBUTE = "userAttribute"; | ||
|
||
public static final String DECODE_USERINFO_RESPONSE = "decodeUserInfoResponse"; | ||
|
||
static { | ||
configProperties.add(new ProviderConfigProperty(DECODE_USERINFO_RESPONSE, "Decode UserInfo Response", | ||
"Decode response returned from IDP userinfo endpoint", ProviderConfigProperty.BOOLEAN_TYPE, false)); | ||
configProperties.add(new ProviderConfigProperty(USER_ATTRIBUTE, "User Attribute", | ||
"User Attribute returned from IDP userinfo endpoint", ProviderConfigProperty.STRING_TYPE, null)); | ||
|
||
OIDCAttributeMapperHelper.addTokenClaimNameConfig(configProperties); | ||
OIDCAttributeMapperHelper.addIncludeInTokensConfig(configProperties, IDPUserinfoMapper.class); | ||
} | ||
|
@@ -74,6 +86,17 @@ private static JsonNode parseJson(String json) { | |
} | ||
} | ||
|
||
private static String decodeUserInfoResponse(String token) { | ||
try { | ||
String[] tokenParts = token.split("\\."); | ||
Base64.Decoder decoder = Base64.getUrlDecoder(); | ||
String payload = new String(decoder.decode(tokenParts[1])); | ||
return payload; | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
protected void setClaim( | ||
IDToken token, | ||
|
@@ -91,22 +114,34 @@ protected void setClaim( | |
String userInfoUrl = identityProviderModel.getConfig().get("userInfoUrl"); | ||
|
||
if (userInfoUrl != null) { | ||
FederatedIdentityModel identity = | ||
keycloakSession.users().getFederatedIdentity(realm, userSession.getUser(), idp); | ||
FederatedIdentityModel identity = keycloakSession.users().getFederatedIdentity(realm, userSession.getUser(), | ||
idp); | ||
String brokerToken = identity.getToken(); | ||
AccessTokenResponse brokerAccessToken = parseTokenString(brokerToken); | ||
Client httpClient = ClientBuilder.newClient(); | ||
String userinfoString = | ||
httpClient | ||
.target(userInfoUrl) | ||
.request() | ||
.header("Authorization", "Bearer " + brokerAccessToken.getToken()) | ||
.get(String.class); | ||
|
||
JsonNode jsonNode = parseJson(userinfoString); | ||
Map<String, Object> otherClaims = token.getOtherClaims(); | ||
otherClaims.put( | ||
mappingModel.getConfig().get(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME), jsonNode); | ||
String userinfoString = httpClient | ||
.target(userInfoUrl) | ||
.request() | ||
.header("Authorization", "Bearer " + brokerAccessToken.getToken()) | ||
.get(String.class); | ||
boolean decode = Boolean.parseBoolean(mappingModel.getConfig().get(DECODE_USERINFO_RESPONSE)); | ||
if (decode) { | ||
userinfoString = decodeUserInfoResponse(userinfoString); | ||
} | ||
try { | ||
JsonNode jsonNode = parseJson(userinfoString); | ||
if (jsonNode == null) { | ||
logger.error("null response returned from [" + idp + "] userinfo URL"); | ||
} | ||
Map<String, Object> otherClaims = token.getOtherClaims(); | ||
otherClaims.put( | ||
mappingModel.getConfig().get(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME), | ||
jsonNode.get(mappingModel.getConfig().get(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME))); | ||
} catch (NullPointerException e) { | ||
logger.errorf("'%s' returned invalid response", idp); | ||
} catch (Exception e) { | ||
logger.errorf("unable to fetch attributes from userinfo endpoint '%s'", userInfoUrl); | ||
} | ||
} else { | ||
logger.error("Identity Provider [" + idp + "] does not have userinfo URL."); | ||
} | ||
|
@@ -123,8 +158,10 @@ public static ProtocolMapperModel create( | |
mapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL); | ||
Map<String, String> config = new HashMap<>(); | ||
config.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, tokenClaimName); | ||
if (accessToken) config.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true"); | ||
if (idToken) config.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true"); | ||
if (accessToken) | ||
config.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true"); | ||
if (idToken) | ||
config.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true"); | ||
mapper.setConfig(config); | ||
return mapper; | ||
} | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.