EJB Security Fails when app deployed in EAR format (but ok in WAR format)
karlnicholas Jan 29, 2017 12:31 PMI cannot get EJB security to work when deploying as an EAR. It works on the same server when deployed as a WEB.
Code when deployed as a WAR . Using a Database authentication configuration. At this point in the logs the code is calling the "merge" function in a @Stateless bean.
2017-01-29 09:14:49,708 DEBUG [org.jboss.security] (default task-11) PBOX00291: Method: merge, interface: Local, required roles: Roles(USER,)
2017-01-29 09:14:49,708 TRACE [org.jboss.security.audit] (default task-11) [Success]Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=null}:method=public model.User service.UserSessionBean.merge(model.User):ejbMethodInterface=Local:ejbName=UserSessionBean:ejbPrincipal=org.wildfly.extension.undertow.security.AccountImpl$AccountPrincipal@bdaf3b8d:MethodRoles=Roles(USER,):securityRoleReferences=null:callerSubject=Subject:
Principal: XXXXXXXX@outlook.com
Principal: Roles(members:USER)
Principal: CallerPrincipal(members:XXXXXXX@outlook.com)
:callerRunAs=null:callerRunAs=null:ejbRestrictionEnforcement=false:ejbVersion=2.0];Action=authorization;Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;policyRegistration=null;
2017-01-29 09:14:49,721 TRACE [org.jboss.security] (default task-11) PBOX00354: Setting security roles ThreadLocal: null
2017-01-29 09:14:49,732 TRACE [org.jboss.security] (default task-11) PBOX00354: Setting security roles ThreadLocal: null
2017-01-29 09:14:53,489 TRACE [org.jboss.security] (default task-12) PBOX00200: Begin isValid, principal: org.wildfly.extension.undertow.security.AccountImpl$AccountPrincipal@bdaf3b8d, cache entry: org.jboss.security.authentication.JBossCachedAuthenticationManager$DomainInfo@57ee7d60
This code is deployed as an EAR. if I call something annotated with @PermitAll then it's allowed, but when annotationed with @RolesAllowed("USER") then I get this failure.
2017-01-29 08:50:11,797 DEBUG [org.jboss.security] (default task-12) PBOX00291: Method: merge, interface: Local, required roles: Roles(USER,)
2017-01-29 08:50:11,797 DEBUG [org.jboss.security] (default task-12) PBOX00292: Insufficient method permissions [principal: org.wildfly.extension.undertow.security.AccountImpl$AccountPrincipal@7d289613, EJB name: UserService, method: merge, interface: Local, required roles: Roles(USER,), principal roles: Roles(**,), run-as roles: null]
2017-01-29 08:50:11,798 DEBUG [org.jboss.security] (default task-12) PBOX00299: Required module org.jboss.security.authorization.modules.DelegatingAuthorizationModule failed
2017-01-29 08:50:11,798 DEBUG [org.jboss.security] (default task-12) PBOX00325: Authorization processing error: org.jboss.security.authorization.AuthorizationException: PBOX00017: Acces denied: authorization failed
at org.jboss.security.plugins.authorization.JBossAuthorizationContext.invokeAuthorize(JBossAuthorizationContext.java:274)