Wildfly 25 and configuration of Elytron Token Realm

979 views
Skip to first unread message

Domenico Briganti

unread,
Oct 27, 2021, 9:38:04 AM10/27/21
to WildFly

Hi all!

 I've migrated a simple application from Wildfly 23 to 25. I used keycloak adapter to validate the calling bearer token and now I switched to the new Elytron module that suppport OIDC.

The application wokrs, but now I want to make the configuration more flexible. I use this CLI script to configure Elytron (inspirated from https://github.com/wildfly/quickstart/tree/main/jaxrs-jwt):

batch

# Add a new token security realm to elytron for authentication using JWTs
/subsystem=elytron/token-realm=jwt-realm:add(jwt={issuer=[${env.OIDC_ISSUER}],principal-claim="sub",key-map={${env.OIDC_KID}=${env.OIDC_PUBLIC_KEY}}})

# Add a new security domain, which uses the jwt security realm
/subsystem=elytron/security-domain=jwt-domain:add(realms=[{realm=jwt-realm,role-decoder=groups-to-roles}],permission-mapper=default-permission-mapper,default-realm=jwt-realm)

# Create http authentication factory that uses BEARER_TOKEN authentication
/subsystem=elytron/http-authentication-factory=jwt-http-authentication:add(security-domain=jwt-domain,http-server-mechanism-factory=global,mechanism-configurations=[{mechanism-name="BEARER_TOKEN",mechanism-realm-configurations=[{realm-name="jwt-realm"}]}])

# Configure Undertow to use our http authentication factory for authentication
/subsystem=undertow/application-security-domain=other:remove()
/subsystem=undertow/application-security-domain=other:add(http-authentication-factory=jwt-http-authentication)

/subsystem=ejb3/application-security-domain=other:write-attribute(name=security-domain,value=jwt-domain)

run-batch

And now the problem. I can't set the KID parameter as expression. Debugging with Eclipse I see (in /org.wildfly.core.wildfly-controller/src/main/java/org/jboss/as/controller/AbstractAddStepHandler.java):


In the KEY-MAP there isn't no "expression" before "${env.OIDC_KID:}", and I do not understand why.

Following the debugging I see the expression resolved, but not KID:


Have you any suggestion?


Regards,

Domenico




Diana Krepinska

unread,
Nov 12, 2021, 6:43:36 AM11/12/21
to WildFly
Hello, it is not currently possible to specify expression for KID keys, you can create a WFCORE or ELY issue for it if you'd like. But if you are using new OIDC subsystem, you wouldn't use it in combination with the token realm, buecase the OIDC subsystem is using dynamically created security domain. So there is no security realm or security domain configuration in the OIDC subsystem, it is created dynamically in runtime for you, see  virtual security here https://docs.wildfly.org/25/Admin_Guide.html#virtual-security-2 .

Martin Carney

unread,
Nov 12, 2021, 11:55:13 AM11/12/21
to WildFly
Well that certainly explains why I'm having trouble getting my OIDC client to use any of the realm or domain configuration details - it's not meant to.
Reply all
Reply to author
Forward
0 new messages