models

package
v0.0.0-...-8da75af Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMTPPlain = "PLAIN"
	SMTPLogin = "LOGIN"
)

SMTP authentication type names.

Variables

View Source
var LoginNames = map[LoginType]string{
	LoginLDAP:  "LDAP (via BindDN)",
	LoginDLDAP: "LDAP (simple auth)",
	LoginSMTP:  "SMTP",
	LoginPAM:   "PAM",
}

LoginNames contains the name of LoginType values.

View Source
var SMTPAuths = []string{SMTPPlain, SMTPLogin}

SMTPAuths contains available SMTP authentication type names.

View Source
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

func Cell2Int64(val xorm.Cell) int64

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

type LDAPConfig struct {
	*ldap.Source
}

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 LoginType

type LoginType int

LoginType represents an login type.

const (
	LoginNoType LoginType = iota
	LoginPlain            // 1
	LoginLDAP             // 2
	LoginSMTP             // 3
	LoginPAM              // 4
	LoginDLDAP            // 5
)

Note: new type must append to the end of list to maintain compatibility.

type PAMConfig

type PAMConfig struct {
	ServiceName string // pam service (e.g. system-auth)
}

PAMConfig holds configuration for the PAM login source.

func (*PAMConfig) FromDB

func (cfg *PAMConfig) FromDB(bs []byte) error

FromDB fills up a PAMConfig from serialized format.

func (*PAMConfig) ToDB

func (cfg *PAMConfig) ToDB() ([]byte, error)

ToDB exports a PAMConfig to a serialized format.

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.

Jump to

Keyboard shortcuts

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