Documentation ¶
Index ¶
- Constants
- Variables
- func Cell2Int64(val xorm.Cell) int64
- func CountLoginSources() int64
- func CreateLoginSource(source *LoginSource) error
- func DeleteSource(source *LoginSource) error
- func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error
- func UpdateSource(source *LoginSource) error
- type LDAPConfig
- type LoginSource
- func (source *LoginSource) AfterSet(colName string, _ xorm.Cell)
- func (source *LoginSource) BeforeInsert()
- func (source *LoginSource) BeforeSet(colName string, val xorm.Cell)
- func (source *LoginSource) BeforeUpdate()
- func (source *LoginSource) HasTLS() bool
- func (source *LoginSource) IsDLDAP() bool
- func (source *LoginSource) IsLDAP() bool
- func (source *LoginSource) IsPAM() bool
- func (source *LoginSource) IsSMTP() bool
- func (source *LoginSource) LDAP() *LDAPConfig
- func (source *LoginSource) PAM() *PAMConfig
- func (source *LoginSource) SMTP() *SMTPConfig
- func (source *LoginSource) SkipVerify() bool
- func (source *LoginSource) TypeName() string
- func (source *LoginSource) UseTLS() bool
- type LoginType
- type PAMConfig
- type SMTPConfig
Constants ¶
const ( SMTPPlain = "PLAIN" SMTPLogin = "LOGIN" )
SMTP authentication type names.
Variables ¶
var LoginNames = map[LoginType]string{ LoginLDAP: "LDAP (via BindDN)", LoginDLDAP: "LDAP (simple auth)", LoginSMTP: "SMTP", LoginPAM: "PAM", }
LoginNames contains the name of LoginType values.
var SMTPAuths = []string{SMTPPlain, SMTPLogin}
SMTPAuths contains available SMTP authentication type names.
var SecurityProtocolNames = map[ldap.SecurityProtocol]string{ ldap.SecurityProtocolUnencrypted: "Unencrypted", ldap.SecurityProtocolLDAPS: "LDAPS", ldap.SecurityProtocolStartTLS: "StartTLS", }
SecurityProtocolNames contains the name of SecurityProtocol values.
Functions ¶
func Cell2Int64 ¶
Cell2Int64 converts a xorm.Cell type to int64, and handles possible irregular cases.
func CountLoginSources ¶
func CountLoginSources() int64
CountLoginSources returns number of login sources.
func CreateLoginSource ¶
func CreateLoginSource(source *LoginSource) error
CreateLoginSource inserts a LoginSource in the DB if not already existing with the given name.
func DeleteSource ¶
func DeleteSource(source *LoginSource) error
DeleteSource deletes a LoginSource record in DB.
func SMTPAuth ¶
func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error
SMTPAuth performs an SMTP authentication.
func UpdateSource ¶
func UpdateSource(source *LoginSource) error
UpdateSource updates a LoginSource record in DB.
Types ¶
type LDAPConfig ¶
LDAPConfig holds configuration for LDAP login source.
func (*LDAPConfig) FromDB ¶
func (cfg *LDAPConfig) FromDB(bs []byte) error
FromDB fills up a LDAPConfig from serialized format.
func (*LDAPConfig) SecurityProtocolName ¶
func (cfg *LDAPConfig) SecurityProtocolName() string
SecurityProtocolName returns the name of configured security protocol.
func (*LDAPConfig) ToDB ¶
func (cfg *LDAPConfig) ToDB() ([]byte, error)
ToDB exports a LDAPConfig to a serialized format.
type LoginSource ¶
type LoginSource struct { ID int64 `xorm:"pk autoincr"` Type LoginType Name string `xorm:"UNIQUE"` IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"` Cfg core.Conversion `xorm:"TEXT"` Created time.Time `xorm:"-"` CreatedUnix int64 `xorm:"INDEX"` Updated time.Time `xorm:"-"` UpdatedUnix int64 `xorm:"INDEX"` }
LoginSource represents an external way for authorizing users.
func GetLoginSourceByID ¶
func GetLoginSourceByID(id int64) (*LoginSource, error)
GetLoginSourceByID returns login source by given ID.
func LoginSources ¶
func LoginSources() ([]*LoginSource, error)
LoginSources returns a slice of all login sources found in DB.
func (*LoginSource) AfterSet ¶
func (source *LoginSource) AfterSet(colName string, _ xorm.Cell)
AfterSet is invoked from XORM after setting the value of a field of this object.
func (*LoginSource) BeforeInsert ¶
func (source *LoginSource) BeforeInsert()
BeforeInsert is invoked from XORM before inserting an object of this type.
func (*LoginSource) BeforeSet ¶
func (source *LoginSource) BeforeSet(colName string, val xorm.Cell)
BeforeSet is invoked from XORM before setting the value of a field of this object.
func (*LoginSource) BeforeUpdate ¶
func (source *LoginSource) BeforeUpdate()
BeforeUpdate is invoked from XORM before updating this object.
func (*LoginSource) HasTLS ¶
func (source *LoginSource) HasTLS() bool
HasTLS returns true of this source supports TLS.
func (*LoginSource) IsDLDAP ¶
func (source *LoginSource) IsDLDAP() bool
IsDLDAP returns true of this source is of the DLDAP type.
func (*LoginSource) IsLDAP ¶
func (source *LoginSource) IsLDAP() bool
IsLDAP returns true of this source is of the LDAP type.
func (*LoginSource) IsPAM ¶
func (source *LoginSource) IsPAM() bool
IsPAM returns true of this source is of the PAM type.
func (*LoginSource) IsSMTP ¶
func (source *LoginSource) IsSMTP() bool
IsSMTP returns true of this source is of the SMTP type.
func (*LoginSource) LDAP ¶
func (source *LoginSource) LDAP() *LDAPConfig
LDAP returns LDAPConfig for this source, if of LDAP type.
func (*LoginSource) PAM ¶
func (source *LoginSource) PAM() *PAMConfig
PAM returns PAMConfig for this source, if of PAM type.
func (*LoginSource) SMTP ¶
func (source *LoginSource) SMTP() *SMTPConfig
SMTP returns SMTPConfig for this source, if of SMTP type.
func (*LoginSource) SkipVerify ¶
func (source *LoginSource) SkipVerify() bool
SkipVerify returns true if this source is configured to skip SSL verification.
func (*LoginSource) TypeName ¶
func (source *LoginSource) TypeName() string
TypeName return name of this login source type.
func (*LoginSource) UseTLS ¶
func (source *LoginSource) UseTLS() bool
UseTLS returns true of this source is configured to use TLS.
type PAMConfig ¶
type PAMConfig struct {
ServiceName string // pam service (e.g. system-auth)
}
PAMConfig holds configuration for the PAM login source.
type SMTPConfig ¶
type SMTPConfig struct { Auth string Host string Port int AllowedDomains string `xorm:"TEXT"` TLS bool SkipVerify bool }
SMTPConfig holds configuration for the SMTP login source.
func (*SMTPConfig) FromDB ¶
func (cfg *SMTPConfig) FromDB(bs []byte) error
FromDB fills up an SMTPConfig from serialized format.
func (*SMTPConfig) ToDB ¶
func (cfg *SMTPConfig) ToDB() ([]byte, error)
ToDB exports an SMTPConfig to a serialized format.