Improve ldap sections (#1218)

This commit is contained in:
Firstyear 2022-12-05 06:40:19 +10:00 committed by GitHub
parent 53a017ce57
commit a4f593f0c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,17 +1,17 @@
# LDAP
While many applications can support systems like Security Assertion Markup
Language (SAML), or Open Authorization (OAuth), many do not.
While many applications can support external authentication and identity services through
Oauth2, not all services can.
Lightweight Directory Access Protocol (LDAP) has been the "lingua franca" of
authentication for many years, with almost every application in the world being
able to search and bind to LDAP. As many organization still rely on LDAP, Kanidm
can host a read-only LDAP interface.
able to search and bind to LDAP. As many organisations still rely on LDAP, Kanidm
can host a read-only LDAP interface for these legacy applications.
{{#template
../templates/kani-warning.md
imagepath=../images
title=Warning!
text=The LDAP server in Kanidm is not RFC compliant. This is intentional, as Kanidm wants to cover the common use case, simple bind and search.
text=The LDAP server in Kanidm is not a fully RFC-compliant LDAP server. This is intentional, as Kanidm wants to cover the common use cases - simple bind and search.
}}
@ -42,11 +42,11 @@ elements, and ignore others.
For this reason, when you search the LDAP interface, Kanidm will make some mapping decisions.
* The domain_info object becomes the suffix root.
* All other entries are direct subordinates of the domain_info for DN purposes.
* Distinguished Names (DNs) are generated from the attributes naming attributes.
* The Kanidm domain name is used to generate the DN of the suffix.
* The domain\_info object becomes the suffix root.
* All other entries are direct subordinates of the domain\_info for DN purposes.
* Distinguished Names (DNs) are generated from the spn, name, or uuid attribute.
* Bind DNs can be remapped and rewritten, and may not even be a DN during bind.
* The Kanidm domain name is used to generate the base DN.
* The '\*' and '+' operators can not be used in conjuction with attribute lists in searches.
These decisions were made to make the path as simple and effective as possible,
@ -62,6 +62,11 @@ StartTLS is not supported due to security risks. LDAPS is the only secure method
of communicating to any LDAP server. Kanidm, when configured with certificates, will
use them for LDAPS (and will not listen on a plaintext LDAP port).
### Writes
LDAP's structure is too simplistic for writing to the complex entries that Kanidm internally
contains. As a result, writes are rejected for all users via the LDAP interface.
### Access Controls
LDAP only supports password authentication. As LDAP is used heavily in POSIX environments
@ -72,6 +77,9 @@ As the POSIX password is not equivalent in strength to the primary credentials o
rights to elevated read permissions. All binds have the permissions of "Anonymous"
even if the anonymous account is locked.
The exception is service accounts which can use api-tokens during an LDAP bind for elevated
read permissions.
## Server Configuration
To configure Kanidm to provide LDAP, add the argument to the `server.toml` configuration:
@ -90,7 +98,7 @@ mappings for application specific requests that must be satisfied.
An example is that some applications expect and require a 'CN' value, even though Kanidm does not
provide it. If the application is unable to be configured to accept "name" it may be necessary
to use Kanidm's mapping feature. Currently these are compiled into the server, so you may need to open
an issue with your requirements.
an issue with your requirements for attribute maps.
To show what attribute maps exists for an entry you can use the attribute search term '+'.
@ -104,18 +112,28 @@ Kanidm native attributes.
ldapsearch ... -x '(name=admin)' cn objectClass displayname memberof
## Service Accounts
If you have [issued api tokens for a service account](../accounts_and_groups.html#using-api-tokens-with-service-accounts)
they can be used to gain extended read permissions for those service accounts.
Api tokens can also be used to gain extended search permissions with LDAP. To do this you can bind
with a dn of "dn=token" and provide the api token in the password.
> **NOTE** The 'dn=token' keyword is guaranteed to not be used by any other entry, which is why it was chosen as the keyword to initiate api token binds.
```shell
ldapwhoami -H ldaps://URL -x -D "dn=token" -w "TOKEN"
ldapwhoami -H ldaps://idm.example.com -x -D "dn=token" -w "..."
# u: demo_service@idm.example.com
```
## Example
Given a default install with domain "example.com" the configured LDAP DN will be "dc=example,dc=com".
Run your server:
cargo run -- server \
-D kanidm.db \
-C ca.pem -c cert.pem \
-k key.pem \
-b 127.0.0.1:8443 \
-l 127.0.0.1:3636
# from server.toml
ldapbindaddress = "[::]:3636"
This can be queried with:
@ -170,3 +188,4 @@ This is despite the fact:
* The third is an incorrect port.
To diagnose errors like this, you may need to add "-d 1" to your LDAP commands or client.