ldap

package
v2.0.0-alpha.5+incompa... Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ldap implements strategies for authenticating using the LDAP protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The host and optional port of the LDAP server. If port isn't supplied, it will be
	// guessed based on the TLS configuration. 389 or 636.
	Host string `yaml:"host"`

	// Required if LDAP host does not use TLS.
	InsecureNoSSL bool `yaml:"insecureNoSSL"`

	// Path to a trusted root certificate file.
	RootCA string `yaml:"rootCA"`

	// BindDN and BindPW for an application service account. The connector uses these
	// credentials to search for users and groups.
	BindDN string `yaml:"bindDN"`
	BindPW string `yaml:"bindPW"`

	// User entry search configuration.
	UserSearch struct {
		// BsaeDN to start the search from. For example "cn=users,dc=example,dc=com"
		BaseDN string `yaml:"baseDN"`

		// Optional filter to apply when searching the directory. For example "(objectClass=person)"
		Filter string `yaml:"filter"`

		// Attribute to match against the inputted username. This will be translated and combined
		// with the other filter as "(<attr>=<username>)".
		Username string `yaml:"username"`

		// Can either be:
		// * "sub" - search the whole sub tree
		// * "one" - only search one level
		Scope string `yaml:"scope"`

		// A mapping of attributes on the user entry to claims.
		IDAttr    string `yaml:"idAttr"`    // Defaults to "uid"
		EmailAttr string `yaml:"emailAttr"` // Defaults to "mail"
		NameAttr  string `yaml:"nameAttr"`  // No default.

	} `yaml:"userSearch"`

	// Group search configuration.
	GroupSearch struct {
		// BsaeDN to start the search from. For example "cn=groups,dc=example,dc=com"
		BaseDN string `yaml:"baseDN"`

		// Optional filter to apply when searching the directory. For example "(objectClass=posixGroup)"
		Filter string `yaml:"filter"`

		Scope string `yaml:"scope"` // Defaults to "sub"

		// These two fields are use to match a user to a group.
		//
		// It adds an additional requirement to the filter that an attribute in the group
		// match the user's attribute value. For example that the "members" attribute of
		// a group matches the "uid" of the user. The exact filter being added is:
		//
		//   (<groupAttr>=<userAttr value>)
		//
		UserAttr  string `yaml:"userAttr"`
		GroupAttr string `yaml:"groupAttr"`

		// The attribute of the group that represents its name.
		NameAttr string `yaml:"nameAttr"`
	} `yaml:"groupSearch"`
}

Config holds the configuration parameters for the LDAP connector. The LDAP connectors require executing two queries, the first to find the user based on the username and password given to the connector. The second to use the user entry to search for groups.

An example config:

type: ldap
config:
  host: ldap.example.com:636
  # The following field is required if using port 389.
  # insecureNoSSL: true
  rootCA: /etc/dex/ldap.ca
  bindDN: uid=seviceaccount,cn=users,dc=example,dc=com
  bindPW: password
  userSearch:
    # Would translate to the query "(&(objectClass=person)(uid=<username>))"
    baseDN: cn=users,dc=example,dc=com
    filter: "(objectClass=person)"
    username: uid
    idAttr: uid
    emailAttr: mail
    nameAttr: name
  groupSearch:
    # Would translate to the query "(&(objectClass=group)(member=<user uid>))"
    baseDN: cn=groups,dc=example,dc=com
    filter: "(objectClass=group)"
    userAttr: uid
    groupAttr: member
    nameAttr: name

func (*Config) Open

func (c *Config) Open() (connector.Connector, error)

Open returns an authentication strategy using LDAP.

Jump to

Keyboard shortcuts

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