Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set the default role for EJB methods in JBoss 7?
    primarykey
    data
    text
    <p>I have an EAR with multiple EJB JARs which shall be secured by using a very simple authentication mechanisms: Every EJB method shall be accessible by every user as long as he/she is authenticated. So I have secured the EAR file by adding the <code>security-domain</code> to the <code>jboss-app.xml</code> file into the EAR:</p> <pre><code>&lt;jboss-app&gt; &lt;security-domain&gt;my-security-domain&lt;/security-domain&gt; &lt;/jboss-app&gt; </code></pre> <p>Users are authenticated with ths JBoss default <code>users.properties</code> file. In JBoss 4.2.3 this just worked fine. Now in JBoss 7 I get an authorization exception:</p> <pre><code>16:45:32,791 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 2) JBAS014134: EJB Invocation failed on component MyServiceBean for method public abstract java.util.List mypackage.MyService.findAllFoo(): javax.ejb.EJBAccessException: JBAS014502: Invocation on method: public abstract java.util.List mypackage.MyService.findAllFoo() of bean: MyServiceBean is not allowed </code></pre> <p>After setting the logger category for <code>org.jboss.security</code> to <code>TRACE</code> I found out, that JBoss 7 obviously expects a default <code>&lt;NOBODY&gt;</code> role on every EJB method, when no explicit role is specified otherwise. From the logs:</p> <pre><code>16:45:32,791 TRACE [org.jboss.security.audit] (EJB default - 2) [Failure]Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;Action=authorization;Exception:=PBOX000017: Acces denied: authorization failed ;Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=null}:method=public abstract java.util.List mypackage.MyService.findAllFoo():ejbMethodInterface=Remote:ejbName=MyServiceBean:ejbPrincipal=rschneider:MethodRoles=Roles(&lt;NOBODY&gt;,):securityRoleReferences=null:callerSubject=Betreff: Principal: org.jboss.remoting3.security.UserPrincipal@ce844325 Principal: Roles(members:user) Principal: CallerPrincipal(members:org.jboss.remoting3.security.UserPrincipal@ce844325) :callerRunAs=null:callerRunAs=null:ejbRestrictionEnforcement=false:ejbVersion=2.0];policyRegistration=null; </code></pre> <p>Then I tried to configure a role-mapping into JBoss, so that every user is mapped to this <code>&lt;NOBODY&gt;</code> role:</p> <pre><code>&lt;security-domain name="my-security-domain" cache-type="default"&gt; &lt;authentication&gt; &lt;login-module code="Remoting" flag="optional"&gt; &lt;module-option name="password-stacking" value="useFirstPass"/&gt; &lt;/login-module&gt; &lt;login-module code="RealmDirect" flag="required"&gt; &lt;module-option name="password-stacking" value="useFirstPass"/&gt; &lt;/login-module&gt; &lt;login-module code="RoleMapping" flag="optional"&gt; &lt;module-option name="rolesProperties" value="${jboss.server.config.dir}/rolesMapping-roles.properties"/&gt; &lt;/login-module&gt; &lt;/authentication&gt; &lt;/security-domain&gt; </code></pre> <p>Content of the <code>rolesMapping-roles.properties</code> file:</p> <pre><code>user=user,&lt;NOBODY&gt; </code></pre> <p>This works, but I am very uneasy about this solution. So, is there a way to tell JBoss 7 to use a default role for every EJB method, e.g. <code>user</code>? I really do not want to annotate every bean with a <code>@RolesAllowed("user")</code>...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload