2

I d like to use Keycloak as Security Provider for my wildfly swarm based app. There is only one resource that needs "public access" (/api/systemInfo)... all the other resources should be protected by Keycloak. If I add this to a web.xml (within src/main/WEB-INF), the web.xml looks as below:

<web-app>
<module-name>amigo</module-name>
<security-constraint>
    <web-resource-collection>
        <url-pattern>/api/systemInfo</url-pattern>
    </web-resource-collection>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>KEYCLOAK</auth-method>
    <realm-name>amigo</realm-name>
</login-config>

Like that, everything works as expected. I can access only /api/systemInfo without login.

But since all my configuration is within default-stages.yml (and the environment depending yml files) I would love to have the security constraints there as well. My default-stages.yml looks like below:

swarm:
  context:
    path: /
  deployment:
    app.war:
      web:
        login-config:
          auth-method: KEYCLOAK
        security-constraints:
          - url-pattern: /api/systemInfo
          - url-pattern: /*
            roles: [admin]

In my opinion this should behave like the first snippet (web.xml). But it doesnt. It seems like the rule for (/api/systemInfo) is ignored or at least it doesnt work as expected. On /api/systemInfo I get a 403, while on all other requests I get the expected redirect to Keycloak Login.

Does somebody have a idea what I need to adjust to get the same behaviour as using web.xml?

Thanks a lot for your help.

mooonli
  • 2,355
  • 4
  • 23
  • 32
  • Hmm, that sounds like it might be a bug. Could you raise an issue at https://issues.jboss.org/browse/SWARM as the two should definitely behave the same. Would be great if you could provide an example project as well – Ken Jan 08 '18 at 18:38
  • Hi Ken Thx for getting back to me. I just raised a Issue as described by you. Lets see what we get there. https://issues.jboss.org/browse/SWARM-1774 – mooonli Jan 09 '18 at 06:20
  • Should be solved with Thorntail Version 2.0.0.Final – McIntosh Jul 04 '18 at 08:12

0 Answers0