1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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
- Mock Type = 999
- )
- 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 {
- return errors.As(err, &ErrBadCredentials{})
- }
- 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
- }
|