Documentation ¶
Index ¶
- Variables
- type Auth0Provider
- func (p *Auth0Provider) AuthCodeURL(csrfToken string) string
- func (p *Auth0Provider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
- func (p *Auth0Provider) GetProviderName() string
- func (p *Auth0Provider) LogoutURL(returnTo string) string
- func (p *Auth0Provider) Refresh(ctx context.Context, refreshToken string) (*Token, error)
- type Config
- type GenericProvider
- func (p *GenericProvider) AuthCodeURL(csrfToken string) string
- func (p *GenericProvider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
- func (p *GenericProvider) GetProviderName() string
- func (p *GenericProvider) LogoutURL(returnTo string) string
- func (p *GenericProvider) Refresh(ctx context.Context, refreshToken string) (*Token, error)
- type GitHubProvider
- func (p *GitHubProvider) AuthCodeURL(csrfToken string) string
- func (p *GitHubProvider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
- func (p *GitHubProvider) GetProviderName() string
- func (p *GitHubProvider) Refresh(ctx context.Context, refreshToken string) (*Token, error)
- type Provider
- type TestProvider
- func (p *TestProvider) AuthCodeURL(csrfToken string) string
- func (p *TestProvider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
- func (p *TestProvider) GetProviderName() string
- func (p *TestProvider) HandleAccessToken(ctx *fasthttp.RequestCtx)
- func (p *TestProvider) HandleAuthorizationCode(ctx *fasthttp.RequestCtx)
- func (p *TestProvider) HandleJWKs(ctx *fasthttp.RequestCtx)
- func (p *TestProvider) Refresh(ctx context.Context, refreshToken string) (*Token, error)
- type Token
Constants ¶
This section is empty.
Variables ¶
var DeviceAccessToken = "123"
var DeviceExpiresIn = time.Minute * 60
var DeviceUserID = "1"
var UserToken = ""
Functions ¶
This section is empty.
Types ¶
type Auth0Provider ¶
Auth0Provider configuration with new http client
func NewAuth0Provider ¶
func NewAuth0Provider(config Config) *Auth0Provider
NewAuth0Provider creates OAuth client
func (*Auth0Provider) AuthCodeURL ¶
func (p *Auth0Provider) AuthCodeURL(csrfToken string) string
AuthCodeURL returns URL for redirecting to the authentication web page
func (*Auth0Provider) Exchange ¶
func (p *Auth0Provider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
Exchange Auth Code for Access Token via OAuth
func (*Auth0Provider) GetProviderName ¶
func (p *Auth0Provider) GetProviderName() string
GetProviderName returns unique name of the provider
func (*Auth0Provider) LogoutURL ¶
func (p *Auth0Provider) LogoutURL(returnTo string) string
LogoutURL to logout the user
type Config ¶
type Config struct { Provider string `envconfig:"PROVIDER" env:"PROVIDER" default:"generic"` // value which comes from the device during the sign-up ("apn") OAuth2 oauth.Config `envconfig:"OAUTH" env:"OAUTH"` }
Config general configuration
type GenericProvider ¶
type GenericProvider struct { Config Config OAuth2 *oauth2.Config NewHTTPClient func() *http.Client }
GenericProvider configuration with new http client
func NewGenericProvider ¶
func NewGenericProvider(config Config) *GenericProvider
NewGenericProvider creates OAuth client
func (*GenericProvider) AuthCodeURL ¶
func (p *GenericProvider) AuthCodeURL(csrfToken string) string
AuthCodeURL returns URL for redirecting to the authentication web page
func (*GenericProvider) Exchange ¶
func (p *GenericProvider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
Exchange Auth Code for Access Token via OAuth
func (*GenericProvider) GetProviderName ¶
func (p *GenericProvider) GetProviderName() string
GetProviderName returns unique name of the provider
func (*GenericProvider) LogoutURL ¶
func (p *GenericProvider) LogoutURL(returnTo string) string
LogoutURL to logout the user
type GitHubProvider ¶
type GitHubProvider struct { Config Config OAuth2 *oauth2.Config NewGithubClient func(*http.Client) *github.Client NewHTTPClient func() *http.Client }
GitHubProvider configuration with client factories
func NewGitHubProvider ¶
func NewGitHubProvider(config Config) *GitHubProvider
NewGitHubProvider creates GitHub OAuth client
func (*GitHubProvider) AuthCodeURL ¶
func (p *GitHubProvider) AuthCodeURL(csrfToken string) string
AuthCodeURL returns URL for redirecting to the GitHub authentication web page.
func (*GitHubProvider) Exchange ¶
func (p *GitHubProvider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
Exchange Auth Code for Access Token via OAuth.
func (*GitHubProvider) GetProviderName ¶
func (p *GitHubProvider) GetProviderName() string
GetProviderName returns unique name of the provider
type Provider ¶
type Provider = interface { Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error) Refresh(ctx context.Context, refreshToken string) (*Token, error) AuthCodeURL(csrfToken string) string }
Provider defines interface for authentification against auth service
type TestProvider ¶
type TestProvider struct { }
TestProvider basic configuration.
func NewTestProvider ¶
func NewTestProvider() *TestProvider
NewTestProvider creates GitHub Oauth client.
func (*TestProvider) AuthCodeURL ¶
func (p *TestProvider) AuthCodeURL(csrfToken string) string
AuthCodeURL returns URL for redirecting.
func (*TestProvider) Exchange ¶
func (p *TestProvider) Exchange(ctx context.Context, authorizationProvider, authorizationCode string) (*Token, error)
Exchange Auth Code for Access Token via OAuth.
func (*TestProvider) GetProviderName ¶
func (p *TestProvider) GetProviderName() string
GetProviderName provides provider name.
func (*TestProvider) HandleAccessToken ¶
func (p *TestProvider) HandleAccessToken(ctx *fasthttp.RequestCtx)
func (*TestProvider) HandleAuthorizationCode ¶
func (p *TestProvider) HandleAuthorizationCode(ctx *fasthttp.RequestCtx)
func (*TestProvider) HandleJWKs ¶
func (p *TestProvider) HandleJWKs(ctx *fasthttp.RequestCtx)