Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-2518

getUserPrincipal and KeycloakSecurityContext returns NULL using Tomcat, Jetty, and JBoss EAP

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.8.0.Final, 1.8.1.Final, 1.9.0.CR1
    • Fix Version/s: 1.9.1.Final
    • Component/s: Adapter - JEE
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      The code below returns NULL when called from /movies/, and works when called from /article/
      (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());
      (KeycloakPrincipal) req.getUserPrincipal()

      In my web.xml I have only one security-constraint securing /article/*

      WEB.XML:
      <security-constraint>
      <web-resource-collection>
      <web-resource-name>Articles</web-resource-name>
      <url-pattern>/article/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
      <role-name>user</role-name>
      </auth-constraint>
      </security-constraint>

      Show
      The code below returns NULL when called from /movies/, and works when called from /article/ (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName()); (KeycloakPrincipal) req.getUserPrincipal() In my web.xml I have only one security-constraint securing /article/* WEB.XML: <security-constraint> <web-resource-collection> <web-resource-name>Articles</web-resource-name> <url-pattern>/article/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>user</role-name> </auth-constraint> </security-constraint>

      Description

      When I'm logged in and I go to a restricted URL, KeycloakSecurityContext returns NULL.
      I tested this when the application is deployed to Tomcat or Jboss EAP.
      The same application deployed to Wildfly works fine.

        Attachments

          Activity

            People

            Assignee:
            bill.burke Bill Burke (Inactive)
            Reporter:
            leonardonunes Leonardo Nunes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: