Documentation ¶
Index ¶
- Constants
- type AccountLoginUtil
- type AuthMiddleware
- type AuthenticateIface
- type AuthenticateModule
- type AuthenticateModuleIface
- type BasicAuthUserLoader
- type BearerTokenUserLoader
- type Credential
- type LdapLoginUtils
- type OauthCommonUserInfo
- type OauthLoginUtils
- type OauthOption
- type PrivateTokenUserLoader
- type UserGetterIface
- type UserInfo
Constants ¶
View Source
const ( AccountLoginName = "account" DefaultLoginURL = "/v1/login" TokenTypeJWT = "JWT" TokenTypeBasic = "BASIC" TokenTypePrivate = "PRIVATE-TOKEN" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountLoginUtil ¶
func (*AccountLoginUtil) GetName ¶
func (ut *AccountLoginUtil) GetName() string
func (*AccountLoginUtil) GetUserInfo ¶
func (ut *AccountLoginUtil) GetUserInfo(ctx context.Context, cred *Credential) (*UserInfo, error)
func (*AccountLoginUtil) LoginAddr ¶
func (ut *AccountLoginUtil) LoginAddr() string
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthMiddleware ¶
func NewAuthMiddleware(opts *jwt.Options, userif aaa.ContextUserOperator) *AuthMiddleware
func (*AuthMiddleware) FilterFunc ¶
func (l *AuthMiddleware) FilterFunc(c *gin.Context)
func (*AuthMiddleware) GoRestfulMiddleware ¶ added in v1.22.0
func (l *AuthMiddleware) GoRestfulMiddleware(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
type AuthenticateIface ¶
type AuthenticateIface interface { GetName() string // LoginAddr 获取登录地址 LoginAddr() string // 验证凭据, 获取用户信息 GetUserInfo(ctx context.Context, cred *Credential) (*UserInfo, error) }
AuthenticateIface 所有登录插件需要实现AuthenticateIface接口
type AuthenticateModule ¶
func NewAuthenticateModule ¶
func NewAuthenticateModule(db *gorm.DB) *AuthenticateModule
func (*AuthenticateModule) GetAuthenticateModule ¶
func (l *AuthenticateModule) GetAuthenticateModule(ctx context.Context, sourceName string) AuthenticateIface
func (*AuthenticateModule) GetNameFromState ¶
func (l *AuthenticateModule) GetNameFromState(state string) (string, error)
type AuthenticateModuleIface ¶
type AuthenticateModuleIface interface {
GetAuthenticateModule(name string) AuthenticateIface
}
type BasicAuthUserLoader ¶
type BasicAuthUserLoader struct{}
BasicAuthUserLoader basic认证 eg: Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
func (*BasicAuthUserLoader) GetUser ¶
func (l *BasicAuthUserLoader) GetUser(req *http.Request) (userData user.CommonUserIface, exist bool)
type BearerTokenUserLoader ¶
BearerTokenUserLoader bearer type
func (*BearerTokenUserLoader) GetUser ¶
func (l *BearerTokenUserLoader) GetUser(req *http.Request) (u user.CommonUserIface, exist bool)
type Credential ¶
type LdapLoginUtils ¶
type LdapLoginUtils struct { Name string `yaml:"name" json:"name"` Vendor string `json:"vendor"` LdapAddr string `yaml:"addr" json:"ldapaddr"` BaseDN string `yaml:"basedn" json:"basedn"` EnableTLS bool `json:"enableTLS"` Filter string `json:"filter"` BindUsername string `yaml:"binduser" json:"binduser"` BindPassword string `yaml:"bindpass" json:"password"` }
func (*LdapLoginUtils) GetName ¶
func (ut *LdapLoginUtils) GetName() string
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 OauthCommonUserInfo ¶
type OauthCommonUserInfo struct { Username string `json:"username"` Name string `json:"name"` Email string `json:"email"` }
OauthCommonUserInfo adaptor all source
type OauthLoginUtils ¶
type OauthLoginUtils struct { Name string Vendor string OauthConfig *oauth2.Config // contains filtered or unexported fields }
func NewOauthUtils ¶
func NewOauthUtils(name, vendor string, opts *OauthOption) *OauthLoginUtils
func (*OauthLoginUtils) GetName ¶
func (ot *OauthLoginUtils) GetName() string
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 PrivateTokenUserLoader ¶
type PrivateTokenUserLoader struct{}
PrivateTokenUserLoader private-token
func (*PrivateTokenUserLoader) GetUser ¶
func (l *PrivateTokenUserLoader) GetUser(req *http.Request) (u user.CommonUserIface, exist bool)
type UserGetterIface ¶
type UserGetterIface interface {
GetUser(req *http.Request) (u user.CommonUserIface, exist bool)
}
UserGetterIface
Source Files ¶
Click to show internal directories.
Click to hide internal directories.