Documentation
¶
Index ¶
- Constants
- func LegoCertStem(domain string) (string, error)
- func Port(listen string) uint16
- func Run(ctx context.Context, opt Options) error
- func ServiceBindDN(base string) string
- func StatePath(override string) string
- func ValidBaseDN(dn string) bool
- func ValidOUName(name string) bool
- func ValidateListen(s string) error
- type Config
- type Directory
- type Entry
- type Input
- type OU
- type Options
- type Role
- type Server
- type User
- type WireEntry
Constants ¶
const ( // DefaultBaseDN is used when the internal directory is enabled and no // base DN has been set. DefaultBaseDN = "dc=factum,dc=local" // DefaultListen is the plain LDAP listen address. DefaultListen = ":389" // ServiceCN is the RDN of the search bind account. It is not a person. ServiceCN = "svc-factum" // MatchingRuleInChain is Active Directory's LDAP_MATCHING_RULE_IN_CHAIN. // A filter (member:1.2.840.113556.1.4.1941:=dn) matches a group when dn // is a direct or nested member. memberOf walks the other way. MatchingRuleInChain = "1.2.840.113556.1.4.1941" )
const Command = "ldap"
Command is the worker.commands name that starts the LDAP listener.
Variables ¶
This section is empty.
Functions ¶
func LegoCertStem ¶
LegoCertStem is the file name lego uses for a certificate domain, without an extension. It matches lego's sanitizedDomain: ":" becomes "-", "*" becomes "_", then the name is converted to ASCII. The result is one path segment.
func ServiceBindDN ¶
ServiceBindDN is the search account for BaseDN.
func StatePath ¶
StatePath is the on-disk directory snapshot. Empty uses the default. The file holds password hashes and the search-account password.
func ValidBaseDN ¶
ValidBaseDN reports whether dn is a usable base DN.
func ValidOUName ¶
ValidOUName is a folder name that can be an RDN.
func ValidateListen ¶
ValidateListen accepts an empty address or host:port.
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
Listen string `json:"listen"`
TLSListen string `json:"tls_listen,omitempty"`
// TLSCertificate is the certificate-store name. TLSDomain is its
// first domain, which is the lego file stem before sanitizing.
// Both empty means LDAPS uses the worker hub certificate.
TLSCertificate string `json:"tls_certificate,omitempty"`
TLSDomain string `json:"tls_domain,omitempty"`
BaseDN string `json:"base_dn"`
BindDN string `json:"bind_dn"`
BindPassword string `json:"bind_password,omitempty"`
Entries []WireEntry `json:"entries"`
}
Config is the snapshot a worker persists and serves.
type Directory ¶
type Directory struct {
BaseDN string
BindDN string
BindPassword string
// RoleDN maps a role id to the DN it was published at. OUDN does the
// same for folders. Both are empty for a snapshot loaded from disk.
RoleDN map[uint]string
OUDN map[uint]string
// contains filtered or unexported fields
}
Directory is an immutable snapshot.
type Entry ¶
type Entry struct {
DN string
Attrs map[string][]string
Password string
DirectMembers []string
DirectMemberOf []string
// contains filtered or unexported fields
}
Entry is one object served over LDAP. Password is checked on bind and is never returned as an attribute. DirectMembers and DirectMemberOf are the unexpanded edges used by the Active Directory in-chain rule. memberOf in Attrs is already expanded, so a plain equality filter sees nested groups.
type Options ¶
type Options struct {
StatePath string
// TLSCert and TLSKey are the worker hub certificate. LDAPS uses them
// when the snapshot does not name a certificate from the store.
TLSCert string
TLSKey string
// LegoStorage is this worker's lego data directory (worker.paths
// lego_storage). A chosen certificate is read from certificates/
// under that directory.
LegoStorage string
Fetch func(ctx context.Context) ([]byte, error)
}
Options wires the listener to the hub. Fetch may fail while factum2 is down; the last snapshot on disk keeps answering.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server answers LDAP. The snapshot is swapped as a whole.
type User ¶
type User struct {
ID uint
Username string
Name string
Email string
Mobile string
Password string
OUID *uint
RoleIDs []uint
}
User is a person published in the directory. Password is a bcrypt hash. Accounts without a bcrypt hash are left out. ID is the factum user id and is not part of the DN.
type WireEntry ¶
type WireEntry struct {
DN string `json:"dn"`
Attributes map[string][]string `json:"attributes"`
Password string `json:"password,omitempty"`
Members []string `json:"members,omitempty"`
MemberOf []string `json:"member_of,omitempty"`
}
WireEntry is one object in the snapshot. Password is a bcrypt hash. Members and MemberOf are the direct edges. The memberof attribute is the expanded list.