Documentation
¶
Index ¶
- Constants
- Variables
- func GetDiceClientToken() (uc.OAuthToken, error)
- func MkSessionKey(sessionID string) string
- func NewUCTokenClient(req *uc.NewClientRequest) (*uc.NewClientResponse, error)
- func VerifyUCClientToken(token string) (uc.TokenClient, error)
- type Auth
- type AuthResult
- type GetUserState
- type OAuth2APISpec
- type OpenapiSpec
- type ScopeInfo
- type SetUserState
- type TokenClient
- type User
- func (u *User) GetInfo(req *http.Request) (identity.UserInfo, AuthResult)
- func (u *User) GetOrgInfo(orgHeader, domainHeader string) (orgID uint64, err error)
- func (u *User) GetScopeInfo(req *http.Request) (ScopeInfo, AuthResult)
- func (u *User) IsLogin(req *http.Request) AuthResult
- func (u *User) Login(uccode string, redirectURI string) (string, int, error)
- func (u *User) Logout(req *http.Request) error
- func (u *User) PwdLogin(username, password string) (string, error)
Constants ¶
View Source
const ( Unauthed = http.StatusUnauthorized AuthFail = http.StatusForbidden InternalAuthErr = http.StatusInternalServerError AuthSucc = http.StatusOK )
View Source
const ( HeaderAuthorization = "Authorization" HeaderAuthorizationBearerPrefix = "Bearer " )
View Source
const ( LOGIN checkType = iota TRY_LOGIN BASICAUTH TOKEN NONE )
View Source
const (
CtxKeyOauth2JwtKeyPayload = "oauth2-jwt-token-payload"
)
View Source
const (
SessionExpireDays = 5
)
Variables ¶
View Source
var (
ErrNotExist = errors.New("session not exist")
)
Functions ¶
func MkSessionKey ¶
func NewUCTokenClient ¶
func NewUCTokenClient(req *uc.NewClientRequest) (*uc.NewClientResponse, error)
func VerifyUCClientToken ¶
func VerifyUCClientToken(token string) (uc.TokenClient, error)
@return example: {"id":7,"userId":null,"clientId":"dice-test","clientName":"dice测试应用","clientLogoUrl":null,"clientSecret":null,"autoApprove":false,"scope":["public_profile","email"],"resourceIds":["shinda-maru"],"authorizedGrantTypes":["client_credentials"],"registeredRedirectUris":[],"autoApproveScopes":[],"authorities":["ROLE_CLIENT"],"accessTokenValiditySeconds":433200,"refreshTokenValiditySeconds":433200,"additionalInformation":{}}
Types ¶
type Auth ¶
type Auth struct { RedisCli *redis.Client OAuth2Server *oauth2.OAuth2Server TokenService tokenpb.TokenServiceServer }
func NewAuth ¶
func NewAuth(oauth2server *oauth2.OAuth2Server, token tokenpb.TokenServiceServer) (*Auth, error)
type AuthResult ¶
type GetUserState ¶
type GetUserState int
const ( GetInit GetUserState = iota GotSessionID GotToken GotInfo GotScopeInfo )
type OAuth2APISpec ¶
type OAuth2APISpec interface { MatchPath(path string) bool PathVars(temp, path string) map[string]string Method() string Scheme() string }
OAuth2APISpec .
type OpenapiSpec ¶
OpenapiSpec .
func (*OpenapiSpec) MatchPath ¶
func (s *OpenapiSpec) MatchPath(path string) bool
func (*OpenapiSpec) Method ¶
func (s *OpenapiSpec) Method() string
func (*OpenapiSpec) PathVars ¶
func (s *OpenapiSpec) PathVars(template, path string) map[string]string
func (*OpenapiSpec) Scheme ¶
func (s *OpenapiSpec) Scheme() string
type TokenClient ¶
func VerifyAccessKey ¶
func VerifyAccessKey(tokenService tokenpb.TokenServiceServer, r *http.Request) (TokenClient, error)
func VerifyOpenapiOAuth2Token ¶
func VerifyOpenapiOAuth2Token(o *oauth2.OAuth2Server, spec OAuth2APISpec, r *http.Request) (TokenClient, error)
type User ¶
type User struct {
// contains filtered or unexported fields
}
func (*User) GetOrgInfo ¶
func (*User) GetScopeInfo ¶
func (u *User) GetScopeInfo(req *http.Request) (ScopeInfo, AuthResult)
获取用户orgID
Click to show internal directories.
Click to hide internal directories.