You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-2Lines changed: 63 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -200,8 +200,8 @@ The following options are available for configuring the OmniAuth LDAP strategy:
200
200
201
201
Why DN for `auth.uid`?
202
202
203
-
- DN is the canonical, globally unique identifier for an LDAP entry and is always present in search results. See LDAPv3 and DN syntax: RFC 4511 (LDAP protocol) and RFC 4514 (String Representation of Distinguished Names).
204
-
- Attributes like `uid` (defined in RFC 4519) or `sAMAccountName` (Active Directory–specific) may be absent, duplicated across parts of the DIT, or vary between directories. Using DN ensures consistent behavior across AD, OpenLDAP, and other servers.
203
+
- DN is the canonical, globally unique identifier for an LDAP entry and is always present in search results. See LDAPv3 and DN syntax: [RFC 4511][rfc4511] (LDAP protocol) and [RFC 4514][rfc4514] (String Representation of Distinguished Names).
204
+
- Attributes like `uid` (defined in [RFC 4519][rfc4519]) or `sAMAccountName` (Active Directory–specific) may be absent, duplicated across parts of the DIT, or vary between directories. Using DN ensures consistent behavior across AD, OpenLDAP, and other servers.
205
205
- This trade-off favors cross-directory interoperability and stability for apps that need a unique identifier.
Some deployments terminate SSO at a reverse proxy or portal and forward the already-authenticated user identity via an HTTP header such as `REMOTE_USER`.
347
+
When you enable this mode, the LDAP strategy will trust the upstream header, perform a directory lookup for that user, and complete OmniAuth without asking the user for a password.
348
+
349
+
Important: Only enable this behind a trusted front-end that strips and sets the header itself. Never enable on a public endpoint without such a gateway, or an attacker could spoof the header.
-`:header_name` (String, default: "REMOTE_USER") — The env/header key to read. The strategy checks both `env["REMOTE_USER"]` and the Rack variant `env["HTTP_REMOTE_USER"]`.
355
+
-`:name_proc` is applied to the header value before search (e.g., to strip a domain part).
356
+
- Search is done using your configured `:uid` or `:filter` and the service bind (`:bind_dn`/`:password`) or anonymous bind if allowed.
357
+
358
+
Minimal Rack example:
359
+
360
+
```ruby
361
+
use OmniAuth::Builderdo
362
+
provider :ldap,
363
+
host:"ldap.example.com",
364
+
base:"dc=example,dc=com",
365
+
uid:"uid",
366
+
bind_dn:"cn=search,dc=example,dc=com",
367
+
password:ENV["LDAP_SEARCH_PASSWORD"],
368
+
header_auth:true, # trust REMOTE_USER
369
+
header_name:"REMOTE_USER", # default
370
+
name_proc:proc { |n| n.split("@").first }
371
+
end
372
+
```
373
+
374
+
Rails initializer example:
375
+
376
+
```ruby
377
+
Rails.application.config.middleware.use(OmniAuth::Builder) do
378
+
provider :ldap,
379
+
title:"Acme LDAP",
380
+
host:"ldap.acme.internal",
381
+
base:"dc=acme,dc=corp",
382
+
uid:"sAMAccountName",
383
+
bind_dn:"cn=search,dc=acme,dc=corp",
384
+
password:ENV["LDAP_SEARCH_PASSWORD"],
385
+
header_auth:true,
386
+
header_name:"REMOTE_USER",
387
+
# Optionally restrict with a group filter while using the header value
0 commit comments