auth: support authentication source config file (#3142)

This commit is contained in:
Unknwon
2018-04-12 09:55:58 -04:00
parent 717d409b72
commit f2ecfdc96a
24 changed files with 504 additions and 166 deletions

View File

@@ -6,6 +6,19 @@ package errors
import "fmt"
type LoginSourceNotExist struct {
ID int64
}
func IsLoginSourceNotExist(err error) bool {
_, ok := err.(LoginSourceNotExist)
return ok
}
func (err LoginSourceNotExist) Error() string {
return fmt.Sprintf("login source does not exist [id: %d]", err.ID)
}
type LoginSourceNotActivated struct {
SourceID int64
}
@@ -31,3 +44,17 @@ func IsInvalidLoginSourceType(err error) bool {
func (err InvalidLoginSourceType) Error() string {
return fmt.Sprintf("invalid login source type [type: %v]", err.Type)
}
type LoginSourceMismatch struct {
Expect int64
Actual int64
}
func IsLoginSourceMismatch(err error) bool {
_, ok := err.(LoginSourceMismatch)
return ok
}
func (err LoginSourceMismatch) Error() string {
return fmt.Sprintf("login source mismatch [expect: %d, actual: %d]", err.Expect, err.Actual)
}