Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JWTCreateToken ¶
JWTCreateToken creates a JWT with the claims configured in the User struct and sends it back to the client.
Types ¶
type Configuration ¶
type Configuration struct { // JWT configuration JWTMethod string `env:"AUTH_JWT_METHOD" envDefault:"HS512"` JWTSecret string `env:"AUTH_JWT_SECRET,required"` JWTValidMinutes time.Duration `env:"AUTH_JWT_VALID_MIN" envDefault:"30m"` // Server attributes defined in Serv ServerAttributes }
Configuration defines the main authentication configuration parameters. This should contain a connection to your authentication server, plus configuration for JWT and the auth server's connection parameters.
var Cfg Configuration
Cfg is the instance of Configuration.
type Server ¶
type Server interface { Close() Connect() error Authenticate(string, string) (bool, map[string]string, error) GetGroupsOfUser(string) ([]string, error) }
Server is the interface that the auth server client library satisfies
type ServerAttributes ¶
type ServerAttributes struct { Conn Server BaseDN string `env:"AUTH_LDAP_BASE,required"` BindDN string `env:"AUTH_LDAP_BIND_DN"` BindPW string `env:"AUTH_LDAP_BIND_PW"` Host string `env:"AUTH_LDAP_HOST" envDefault:"localhost"` Port int `env:"AUTH_LDAP_PORT" envDefault:"389"` UseTLS bool `env:"AUTH_LDAP_TLS" envDefault:"false"` StartTLS bool `env:"AUTH_LDAP_START_TLS" envDefault:"false"` UIDFieldName string `env:"AUTH_LDAP_UID_NAME" envDefault:"uid"` GIDFieldName string `env:"AUTH_LDAP_GID_NAME" envDefault:"memberUid"` Timeout int `env:"AUTH_LDAP_TIMEOUT_SECS" envDefault:"3"` Fields []string // Populated based on the mapstructure tags in User }
ServerAttributes contains the fields needed to connect to the auth server
type User ¶
type User struct { Email string `mapstructure:"mail" structs:"email"` Realname string `mapstructure:"gecos" structs:"fullname"` Username string `mapstructure:"uid" structs:"name"` // Groups isn't directly pulled from a single LDAP field, nor is it // stored in the JWT claims Groups []string `structs:",omitempty"` }
User contains data about the user that we care about.
The 'mapstructure' tag maps to LDAP fields, and 'structs' maps to JWT claims e.g. Email is stored in ldap as "mail", and in the JWT claims as "email". There must be a mapstructure tag for the field to be pulled from LDAP and similarly there must be a structs tag for the field to be put into the JWT claims