Wildfly Swarm Speci...
Notifications
Clear all

Wildfly Swarm Specific configuration of the Keycloak Backend environment

RSS

(@ganesh)
Noble Member
Joined: 2 years ago
Posts: 1362
15/05/2021 11:12 am

This is a JavaEE application on wildfly that used keycloak as auth backend. This was configured in project-stages.yml:

swarm: deployment: my.app.war: web: login-config: auth-method: KEYCLOAK

The application will be implemented in different environments using a Gitlab-CD-Pipeline. Therefore, keycloak must be configured per environment.

For now, the only work configuration I found is adding a keycloak.json like (the same file in each environment):

{ "realm": "helsinki", "bearer-only": true, "auth-server-url": "http://localhost:8180/auth", "ssl-required": "external", "resource": "backend" }

According to the Wildfly-Swarm Documentation it should be possible to configure keycloak in project-stages.yml like:

swarm: keycloak: secure-deployments: my-deployment: realm: keycloakrealmname bearer-only: true ssl-required: external resource: keycloakresource auth-server-url: http://localhost:8180/auth

But when I deploy the application, no configuration is read:

2018-03-08 06:29:03,540 DEBUG [org.keycloak.adapters.undertow.KeycloakServletExtension] (ServerService Thread Pool -- 12) KeycloakServletException initialization 2018-03-08 06:29:03,540 DEBUG [org.keycloak.adapters.undertow.KeycloakServletExtension] (ServerService Thread Pool -- 12) using /WEB-INF/keycloak.json 2018-03-08 06:29:03,542 WARN [org.keycloak.adapters.undertow.KeycloakServletExtension] (ServerService Thread Pool -- 12) No adapter configuration. Keycloak is unconfigured and will deny all requests. 2018-03-08 06:29:03,545 DEBUG [org.keycloak.adapters.undertow.KeycloakServletExtension] (ServerService Thread Pool -- 12) Keycloak is using a per-deployment configuration.

In thesource of the above class, it seems like the only way to get around is to provide a KeycloakConfigResolver. Does Wildfly-Swarm provide a resolver that reads the project-stages.yml?

How can I configure environment-specific auth-server-urls?

or does it have a different workaround for keycloak.json-Files. I would rather use the project-stages.yml.


Quote
(@sathish)
Member Moderator
Joined: 2 years ago
Posts: 1391
15/05/2021 11:14 am

I worked on a swarm project which configures keycloak exclusively via project-defaults.yml:https://github.com/Ladicek/swarm-test-suite/tree/master/wildfly/keycloak

The only thing I see wrong is:

swarm: keycloak: secure-deployments: my-deployment:

Your my-deployment name should be the actual deployment name. Same as you have here:

swarm: deployment: my.app.war:

If this is your current config, then I'll have to make a guess.


ReplyQuote
Share:
Baidu