Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultAccessTokenGenerator() (code string)
- func DefaultAuthCodeGenerator() (code string)
- func DefaultRefreshTokenGenerator() (code string)
- func SimpleRandomTokenGenerator(size int) string
- type AccessHandler
- type AccessHandlers
- type AccessToken
- type AuthHandler
- type AuthHandlers
- type Authorize
- type Client
- type Config
- type Error
- type ErrorCode
- type GrantType
- type OAuth
- func (a *OAuth) AccessTokenRequestHandler(w http.ResponseWriter, r *http.Request)
- func (a *OAuth) AuthorizeRequestHandler(w http.ResponseWriter, r *http.Request)
- func (a *OAuth) Close()
- func (a *OAuth) ConnectClientToCode(code string, client Client) error
- func (a *OAuth) RedirectAuthorize(w http.ResponseWriter, r *http.Request, v url.Values)
- func (a *OAuth) VerifyAccess(w http.ResponseWriter, r *http.Request) (Client, error)
- type RefreshToken
- type ResourceOwner
- type ResponseType
- type Scopes
- type Storage
- type TokenType
Constants ¶
View Source
const ( GrantRefreshToken GrantType = "refresh_token" GrantAuthCode = "authorization_code" GrantPassword = "password" GrantClientCredentials = "client_credentials" )
View Source
const ( ErrorCodeInvalidRequest ErrorCode = "invalid_request" ErrorCodeUnsupportedGrantType = "unsupported_grant_type" ErrorCodeUnsupportedResponseType = "unsupported_response_type" ErrorCodeAccessDenied = "access_denied" ErrorCodeInvalidScope = "invalid_scope" ErrorCodeServerError = "server_error" )
Variables ¶
View Source
var ( ErrorGrantTypeMissing = &Error{ Error: ErrorCodeInvalidRequest, ErrorDescription: "Required parameter is missing: grant_type", } ErrorResponseTypeMissing = &Error{ Error: ErrorCodeInvalidRequest, ErrorDescription: "Required parameter is missing: response_type", } ErrorClientIdMissing = &Error{ Error: ErrorCodeInvalidRequest, ErrorDescription: "Required parameter is missing: client_id", } Error: ErrorCodeInvalidScope, ErrorDescription: "Unknown scope(s) have been included in the request", } ErrorUnsupportedGrantType = &Error{ Error: ErrorCodeUnsupportedGrantType, ErrorDescription: "This grant type is not supported", } ErrorUnsupportedResponseType = &Error{ Error: ErrorCodeUnsupportedResponseType, ErrorDescription: "The authorization server does not support obtaining an authorization code using this method", } ErrorClientNotFound = &Error{ Error: ErrorCodeInvalidRequest, ErrorDescription: "The OAuth client was not found.", } ErrorRefreshTokenInvalid = &Error{ Error: ErrorCodeInvalidRequest, ErrorDescription: "The refresh token is invalid.", } )
View Source
var DefaultConfig = NewConfig()
Functions ¶
func DefaultAccessTokenGenerator ¶
func DefaultAccessTokenGenerator() (code string)
func DefaultAuthCodeGenerator ¶
func DefaultAuthCodeGenerator() (code string)
func DefaultRefreshTokenGenerator ¶
func DefaultRefreshTokenGenerator() (code string)
Types ¶
type AccessHandlers ¶
type AccessHandlers map[GrantType]AccessHandler
type AccessToken ¶
type AuthHandler ¶
type AuthHandler func(*OAuth, http.ResponseWriter, *http.Request)
type AuthHandlers ¶
type AuthHandlers map[ResponseType]AuthHandler
type Config ¶
type Config struct { Storage Storage Owner ResourceOwner AuthorizeExpires time.Duration AccessTokenExpires time.Duration AuthorizeGenerator func() string AccessTokenGenerator func() string RefreshTokenGenerator func() string AuthorizeEndpoint string AccessTokenEndpoint string RedirectEndpoint string AuthHandlers AuthHandlers AccessHandlers AccessHandlers TokenType TokenType AvailableScopes Scopes // contains filtered or unexported fields }
type Error ¶
type Error struct { Error ErrorCode `json:"error"` ErrorDescription string `json:"error_description"` ErrorUri string `json:"error_uri"` State string `json:"state"` }
func (*Error) Write ¶
func (e *Error) Write(w http.ResponseWriter)
type OAuth ¶
type OAuth struct {
// contains filtered or unexported fields
}
func (*OAuth) AccessTokenRequestHandler ¶
func (a *OAuth) AccessTokenRequestHandler(w http.ResponseWriter, r *http.Request)
func (*OAuth) AuthorizeRequestHandler ¶
func (a *OAuth) AuthorizeRequestHandler(w http.ResponseWriter, r *http.Request)
func (*OAuth) ConnectClientToCode ¶
func (*OAuth) RedirectAuthorize ¶
func (*OAuth) VerifyAccess ¶
type RefreshToken ¶
type RefreshToken interface {
GetClient() Client
}
type ResourceOwner ¶
type ResourceOwner interface { ExistClientId(id string) bool GetClient(id, secret string) Client GetClientWithPasswordGrant(username, password string) Client GetRedirectUri(clientId string) string Close() AuthCodeDecision(r *http.Request, clientId string) Client AuthCodeMissing(w http.ResponseWriter, r *http.Request) }
type ResponseType ¶
type ResponseType string
const ( ResponseCode ResponseType = "code" ResponseToken = "token" )
type Scopes ¶
type Scopes []string
func ParseScopes ¶
func (Scopes) ContainScope ¶
func (Scopes) ContainScopes ¶
type Storage ¶
type Storage interface { AddAuthorize(code string, auth Authorize) GetAuthorize(code string) Authorize DisableAuthorize(id string) AddAccessToken(token string, access AccessToken) GetAccessToken(token string) AccessToken AddRefreshToken(token string, refresh RefreshToken) GetRefreshToken(token string) RefreshToken DisableRefreshToken(token string) }
func NewMemoryStorage ¶
func NewMemoryStorage() Storage
Source Files ¶
Click to show internal directories.
Click to hide internal directories.