Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
authenticator = com.sos.auth.shiro.SOSAuthenticator
securityManager.authenticator=$authenticator
# Please note that you have to assign the realms to the authenticator instead to the securityManager.realms 
authenticator.realms = $iniRealm, $ldapRealm

The SOS authenticator can be used with all three behavior strategies but it only causes the behavior of the First Successful strategy to be modified,

...

  • If the authorization occurs through the ini realm then the user account will only be assigned the roles specified for the ini realm. The LDAP realm(s) will be ignored.
  • If the authorization occurs through an LDAP realm then, regardless of whether or not the same password is used in each realm:
    • The user account will be assigned the role(s) specified for the account in the (first) authorizing realm.
    • The user account will also be assigned the role(s) specified for the account in the ini realm.
      • This behavior ensures that a login is possible in the event of problems with the LDAP realm(s).
    • The order in which the realms are specified in the securityManager.realms parameter is not significant here.
    • The roleAssignmentFromIni=false setting (default true) can be used to modify the behavior of the First Successful strategy so that roles from the ini realm are not assigned. See the Suppressing assignment of the ini Realm section below.

 

Show If
useraa
When the SOS Authenticator is used with the At Least One Successful strategy:
  • ...

When the SOS Authenticator is used with the All Successful strategy:

  • ...
StrategyAuthenticator.........
First Successfulshiro   
First  SuccessfulSOS   
At Least One Successfulshiro/SOS   
All Successfulshiro/SOS   
     

Suppressing assignment of the ini Realm

Display feature availability
StartingFromRelease1.12.4

When the First Successful strategy is used when an ini realm and one or more LDAP realms have accounts with common user names and separate passwords, the roles for the ini realm will be assigned by default when the login is carried out for one of the LDAP realms. This behavior can be suppressed by setting the roleAssignmentFromIni parameter to false for the  LDAP realms in the environment. This is shown in the code example below: 

Suppressing assignment of the ini Realm

Display feature availability
StartingFromRelease1.12.4

When the First Successful strategy is used when an ini Realm and one or more LDAP Realms have accounts with common user names and separate passwords, the roles for the ini Realm will be assigned by default when the login is carried out for one of the LDAP Realms. This behavior can be suppressed by setting the roleAssignmentFromIni property to false for the LDAP Realms in the environment. This is shown in the code example below: 

Code Block
languagexml
titleConfiguration for ini and LDAP Realms
collapsetrue
[users]
newton = $shiro1$SHA-512$500000$wsJJJJ7cbBpoVi0C...JJ5U5pter6Q==,administrator

[main]
publicLdapRealm = com.sos.auth.shiro.SOSLdapAuthorizingRealm
 
publicLdapRealm.userDnTemplate = uid={0},dc=example,dc=com
publicLdapRealm.searchBase = dc=example,dc=com
publicLdapRealm.contextFactory.url = ldap://ldap.forumsys.com:389
 
publicLdapRealm.groupNameAttribute = ou
publicLdapRealm.userNameAttribute = uid
 
publicLdapRealm.rolePermissionResolver = $rolePermissionResolver
publicLdapRealm.userSearchFilter = (uniqueMember=uid=%s
Code Block
languagexml
titleConfiguration for ini and LDAP Realms
collapsetrue
[users]
newton = $shiro1$SHA-512$500000$wsJJJJ7cbBpoVi0C...JJ5U5pter6Q==,administrator

[main]
publicLdapRealm = com.sos.auth.shiro.SOSLdapAuthorizingRealm
 
publicLdapRealm.userDnTemplate = uid={0},dc=example,dc=com)
publicLdapRealm.searchBasegroupRolesMap = dc=example,dc=com
publicLdapRealm.contextFactory.url = ldap://ldap.forumsys.com:389
 
publicLdapRealm.groupNameAttribute = ou
publicLdapRealm.userNameAttribute = uid
 
publicLdapRealm.rolePermissionResolver = $rolePermissionResolver
publicLdapRealm.userSearchFilter = (uniqueMember=uid=%s,dc=example,dc=com)
publicLdapRealm.groupRolesMap = \
  scientists : it_operator, \
  mathematicians: all
publicLdapRealm.roleAssignmentFromIni = false
 
rolePermissionResolver = com.sos.auth.shiro.SOSPermissionResolverAdapter
rolePermissionResolver.ini = $iniRealm
 
authcStrategy = org.apache.shiro.authc.pam.SOSFirstSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
securityManager.realms = $publicLdapRealm, $iniRealm
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager

With the above configuration:

  • When the user name newton is used together with the password for the ini realm then the account will be assigned the administrator role.
  • When the user name newton is used together with the password for the LDAP realm then the account will be assigned the it_operator role.

Realm Group/Role Mappings

Display feature availability
StartingFromRelease1.12.4

Logical selection of realm group strategies can also be implemented. These strategies determine, for example, that an account will only be authenticated for one realm when it can also be authenticated for all the realms in that group.

Configuration

This feature is activated by inserting the following line of code in the [main] section of the Shiro ini file:

  • securityManager.authenticator.authenticationStrategy = $authcStrategy

In addition a logical strategy has to be implemented - the following four strategies are available:

...

\
  scientists : it_operator, \
  mathematicians: all
publicLdapRealm.roleAssignmentFromIni = false
 
rolePermissionResolver = com.sos.auth.shiro.SOSPermissionResolverAdapter
rolePermissionResolver.ini = $iniRealm
 
authcStrategy = org.apache.shiro.authc.pam.SOSFirstSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
securityManager.realms = $publicLdapRealm, $iniRealm
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager

With the above configuration:

  • When the user name newton is used together with the password for the ini realm then the account will be assigned the administrator role.
  • When the user name newton is used together with the password for the LDAP realm then the account will be assigned the it_operator role.

Realm Group/Role Mappings

Display feature availability
StartingFromRelease1.12.4

Use of group strategies can be configured. These strategies determine, for example, that an account will only be authenticated for one realm when it can also be authenticated for all the realms in that group.

Configuration

The group strategy has to be configured - the following four strategies are available:

  • SOSFirstSuccessfulGroupStrategy
  • SOSAllSuccessfulGroupStrategy
  • SOSAllSuccessfulFirstGroupStrategy
  • SOSAtLeastOneSuccessfulGroupStrategy

The strategy to be followed is specified by adding, for example, the following to the [main] section of the Shiro ini file:

  • authcStrategy = com.sos.auth.shiro.SOSFirstSuccessfulGroupStrategy
  • securityManager.authenticator.authenticationStrategy = $authcStrategy

For the grouping of strategies a naming convention has to be followed that includes to separate the group form the Realm name by a hashtag, for example

  • A#Ldap1

Example

The following example uses two Groups "A" and "B", each with two Realms each. Roles "r1" and "r2" are configured per Realm by the groups/roles mapping instruction: 

 

Code Block
titleMulti Group Realms
collapsetrue
[main]
A#Ldap1 = com.sos.auth.shiro.SOSLdapAuthorizingRealm
 
A#Ldap1.userDnTemplate = uid={0},dc=example,dc=com
A#Ldap1.searchBase = dc=example,dc=com
A#Ldap1.contextFactory.url = ldap://ldap.forumsys.com:389
 
A#Ldap1.groupNameAttribute = ou
A#Ldap1.userNameAttribute = uid
 
A#Ldap1.rolePermissionResolver = $rolePermissionResolver
A#Ldap1.userSearchFilter = (uniqueMember=uid=%s

...

The strategy to be followed is specified by adding, for example, the following to the [main] section of the Shiro ini file:

  • authcStrategy = com.sos.auth.shiro.SOSFirstSuccessfulGroupStrategy

Finally all group realms are to be named following the syntax:

  • group#name

Example

The following example uses two Groups, each with two realms. An account with a common User Name and Password is configured for all Realms

A#ldap1
roles = a1

A#ldap2
roles = a2

B#ldap1
roles = b1

B#ldap2
roles = b2

 

Here is an example main section for this szenario

Code Block
titleMulti Group Realms
collapsetrue
[main]
A#Ldap1 = com.sos.auth.shiro.SOSLdapAuthorizingRealm
 
A#Ldap1.userDnTemplate = uid={0},dc=example,dc=com)
A#Ldap1.searchBasegroupRolesMap = dc=example,dc=com
A#Ldap1.contextFactory.url = ldap://ldap.forumsys.com:389
 
A#Ldap1.groupNameAttribute = ou
A#Ldap1.userNameAttribute = uid
 
A#Ldap1.rolePermissionResolver = $rolePermissionResolver
A#Ldap1.userSearchFilter = (uniqueMember=uid=%s,dc=example,dc=com)
A#Ldap1.groupRolesMap = \
  scientists : it_operator, \
  mathematicians: all
A#Ldap1.roleAssignmentFromIni = false
 
A#Ldap2\
  scientists : r1, \
  mathematicians: r2
A#Ldap1.roleAssignmentFromIni = false
 
A#Ldap2 = com.sos.auth.shiro.SOSLdapAuthorizingRealm
...

B#Ldap1 = com.sos.auth.shiro.SOSLdapAuthorizingRealm
...

B#Ldap2 = com.sos.auth.shiro.SOSLdapAuthorizingRealm
...

rolePermissionResolver = com.sos.auth.shiro.SOSLdapAuthorizingRealmSOSPermissionResolverAdapter
...


B#Ldap1rolePermissionResolver.ini = $iniRealm
 
authcStrategy = comorg.apache.sosshiro.authauthc.shiropam.SOSLdapAuthorizingRealmSOSFirstSuccessfulGroupStrategy
securityManager.authenticator..


B#Ldap2authenticationStrategy = com.sos.auth.shiro.SOSLdapAuthorizingRealm
...

rolePermissionResolver = com.sos.auth.shiro.SOSPermissionResolverAdapter
rolePermissionResolver.ini = $iniRealm
 
$authcStrategy
securityManager.realms = $A#Ldap1,$A#Ldap2,$B#Ldap1,$B#Ldap2
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager


Find a number of examples for the behavior with different strategies from the following chapters.

SOSFirstSuccessfulGroupStrategy

Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSFirstSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
Explanation
  • All Realms with the same group will be checked group-wise.
  • In every group there must be one Realm that can be authenticated, otherwise authentication will fail for all groups.
  • The roles from the first Realm per group will be added to the roles the user is assigned.
Authentication Matrix
A#Ldap1A#Ldap2B#Ldap1B#Ldap2Resulting Role Assignments
xxxxA#Ldap1, B#Ldap1
x xxA#Ldap1, B#Ldap1
xx xA#Ldap1, B#Ldap2
xxx A#Ldap1, B#Ldap1
 xxxA#Ldap2, B#Ldap1
xx  fail
x x A#Ldap1, B#Ldap1
x  xA#Ldap1, B#Ldap2
 xx A#Ldap2, B#Ldap1
 x xA#Ldap2, B#Ldap2
  xxfail
x   fail
 x  fail
  x fail
   xfail
    fail


SOSAllSuccessfulGroupStrategy

Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSAllSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
Explanation
  • All realms with the same group will be checked group-wise.
  • In at least one group all Realms must be authenticated.
  • The roles from Realms in groups where all Realms can be authenticated will be merged to the roles the user is assigned.
Authentication Matrix
A#Ldap1A#Ldap2B#Ldap1B#Ldap2Resulting Role Assignments
xxxxA#Ldap1, A#Ldap2, B#Ldap1, B#Ldap2
x xxB#Ldap1, B#Ldap2
xx xA#Ldap1, A#Ldap2
xxx A#Ldap1, A#Ldap2
 xxxB#Ldap1, B#Ldap2
xx  A#Ldap1, A#Ldap2
x x fail
x  xfail
 xx fail
 x xfail
  xxB#Ldap1, B#Ldap2
x   fail
 x  fail
  x fail
   xfail
    fail



SOSAllSuccessfulFirstGroupStrategy

Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSAllSuccessfulFirstGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
Explanation
  • All Realms with the same group will be checked group-wise.
  • In at least one group all Realms must be authenticated.
  • The roles from Realms in the first group where all Realms can be authenticated will be merged with other roles the user is assigned.
Authentication Matrix
A#Ldap1A#Ldap2B#Ldap1B#Ldap2Resulting Role Assignments
xxxxA#Ldap1, A#Ldap2
x xxB#Ldap1, B#Ldap2
xx xA#Ldap1, A#Ldap2
xxx A#Ldap1, A#Ldap2
 xxxB#Ldap1, B#Ldap2
xx  A#Ldap1, A#Ldap2
x x fail
x  xfail
 xx fail
 x xfail
  xxB#Ldap1, B#Ldap2
x   fail
 x  fail
  x fail
   xfail
    fail


SOSAtLeastOneSuccessfulGroupStrategy

Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSFirstSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
 
securityManager.realms = $A#Ldap1,$A#Ldap2,$B#Ldap1,$B#Ldap2
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager

 

 

Example Behavior with Different Strategies

SOSFirstSuccessfulGroupStrategy
Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSFirstSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy

 

All realms with the same group will be checked group-wise.

In every group there must be one realm that can be authenticated.

If none of the realms in at least one group authenticate then authentication will fail for all groups.

The roles from the first realm per group will be merged to the roles the user has.

Example:
  • If A#ldap1, A#ldap2 and B#ldap2 can authenticate than the user will have the roles a1 and b2.
  • If A#ldap2 and B#ldap1 can authenticate than authentication will fail.
SOSAllSuccessfulGroupStrategy
Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSAllSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy

All realms with the same group will be checked group-wise.
In at least one group all realms must be authenticated.
The roles from realms in groups where all realms can be authenticated will be merged to the roles the user has.

Examples:
  • If A#ldap1, A#ldap2 and B#ldap1, B#ldap2 can authenticate than the user will have the roles a1,a2,b1,b2.
  • If A#ldap1, A#ldap2 and B#ldap1 can authenticate than the user will have the roles a1,a2.
  • If A#ldap2 and B#ldap1 can authenticate than authentication will fail.
SOSAllSuccessfulFirstGroupStrategy
Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSAllSuccessfulFirstGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy

All realms with the same group will be checked group-wise.
In at least one group all realms must be authenticated.
The roles from realms in the first group where all realms can be authenticated will be merged with other roles the user may have.

Example:
  • If A#ldap1, and B#ldap1, B#ldap2 can authenticate than the user will have the roles b1,b2
  • If A#ldap1, A#ldap2 and B#ldap2 can authenticate than the user will have the roles a1,a2
  • If A#ldap1 and B#ldap2 can authenticate than authentication will fail.
SOSAtLeastOneSuccessfulGroupStrategy
Code Block
authcStrategy = org.apache.shiro.authc.pam.SOSAtLeastOneSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy

All realms with the same group will be checked group-wise.
At least one realm must be authenticate in every group.
The roles from realms that have authenticated will be merged with other roles the user may have.

Example:

...

.pam.SOSAtLeastOneSuccessfulGroupStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
Explanation
  • All Realms with the same group will be checked group-wise.
  • At least one Realm must be authenticated in every group.
  • The roles from Realms that have been authenticated will be merged with other roles the user is assigned.
Authentication Matrix
A#Ldap1A#Ldap2B#Ldap1B#Ldap2Resulting Role Assignments
xxxxA#Ldap1, A#Ldap2, B#Ldap1, B#Ldap2
x xxA#Ldap1, B#Ldap1, B#Ldap2
xx xA#Ldap1, A#Ldap2, B#Ldap2
xxx A#Ldap1, A#Ldap2, B#Ldap1
 xxxA#Ldap2, B#Ldap1, B#Ldap2
xx  fail
x x A#Ldap1, B#Ldap1
x  xA#Ldap1, B#Ldap2
 xx A#Ldap2, B#Ldap1
 x xA#Ldap2, B#Ldap2
  xxfail
x   fail
 x  fail
  x fail
   xfail
    fail

 

...