ldap

package
v0.45.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package ldap implements simple-bind LDAP/Active Directory authentication.

On a successful bind the account is upserted into the local users table, so RBAC grants, shares and quotas treat a directory user like any other. The browser session that follows is the ordinary `filex_session` cookie — minted through internal/auth/drivers/local so there is exactly one definition of a session's shape.

Two entry points, deliberately

  • Login is the browser path: verify, then mint a session.
  • VerifyPassword is the protocol path (WebDAV, SFTP, FTPS, S3, NFS): verify and nothing else. Those protocols present the password on EVERY request; minting a session per request would fill the sessions table with rows nobody can ever use or revoke.

Both share verify(), so the directory is consulted in exactly one way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is the LDAP/AD auth driver.

func New

func New(store db.Store) *Driver

New constructs an empty driver — Init must be called.

func (*Driver) Authenticate

func (d *Driver) Authenticate(_ *http.Request) (*model.User, error)

Authenticate is a no-op: this driver has no per-request credential to read. A directory account's requests carry the same session cookie as everyone else's, and the local driver resolves those.

⚠ This method being a flat refusal is exactly why the driver used to be unreachable: the auth middleware walks the enabled drivers calling Authenticate, so being "enabled" told it nothing. Login is reached through auth.LoginChain instead — see internal/auth/chain.go.

func (*Driver) Capabilities

func (d *Driver) Capabilities() auth.Capabilities

Capabilities implements auth.Driver.

func (*Driver) Init

func (d *Driver) Init(_ context.Context, cfg map[string]any) error

Init configures the driver.

func (*Driver) Login

func (d *Driver) Login(ctx context.Context, identifier, password string) (*model.User, string, error)

Login verifies the credentials against the directory and mints a browser session for the resulting account.

func (*Driver) Logout

func (d *Driver) Logout(ctx context.Context, token string) error

Logout revokes a session minted by Login.

⚠ Its real job is making *Driver satisfy auth.LoginDriver. Without it the driver could not be placed in the login chain AT ALL — the compiler said "missing method Logout" — which is half of why the directory path was unreachable.

func (*Driver) Name

func (d *Driver) Name() string

Name implements auth.Driver.

func (*Driver) Probe

func (d *Driver) Probe(ctx context.Context, cfg map[string]any, _ *http.Request) []auth.ProbeCheck

Probe tests an LDAP configuration the way a sign-in would use it, stopping at the first step that fails:

required   the address and the base DN are filled in
address    the address is ldap:// or ldaps://
connect    the directory answers at that address (TLS verified for ldaps)
starttls   StartTLS succeeds, when it is switched on for ldap://
bind       the service account binds with its password — or, with no
           service account, the bind is anonymous and said to be
base       the base DN exists and is readable by that bind

⚠ Nothing is written and nobody signs in: this is the service bind and one base-scope read, which is what every login starts with. What it cannot check — that a particular person's filter matches — is left to a login.

func (*Driver) VerifyPassword

func (d *Driver) VerifyPassword(ctx context.Context, identifier, password string) (*model.User, error)

VerifyPassword checks a password against the directory and returns the local account, WITHOUT minting a session. This is what the non-HTTP protocols use; see internal/protocolauth.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL