I am failing to get GeoServer to use groups from LDAP as roles as described on https://docs.geoserver.org/stable/en/user/security/tutorials/ldap/index.html#map-ldap-groups-to-geoserver-roles
Running GeoServer 2.24.2 on openjdk 11.0.19 2023-04-18 LTS using Tomcat 9.0.62-5.el8. A LDAP server is available elsewhere.
If I query the LDAP server via Python, I get a list of 5 groups:
import ldap # python-ldap, https://www.python-ldap.org
connection = ldap.initialize('ldaps://example.com:7636/')
# ignore cert
connection.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
connection.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
connection.simple_bind_s(
'uid=alice,cn=admins,cn=users,dc=foo,dc=bar,dc=baz,dc=com',
'password',
)
result = connection.search_s(
"cn=groups,dc=foo,dc=bar,dc=baz,dc=com",
ldap.SCOPE_SUBTREE,
"(&(objectClass=univentionGroup)(memberUid=alice))",
)
print([r[0] for r in result])
returns
[
'cn=Foo Bar,cn=groups,dc=foo,dc=bar,dc=baz,dc=com',
'cn=group1,cn=login,cn=groups,dc=foo,dc=bar,dc=baz,dc=com',
'cn=something_else,cn=sudo,cn=groups,dc=foo,dc=bar,dc=baz,dc=com',
'cn=yaddayadda,cn=services,cn=groups,dc=foo,dc=bar,dc=baz,dc=com',
'cn=geoserver_global_admins,cn=services,cn=groups,dc=foo,dc=bar,dc=baz,dc=com'
]
The GeoServer configuration is:
- Server URL:
ldaps://example.com:7636/dc=foo,dc=bar,dc=baz,dc=com
- User lookup pattern:
uid={0},cn=admins,cn=users
- Use LDAP groups for authorization: Checked
- Bind user before searching for groups: Checked
- Group search base:
cn=groups,dc=foo,dc=bar,dc=baz,dc=com
- Group search filter:
(&(objectClass=univentionGroup)(memberUid={0}))
Other options are unchecked or empty.
The GeoServer verbose logs show:
26 Feb 14:48:51 DEBUG [security.ldap] - Getting authorities for user uid=alice,cn=admins,cn=users,dc=foo,dc=bar,dc=baz,dc=com
26 Feb 14:48:51 DEBUG [security.ldap] - Searching for roles for user 'foo', DN = 'uid=alice,cn=admins,cn=users,dc=foo,dc=bar,dc=baz,dc=com', with filter (&(objectClass=univentionGroup)(memberUid={0})) in search base 'cn=groups,dc=foo,dc=bar,dc=baz,dc=com'
26 Feb 14:48:51 DEBUG [security.ldap] - Roles from search: []
26 Feb 14:48:51 DEBUG [ldap.LDAPSecurityProvider$1] - Authenticated user
26 Feb 14:48:51 DEBUG [filter.GeoServerUserNamePasswordAuthenticationFilter$1] - Set SecurityContextHolder to UsernamePasswordAuthenticationToken [Principal=LdapUserDetailsImpl [Dn=uid=alice,cn=admins,cn=users,dc=foo,dc=bar,dc=baz,dc=com; Username=alice; Password=[PROTECTED]; Enabled=true; AccountNonExpired=true; CredentialsNonExpired=true; AccountNonLocked=true; Granted Authorities=[]], Credentials=[PROTECTED], Authenticated=true, Details=GeoServerWebAuthenticationDetails [RemoteIpAddress=127.0.0.1, SessionId=...], Granted Authorities=[ROLE_AUTHENTICATED]]
The LDAP query in "Searching for roles for user 'foo'
" seems to match my script exactly.
As I understand GeoServer's role model in combination with LDAP the user should be assigned a ROLE_{GROUPNAME}
role for each of the groups. So e.g. the user should get the role ROLE_GEOSERVER_GLOBAL_ADMINS
.
But GeoServer assigns no roles.
How can I get GeoServer to assign the roles from the LDAP groups?
I have found several hints that this might be a GeoServer bug:
- https://sourceforge.net/p/geoserver/mailman/geoserver-users/thread/[email protected]/
- https://sourceforge.net/p/geoserver/mailman/geoserver-users/thread/SJ0PR08MB6800C0E997D3CBD049D22B8ED71F9%40SJ0PR08MB6800.namprd08.prod.outlook.com
- https://sourceforge.net/p/geoserver/mailman/geoserver-users/thread/[email protected]/
A suggested workaround is using old jar files (gs-sec-ldap-2.15.2.jar
and gs-web-sec-ldap-2.15.2.jar
), this did not work for me.
I cross-posted this to https://sourceforge.net/p/geoserver/mailman/geoserver-users/thread/20240228133315.0EEA6A78BBBB%40dd44930.kasserver.com/ (FYI the threading is broken on that site, so you will need to hunt for further answers via the main interface, sorry)
bob
will be assigned the roleROLE_WORKERS
. The role name is generated by concatenatingROLE_
with the name of the group in upper case."ROLE_GEOSERVER_GLOBAL_ADMINS
at various places in the GeoServer admin panel, but upon user login, still no roles are found/assigned. From my understanding those things are separate? Role service finds groups and provides them as roles for configuration. Authentication logs in and places authenticated user into its roles (via the ldap group names)