Documentation ¶
Index ¶
- Constants
- type AuthorizedClient
- type GithubValidator
- type GithubValidatorRequest
- type GithubValidatorResponse
- type Provider
- func (p Provider) AddValidator(providerType ProviderType, validator Validator)
- func (p Provider) AuthenticateUser(providerType ProviderType) (client *AuthorizedClient, err error)
- func (p Provider) CallbackHandler(ctx context.Context, clientChan chan *AuthorizedClient, ...) func(w http.ResponseWriter, r *http.Request)
- func (p Provider) ErrorHandler() func(w http.ResponseWriter, r *http.Request)
- func (p Provider) GetValidator(providerType ProviderType) (Validator, error)
- func (p Provider) ValidateAccessToken(providerType ProviderType, accessToken string) error
- func (p Provider) ValidateToken(providerType ProviderType, token *oauth2.Token) (*oauth2.Token, error)
- type ProviderType
- type Validator
Constants ¶
const (
// AuthorizationPrefix is authorization prefix
AuthorizationPrefix = "Bearer"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizedClient ¶
AuthorizedClient is authorized client and token
type GithubValidator ¶ added in v1.2.4
type GithubValidator struct {
// contains filtered or unexported fields
}
GithubValidator is github oauth validator
func NewGithubValidator ¶ added in v1.2.4
func NewGithubValidator(client *http.Client, clientID, clientSecret string, scopes []string) *GithubValidator
NewGithubValidator creates new github validator
func (GithubValidator) GetEndpoint ¶ added in v1.2.4
func (v GithubValidator) GetEndpoint() oauth2.Endpoint
GetEndpoint returns endpoint
func (GithubValidator) Validate ¶ added in v1.2.4
func (v GithubValidator) Validate(accessToken string) error
Validate validates oauth token
type GithubValidatorRequest ¶ added in v1.2.4
type GithubValidatorRequest struct {
AccessToken string `json:"access_token"`
}
GithubValidatorRequest contains github validation request
type GithubValidatorResponse ¶ added in v1.2.4
type GithubValidatorResponse struct { ExpiresAt *time.Time `json:"expires_at"` Scopes []string `json:"scopes"` }
GithubValidatorResponse contains github validation response
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider contains oauth provider config
func NewProvider ¶
NewProvider returns new provider
func (Provider) AddValidator ¶ added in v1.2.4
func (p Provider) AddValidator(providerType ProviderType, validator Validator)
AddValidator adds validator
func (Provider) AuthenticateUser ¶
func (p Provider) AuthenticateUser(providerType ProviderType) (client *AuthorizedClient, err error)
AuthenticateUser starts the login process
func (Provider) CallbackHandler ¶
func (p Provider) CallbackHandler(ctx context.Context, clientChan chan *AuthorizedClient, providerType ProviderType) func(w http.ResponseWriter, r *http.Request)
CallbackHandler is oauth callback handler
func (Provider) ErrorHandler ¶
func (p Provider) ErrorHandler() func(w http.ResponseWriter, r *http.Request)
ErrorHandler is oauth error handler
func (Provider) GetValidator ¶ added in v1.2.4
func (p Provider) GetValidator(providerType ProviderType) (Validator, error)
GetValidator returns validator
func (Provider) ValidateAccessToken ¶ added in v1.2.4
func (p Provider) ValidateAccessToken(providerType ProviderType, accessToken string) error
ValidateAccessToken validates access token
func (Provider) ValidateToken ¶
func (p Provider) ValidateToken(providerType ProviderType, token *oauth2.Token) (*oauth2.Token, error)
ValidateToken validates token
type ProviderType ¶ added in v1.2.4
type ProviderType string
ProviderType is provider type
const ( // GithubProviderType is github provider type GithubProviderType ProviderType = "github" )