I'm trying to understand how the EJB security works on a WebLogic server.
I have an EJB with following configuration in ejb-jar.xml
<session>
<ejb-name>BeanA</ejb-name>
....
<security-identity>
<run-as>
<role-name>beanA_users</role-name>
</run-as>
</security-identity>
</session>
<assembly-descriptor>
<security-role>
<role-name>beanA_users</role-name>
</security-role>
<container-transaction>
<method>
<ejb-name>BeanA</ejb-name>
<method-name>*</method-name>
</method>
</container-transaction>
</assembly-descriptor>
and in weblogic-ejb-jar.xml:
<security-role-assignment>
<role-name>beanA_users</role-name>
<principal-name>runas_a</principal-name>
</security-role-assignment>
<run-as-role-assignment>
<role-name>beanA_users</role-name>
<run-as-principal-name>runas_a</run-as-principal-name>
</run-as-role-assignment>
I interpret it like this: BeanA runs as beanA_users. "runas_a" is one of beanA_users. Therefore, BeanA runs as runas_a user. Also, all users that are in the beanA_users role are permitted to call all the BeanA methods. In other words, Bean_A is running as runas_a, and only runas_a can call its methods. Is this correct?
However, when I call this EJB from another EJB that has the below configuration I'm able to get through. Shouldn't Bean A configure a permission for the principal assigned to BeanB_users role in the BeanB?
ejb-jar.xml:
<session>
<ejb-name>BeanB</ejb-name>
...
<security-identity>
<run-as>
<role-name>beanB_users</role-name>
</run-as>
</security-identity>
</session>
weblogic-ejb-jar.xml:
<run-as-role-assignment>
<role-name>beanB_users</role-name>
<run-as-principal-name>runas_b</run-as-principal-name>
</run-as-role-assignment>
Edit:
After reading the ejb-jar.xml schema it looks like the Bean A in this example does not define any permissions in the <assembly-descriptor>
element. It only defines the security role. I presume this is why any EJB can call its methods. But why does it define a security role assignment in that case? For instance, if BeanA had the following within the element, would it in that case block BeanB from getting through since the permission does not include the runas_b principal?
<method-permission>
<role-name>beanA_users</role-name>
<method>
<ejb-name>BeanA</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>