Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // oauth2 err https://tools.ietf.org/html/rfc6749#section-5.2 ErrInvalidRequest = NewError(http.StatusBadRequest, "invalid_request", "The request is missing a required parameter, includes an unsupported parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.") ErrAccessDenied = NewError(http.StatusUnauthorized, "access_denied", "The resource owner or authorization server denied the request") ErrUnsupportedResponseType = NewError(http.StatusUnauthorized, "unsupported_response_type", "The authorization server does not support obtaining an authorization code or an access token using this method") ErrInvalidScope = NewError(http.StatusBadRequest, "invalid_scope", "The requested scope is invalid, unknown, or malformed") ErrServerError = NewError(http.StatusInternalServerError, "server_error", "The authorization server encountered an unexpected condition that prevented it from fulfilling the request") ErrInvalidClient = NewError(http.StatusBadRequest, "invalid_client", "Client authentication failed") ErrInvalidGrant = NewError(http.StatusUnauthorized, "invalid_grant", "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client") ErrUnsupportedGrantType = NewError(http.StatusUnauthorized, "unsupported_grant_type", "The authorization grant type is not supported by the authorization server") // extra customized errors ErrInvalidRedirectURI = NewError(http.StatusBadRequest, "invalid_redirect_uri", "The request is missing redirect uri or includes an invalid redirect uri value") ErrInvalidAuthorizeCode = NewError(http.StatusBadRequest, "invalid_authorize_code", "The request is missing authorize code or includes an invalid authorize code value") ErrInvalidAccessToken = NewError(http.StatusBadRequest, "invalid_access_token", "The request is missing access token or includes an invalid access token value") ErrInvalidRefreshToken = NewError(http.StatusBadRequest, "invalid_refresh_token", "The request is missing refresh token or includes an invalid refresh token value") ErrExpiredAuthorizeCode = NewError(http.StatusBadRequest, "expired_authorize_code", "The request includes an expired authorize code value") ErrExpiredAccessToken = NewError(http.StatusBadRequest, "expired_access_token", "The request includes an expired access token value") ErrExpiredRefreshToken = NewError(http.StatusBadRequest, "expired_refresh_token", "The request includes an expired refresh token value") ErrInvalidUsernameOrPassword = NewError(http.StatusBadRequest, "invalid_username_or_password", "The request includes invalid username or password") )
View Source
var DefaultOauth2Config = Config{ TokenType: "Bearer", RedirectUriSep: "|", RedirectAllowEmpty: false, AllowGrantType: map[GrantType]GrantTypeConfig{ AuthorizationCode: { AccessTokenExpire: 12 * 3600, RefreshTokenExpire: 72 * 3600, CodeExpire: 300, IsGenerateRefresh: true, IsResetRefreshTime: false, }, Implicit: { AccessTokenExpire: 6 * 3600, IsGenerateRefresh: false, IsResetRefreshTime: false, }, PasswordCredentials: { AccessTokenExpire: 6 * 3600, IsGenerateRefresh: false, IsResetRefreshTime: false, }, ClientCredentials: { AccessTokenExpire: 6 * 3600, IsGenerateRefresh: false, IsResetRefreshTime: false, }, RefreshToken: { AccessTokenExpire: 12 * 3600, RefreshTokenExpire: 72 * 3600, IsGenerateRefresh: true, IsResetRefreshTime: false, }, }, ManagerConfig: ManagerConfig{ TokenGcInterval: 7 * 24 * 3600, TokenStoreName: "mem", GeneratorName: "default", TokenStoreConfig: "", }, }
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { TokenType string RedirectUriSep string RedirectAllowEmpty bool AllowGrantType map[GrantType]GrantTypeConfig ManagerConfig ManagerConfig }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type GrantTypeConfig ¶
type ManagerConfig ¶
type Oauth2Error ¶
type Oauth2Error struct {
// contains filtered or unexported fields
}
func (Oauth2Error) Error ¶
func (e Oauth2Error) Error() string
func (Oauth2Error) ErrorDescription ¶
func (e Oauth2Error) ErrorDescription() string
func (Oauth2Error) StatusCode ¶
func (e Oauth2Error) StatusCode() int
type Response ¶
type Response struct { Error error ErrorCode int Description string Uri string StatusCode int Header http.Header }
Response error response
type ResponseType ¶
type ResponseType string
const ( Token ResponseType = "token" Code ResponseType = "code" )
func (ResponseType) IsValid ¶
func (rt ResponseType) IsValid() bool
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
Click to show internal directories.
Click to hide internal directories.