12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package auth
- import (
- "fmt"
- "github.com/pkg/errors"
- "gogs.io/gogs/internal/errutil"
- )
- type Type int
- const (
- None Type = iota
- Plain
- LDAP
- SMTP
- PAM
- DLDAP
- GitHub
- )
- func Name(typ Type) string {
- return map[Type]string{
- LDAP: "LDAP (via BindDN)",
- DLDAP: "LDAP (simple auth)",
- SMTP: "SMTP",
- PAM: "PAM",
- GitHub: "GitHub",
- }[typ]
- }
- var _ errutil.NotFound = (*ErrBadCredentials)(nil)
- type ErrBadCredentials struct {
- Args errutil.Args
- }
- func IsErrBadCredentials(err error) bool {
- _, ok := errors.Cause(err).(ErrBadCredentials)
- return ok
- }
- func (err ErrBadCredentials) Error() string {
- return fmt.Sprintf("bad credentials: %v", err.Args)
- }
- func (ErrBadCredentials) NotFound() bool {
- return true
- }
- type ExternalAccount struct {
-
- Login string
-
- Name string
-
- FullName string
-
- Email string
-
- Location string
-
- Website string
-
- Admin bool
- }
- type Provider interface {
-
-
- Authenticate(login, password string) (*ExternalAccount, error)
-
- Config() any
-
- HasTLS() bool
-
- UseTLS() bool
-
- SkipTLSVerify() bool
- }
|