package config import ( "errors" "fmt" "net/url" "strings" "time" "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/v2" ) // LDAP is sign-in against a directory — Active Directory above all — with // the directory's own passwords, and the accounts kept in step with it. // // auth: // ldap: // urls: [ldaps://dc1.corp.example.com, ldaps://dc2.corp.example.com] // bind_dn: CN=llmgw,OU=Service Accounts,DC=corp,DC=example,DC=com // bind_password_file: /etc/llmgw/secrets/ldap-bind // base_dn: OU=Staff,DC=corp,DC=example,DC=com // create_accounts: true // roles: {admin: [llmgw-admins]} // memberships: {ml-team: "team:Acme/ml"} // // A person signs in on the portal's form with their sAMAccountName, their // userPrincipalName or their mail, and their directory password. The // gateway finds them with the bind account, checks the password by binding // as them, and reads their groups, nested ones included. Every sync_interval // the leader reads the directory again: an account disabled or gone there // is suspended here, its sessions ended and its API keys refused. type LDAP struct { // URLs are the directory's servers, tried in turn: ldaps:// (636), or // ldap:// (389) with StartTLS. URLs []string `koanf:"urls"` // StartTLS upgrades an ldap:// connection before anything is sent. A // password never crosses a connection without TLS: ldap:// without it // is refused. StartTLS bool `koanf:"start_tls"` // CAFile is the authority the servers' certificates are checked against, // when it is not the system's: an AD Certificate Services root. CAFile string `koanf:"ca_file"` // CA is the same authority written out, PEM: kept in the cluster's // settings, so no file has to be put on every control plane. Used in // place of CAFile when both are set. CA string `koanf:"ca"` // BindDN and the file holding its password: a service account that may // read users and groups. Nothing is written to the directory. BindDN string `koanf:"bind_dn"` BindPasswordFile string `koanf:"bind_password_file"` // BaseDN is where people are searched for, subtree included. BaseDN string `koanf:"base_dn"` // GroupBaseDN is where their groups are; empty is BaseDN's domain root. GroupBaseDN string `koanf:"group_base_dn"` // UserFilter narrows who may sign in, ANDed with the login match: a // group (memberOf=...) or an OU's people only. Empty is every enabled // user object. UserFilter string `koanf:"user_filter"` // Label is what the form says to sign in with: "Sign in with your //