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)
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) 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)
type OauthOption ¶
type OauthOption struct {
AuthURL string
TokenURL string
UserInfoURL string
RedirectURL string
AppID string
AppSecret string
Scopes []string
}
Click to show internal directories.
Click to hide internal directories.