auth

package
v1.21.2-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountLoginName = "account"
	DefaultLoginURL  = "/token"
	TokenTypeJWT     = "JWT"
	TokenTypeBasic   = "BASIC"
	TokenTypePrivate = "PRIVATE-TOKEN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountLoginUtil

type AccountLoginUtil struct {
	Name string
	DB   *gorm.DB
}

func (*AccountLoginUtil) GetUserInfo

func (ut *AccountLoginUtil) GetUserInfo(ctx context.Context, cred *Credential) (*UserInfo, error)

func (*AccountLoginUtil) LoginAddr

func (ut *AccountLoginUtil) LoginAddr() string

type AuthenticateIface

type AuthenticateIface interface {
	// LoginAddr 获取登录地址
	LoginAddr() string
	// 验证凭据, 获取用户信息
	GetUserInfo(ctx context.Context, cred *Credential) (*UserInfo, error)
}

AuthenticateIface 所有登录插件需要实现AuthenticateIface接口

type AuthenticateModule

type AuthenticateModule struct {
	DB *gorm.DB
}

func NewAuthenticateModule

func NewAuthenticateModule(db *gorm.DB) *AuthenticateModule

func (*AuthenticateModule) GetAuthenticateModule

func (l *AuthenticateModule) GetAuthenticateModule(ctx context.Context, name string) AuthenticateIface

type AuthenticateModuleIface

type AuthenticateModuleIface interface {
	GetAuthenticateModule(name string) AuthenticateIface
}

type Credential

type Credential struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Code     string `json:"code"`
	Source   string `json:"source"`
}

type LdapLoginUtils

type LdapLoginUtils struct {
	Name         string `yaml:"name"`
	LdapAddr     string `yaml:"addr"`
	BaseDN       string `yaml:"basedn"`
	BindUsername string `yaml:"binduser"`
	BindPassword string `yaml:"bindpass"`
}

func (*LdapLoginUtils) GetUserInfo

func (ut *LdapLoginUtils) GetUserInfo(ctx context.Context, cred *Credential) (ret *UserInfo, err error)

func (*LdapLoginUtils) LoginAddr

func (ut *LdapLoginUtils) LoginAddr() string

func (*LdapLoginUtils) ValidateCredential

func (ut *LdapLoginUtils) ValidateCredential(cred *Credential) bool

type OauthLoginUtils

type OauthLoginUtils struct {
	Name        string
	Options     *OauthOption
	OauthConfig *oauth2.Config
	// contains filtered or unexported fields
}

func NewOauthUtils

func NewOauthUtils(opts *OauthOption) *OauthLoginUtils

func (*OauthLoginUtils) GetUserInfo

func (ot *OauthLoginUtils) GetUserInfo(ctx context.Context, cred *Credential) (*UserInfo, error)

func (*OauthLoginUtils) LoginAddr

func (ot *OauthLoginUtils) LoginAddr() string

type OauthOption

type OauthOption struct {
	AuthURL     string
	TokenURL    string
	UserInfoURL string
	RedirectURL string
	AppID       string
	AppSecret   string
	Scopes      []string
}

type UserInfo

type UserInfo struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Source   string `json:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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