Documentation ¶
Index ¶
- Constants
- Variables
- func GetDiceClientToken() (ucauth.OAuthToken, error)
- func MkSessionKey(sessionID string) string
- func NewUCTokenClient(req *ucauth.NewClientRequest) (*ucauth.NewClientResponse, error)
- func VerifyUCClientToken(token string) (ucauth.TokenClient, error)
- type Auth
- type AuthResult
- type GetUserState
- type ScopeInfo
- type SetUserState
- type TokenClient
- type User
- func (u *User) GetInfo(req *http.Request) (ucauth.UserInfo, AuthResult)
- func (u *User) GetScopeInfo(req *http.Request) (ScopeInfo, AuthResult)
- func (u *User) IsLogin(req *http.Request, spec *apispec.Spec) 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 *ucauth.NewClientRequest) (*ucauth.NewClientResponse, error)
func VerifyUCClientToken ¶
func VerifyUCClientToken(token string) (ucauth.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 AuthResult ¶
type GetUserState ¶
type GetUserState int
const ( GetInit GetUserState = iota GotSessionID GotToken GotInfo GotScopeInfo )
type TokenClient ¶
func VerifyOpenapiOAuth2Token ¶
func VerifyOpenapiOAuth2Token(o *oauth2.OAuth2Server, spec *spec.Spec, r *http.Request) (TokenClient, error)
Click to show internal directories.
Click to hide internal directories.