auth

package
v1.24.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

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

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

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, tracer trace.Tracer) *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

type AuthenticateModule struct {
	DB *gorm.DB
}

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

type BearerTokenUserLoader struct {
	JWT    *jwt.JWT
	Tracer trace.Tracer
}

BearerTokenUserLoader bearer type

func (*BearerTokenUserLoader) GetUser

func (l *BearerTokenUserLoader) GetUser(req *http.Request) (u user.CommonUserIface, exist bool)

type Credential

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

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 OauthOption struct {
	AuthURL     string   `json:"url"`
	TokenURL    string   `json:"tokenURL"`
	UserInfoURL string   `json:"userInfoURL"`
	RedirectURL string   `json:"redirectURL"`
	AppID       string   `json:"appID"`
	AppSecret   string   `json:"appSecret"`
	Scopes      []string `json:"scopes"`
}

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

type UserInfo

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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