Documentation
¶
Index ¶
- Constants
- Variables
- type Apple
- type AuthUser
- type BaseProvider
- func (p *BaseProvider) AuthURL() string
- func (p *BaseProvider) BuildAuthURL(state string, opts ...oauth2.AuthCodeOption) string
- func (p *BaseProvider) Client(token *oauth2.Token) *http.Client
- func (p *BaseProvider) ClientId() string
- func (p *BaseProvider) ClientSecret() string
- func (p *BaseProvider) Context() context.Context
- func (p *BaseProvider) DisplayName() string
- func (p *BaseProvider) Extra() map[string]any
- func (p *BaseProvider) FetchRawUserInfo(token *oauth2.Token) ([]byte, error)
- func (p *BaseProvider) FetchToken(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
- func (p *BaseProvider) PKCE() bool
- func (p *BaseProvider) RedirectURL() string
- func (p *BaseProvider) Scopes() []string
- func (p *BaseProvider) SetAuthURL(url string)
- func (p *BaseProvider) SetClientId(clientId string)
- func (p *BaseProvider) SetClientSecret(secret string)
- func (p *BaseProvider) SetContext(ctx context.Context)
- func (p *BaseProvider) SetDisplayName(displayName string)
- func (p *BaseProvider) SetExtra(data map[string]any)
- func (p *BaseProvider) SetPKCE(enable bool)
- func (p *BaseProvider) SetRedirectURL(url string)
- func (p *BaseProvider) SetScopes(scopes []string)
- func (p *BaseProvider) SetTokenURL(url string)
- func (p *BaseProvider) SetUserInfoURL(url string)
- func (p *BaseProvider) TokenURL() string
- func (p *BaseProvider) UserInfoURL() string
- type Bitbucket
- type Box
- type Discord
- type Facebook
- type Gitea
- type Gitee
- type Github
- type Gitlab
- type Google
- type Instagram
- type Kakao
- type Lark
- type Linear
- type Livechat
- type Mailcow
- type Microsoft
- type Monday
- type Notion
- type OIDC
- type Patreon
- type Planningcenter
- type Provider
- type ProviderFactoryFunc
- type Spotify
- type Strava
- type Trakt
- type Twitch
- type Twitter
- type VK
- type Wakatime
- type Yandex
Constants ¶
const NameApple string = "apple"
NameApple is the unique name of the Apple provider.
const NameBitbucket = "bitbucket"
NameBitbucket is the unique name of the Bitbucket provider.
const NameBox = "box"
NameBox is the unique name of the Box provider.
const NameDiscord string = "discord"
NameDiscord is the unique name of the Discord provider.
const NameFacebook string = "facebook"
NameFacebook is the unique name of the Facebook provider.
const NameGitea string = "gitea"
NameGitea is the unique name of the Gitea provider.
const NameGitee string = "gitee"
NameGitee is the unique name of the Gitee provider.
const NameGithub string = "github"
NameGithub is the unique name of the Github provider.
const NameGitlab string = "gitlab"
NameGitlab is the unique name of the Gitlab provider.
const NameGoogle string = "google"
NameGoogle is the unique name of the Google provider.
const NameInstagram string = "instagram2" // "2" suffix to avoid conflicts with the old deprecated version
NameInstagram is the unique name of the Instagram provider.
const NameKakao string = "kakao"
NameKakao is the unique name of the Kakao provider.
const NameLark string = "lark"
NameLark is the unique name of the Lark provider.
const NameLinear string = "linear"
NameLinear is the unique name of the Linear provider.
const NameLivechat = "livechat"
NameLivechat is the unique name of the Livechat provider.
const NameMailcow string = "mailcow"
NameMailcow is the unique name of the mailcow provider.
const NameMicrosoft string = "microsoft"
NameMicrosoft is the unique name of the Microsoft provider.
const NameMonday = "monday"
NameMonday is the unique name of the Monday provider.
const NameNotion string = "notion"
NameNotion is the unique name of the Notion provider.
const NameOIDC string = "oidc"
NameOIDC is the unique name of the OpenID Connect (OIDC) provider.
const NamePatreon string = "patreon"
NamePatreon is the unique name of the Patreon provider.
const NamePlanningcenter string = "planningcenter"
NamePlanningcenter is the unique name of the Planningcenter provider.
const NameSpotify string = "spotify"
NameSpotify is the unique name of the Spotify provider.
const NameStrava string = "strava"
NameStrava is the unique name of the Strava provider.
const NameTrakt string = "trakt"
NameTrakt is the unique name of the Trakt provider.
const NameTwitch string = "twitch"
NameTwitch is the unique name of the Twitch provider.
const NameTwitter string = "twitter"
NameTwitter is the unique name of the Twitter provider.
const NameVK string = "vk"
NameVK is the unique name of the VK provider.
const NameWakatime = "wakatime"
NameWakatime is the unique name of the Wakatime provider.
const NameYandex string = "yandex"
NameYandex is the unique name of the Yandex provider.
Variables ¶
var Providers = map[string]ProviderFactoryFunc{}
Providers defines a map with all of the available OAuth2 providers.
To register a new provider append a new entry in the map.
Functions ¶
This section is empty.
Types ¶
type Apple ¶ added in v0.14.0
type Apple struct {
BaseProvider
// contains filtered or unexported fields
}
Apple allows authentication via Apple OAuth2.
OIDC differences: https://bitbucket.org/openid/connect/src/master/How-Sign-in-with-Apple-differs-from-OpenID-Connect.md.
func NewAppleProvider ¶ added in v0.14.0
func NewAppleProvider() *Apple
NewAppleProvider creates a new Apple provider instance with some defaults.
func (*Apple) FetchAuthUser ¶ added in v0.14.0
FetchAuthUser returns an AuthUser instance based on the provided token.
func (*Apple) FetchRawUserInfo ¶ added in v0.23.0
FetchRawUserInfo implements Provider.FetchRawUserInfo interface.
Note that Apple doesn't have a UserInfo endpoint and claims about the users are included in the id_token (without the name - see #7090).
type AuthUser ¶
type AuthUser struct {
Expiry types.DateTime `json:"expiry"`
RawUser map[string]any `json:"rawUser"`
Id string `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
Email string `json:"email"`
AvatarURL string `json:"avatarURL"`
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
// @todo
// deprecated: use AvatarURL instead
// AvatarUrl will be removed after dropping v0.22 support
AvatarUrl string `json:"avatarUrl"`
}
AuthUser defines a standardized OAuth2 user data structure.
func (AuthUser) MarshalJSON ¶ added in v0.23.0
MarshalJSON implements the json.Marshaler interface.
@todo remove after dropping v0.22 support
type BaseProvider ¶ added in v0.23.0
type BaseProvider struct {
// contains filtered or unexported fields
}
BaseProvider defines common fields and methods used by OAuth2 client providers.
func (*BaseProvider) AuthURL ¶ added in v0.23.0
func (p *BaseProvider) AuthURL() string
AuthURL implements Provider.AuthURL() interface method.
func (*BaseProvider) BuildAuthURL ¶ added in v0.23.0
func (p *BaseProvider) BuildAuthURL(state string, opts ...oauth2.AuthCodeOption) string
BuildAuthURL implements Provider.BuildAuthURL() interface method.
func (*BaseProvider) Client ¶ added in v0.23.0
func (p *BaseProvider) Client(token *oauth2.Token) *http.Client
Client implements Provider.Client() interface method.
func (*BaseProvider) ClientId ¶ added in v0.23.0
func (p *BaseProvider) ClientId() string
ClientId implements Provider.ClientId() interface method.
func (*BaseProvider) ClientSecret ¶ added in v0.23.0
func (p *BaseProvider) ClientSecret() string
ClientSecret implements Provider.ClientSecret() interface method.
func (*BaseProvider) Context ¶ added in v0.23.0
func (p *BaseProvider) Context() context.Context
Context implements Provider.Context() interface method.
func (*BaseProvider) DisplayName ¶ added in v0.23.0
func (p *BaseProvider) DisplayName() string
DisplayName implements Provider.DisplayName() interface method.
func (*BaseProvider) Extra ¶ added in v0.23.0
func (p *BaseProvider) Extra() map[string]any
Extra implements Provider.Extra() interface method.
func (*BaseProvider) FetchRawUserInfo ¶ added in v0.23.0
func (p *BaseProvider) FetchRawUserInfo(token *oauth2.Token) ([]byte, error)
FetchRawUserInfo implements Provider.FetchRawUserInfo() interface method.
func (*BaseProvider) FetchToken ¶ added in v0.23.0
func (p *BaseProvider) FetchToken(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
FetchToken implements Provider.FetchToken() interface method.
func (*BaseProvider) PKCE ¶ added in v0.23.0
func (p *BaseProvider) PKCE() bool
PKCE implements Provider.PKCE() interface method.
func (*BaseProvider) RedirectURL ¶ added in v0.23.0
func (p *BaseProvider) RedirectURL() string
RedirectURL implements Provider.RedirectURL() interface method.
func (*BaseProvider) Scopes ¶ added in v0.23.0
func (p *BaseProvider) Scopes() []string
Scopes implements Provider.Scopes() interface method.
func (*BaseProvider) SetAuthURL ¶ added in v0.23.0
func (p *BaseProvider) SetAuthURL(url string)
SetAuthURL implements Provider.SetAuthURL() interface method.
func (*BaseProvider) SetClientId ¶ added in v0.23.0
func (p *BaseProvider) SetClientId(clientId string)
SetClientId implements Provider.SetClientId() interface method.
func (*BaseProvider) SetClientSecret ¶ added in v0.23.0
func (p *BaseProvider) SetClientSecret(secret string)
SetClientSecret implements Provider.SetClientSecret() interface method.
func (*BaseProvider) SetContext ¶ added in v0.23.0
func (p *BaseProvider) SetContext(ctx context.Context)
SetContext implements Provider.SetContext() interface method.
func (*BaseProvider) SetDisplayName ¶ added in v0.23.0
func (p *BaseProvider) SetDisplayName(displayName string)
SetDisplayName implements Provider.SetDisplayName() interface method.
func (*BaseProvider) SetExtra ¶ added in v0.23.0
func (p *BaseProvider) SetExtra(data map[string]any)
SetExtra implements Provider.SetExtra() interface method.
func (*BaseProvider) SetPKCE ¶ added in v0.23.0
func (p *BaseProvider) SetPKCE(enable bool)
SetPKCE implements Provider.SetPKCE() interface method.
func (*BaseProvider) SetRedirectURL ¶ added in v0.23.0
func (p *BaseProvider) SetRedirectURL(url string)
SetRedirectURL implements Provider.SetRedirectURL() interface method.
func (*BaseProvider) SetScopes ¶ added in v0.23.0
func (p *BaseProvider) SetScopes(scopes []string)
SetScopes implements Provider.SetScopes() interface method.
func (*BaseProvider) SetTokenURL ¶ added in v0.23.0
func (p *BaseProvider) SetTokenURL(url string)
SetTokenURL implements Provider.SetTokenURL() interface method.
func (*BaseProvider) SetUserInfoURL ¶ added in v0.23.0
func (p *BaseProvider) SetUserInfoURL(url string)
SetUserInfoURL implements Provider.SetUserInfoURL() interface method.
func (*BaseProvider) TokenURL ¶ added in v0.23.0
func (p *BaseProvider) TokenURL() string
TokenURL implements Provider.TokenURL() interface method.
func (*BaseProvider) UserInfoURL ¶ added in v0.23.0
func (p *BaseProvider) UserInfoURL() string
UserInfoURL implements Provider.UserInfoURL() interface method.
type Bitbucket ¶ added in v0.21.0
type Bitbucket struct {
BaseProvider
}
Bitbucket is an auth provider for Bitbucket.
func NewBitbucketProvider ¶ added in v0.21.0
func NewBitbucketProvider() *Bitbucket
NewBitbucketProvider creates a new Bitbucket provider instance with some defaults.
func (*Bitbucket) FetchAuthUser ¶ added in v0.21.0
FetchAuthUser returns an AuthUser instance based on the Bitbucket's user API.
API reference: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-user-get
type Box ¶ added in v0.29.1
type Box struct {
BaseProvider
}
Box is an auth provider for Box.
func NewBoxProvider ¶ added in v0.29.1
func NewBoxProvider() *Box
NewBoxProvider creates a new Box provider instance with some defaults.
func (*Box) FetchAuthUser ¶ added in v0.29.1
FetchAuthUser returns an AuthUser instance based on the Box's user API.
API reference: https://developer.box.com/reference/get-users-me/
type Discord ¶ added in v0.6.0
type Discord struct {
BaseProvider
}
Discord allows authentication via Discord OAuth2.
func NewDiscordProvider ¶ added in v0.6.0
func NewDiscordProvider() *Discord
NewDiscordProvider creates a new Discord provider instance with some defaults.
func (*Discord) FetchAuthUser ¶ added in v0.6.0
FetchAuthUser returns an AuthUser instance from Discord's user api.
API reference: https://discord.com/developers/docs/resources/user#user-object
type Facebook ¶
type Facebook struct {
BaseProvider
}
Facebook allows authentication via Facebook OAuth2.
func NewFacebookProvider ¶
func NewFacebookProvider() *Facebook
NewFacebookProvider creates new Facebook provider instance with some defaults.
func (*Facebook) FetchAuthUser ¶
FetchAuthUser returns an AuthUser instance based on the Facebook's user api.
API reference: https://developers.facebook.com/docs/graph-api/reference/user/
type Gitea ¶ added in v0.12.0
type Gitea struct {
BaseProvider
}
Gitea allows authentication via Gitea OAuth2.
func NewGiteaProvider ¶ added in v0.12.0
func NewGiteaProvider() *Gitea
NewGiteaProvider creates new Gitea provider instance with some defaults.
func (*Gitea) FetchAuthUser ¶ added in v0.12.0
FetchAuthUser returns an AuthUser instance based on Gitea's user api.
API reference: https://try.gitea.io/api/swagger#/user/userGetCurrent
type Gitee ¶ added in v0.11.0
type Gitee struct {
BaseProvider
}
Gitee allows authentication via Gitee OAuth2.
func NewGiteeProvider ¶ added in v0.11.0
func NewGiteeProvider() *Gitee
NewGiteeProvider creates new Gitee provider instance with some defaults.
func (*Gitee) FetchAuthUser ¶ added in v0.11.0
FetchAuthUser returns an AuthUser instance based the Gitee's user api.
API reference: https://gitee.com/api/v5/swagger#/getV5User
type Github ¶
type Github struct {
BaseProvider
}
Github allows authentication via Github OAuth2.
func NewGithubProvider ¶
func NewGithubProvider() *Github
NewGithubProvider creates new Github provider instance with some defaults.
func (*Github) FetchAuthUser ¶
FetchAuthUser returns an AuthUser instance based the Github's user api.
API reference: https://docs.github.com/en/rest/reference/users#get-the-authenticated-user
type Gitlab ¶
type Gitlab struct {
BaseProvider
}
Gitlab allows authentication via Gitlab OAuth2.
func NewGitlabProvider ¶
func NewGitlabProvider() *Gitlab
NewGitlabProvider creates new Gitlab provider instance with some defaults.
func (*Gitlab) FetchAuthUser ¶
FetchAuthUser returns an AuthUser instance based the Gitlab's user api.
API reference: https://docs.gitlab.com/ee/api/users.html#for-admin
type Google ¶
type Google struct {
BaseProvider
}
Google allows authentication via Google OAuth2.
func NewGoogleProvider ¶
func NewGoogleProvider() *Google
NewGoogleProvider creates new Google provider instance with some defaults.
type Instagram ¶ added in v0.17.0
type Instagram struct {
BaseProvider
}
Instagram allows authentication via Instagram Login OAuth2.
func NewInstagramProvider ¶ added in v0.17.0
func NewInstagramProvider() *Instagram
NewInstagramProvider creates new Instagram provider instance with some defaults.
func (*Instagram) FetchAuthUser ¶ added in v0.17.0
FetchAuthUser returns an AuthUser instance based on the Instagram Login user api response.
API reference: https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login/get-started#fields
type Kakao ¶ added in v0.8.0
type Kakao struct {
BaseProvider
}
Kakao allows authentication via Kakao OAuth2.
func NewKakaoProvider ¶ added in v0.8.0
func NewKakaoProvider() *Kakao
NewKakaoProvider creates a new Kakao provider instance with some defaults.
func (*Kakao) FetchAuthUser ¶ added in v0.8.0
FetchAuthUser returns an AuthUser instance based on the Kakao's user api.
API reference: https://developers.kakao.com/docs/latest/en/kakaologin/rest-api#req-user-info-response
type Lark ¶ added in v0.30.0
type Lark struct {
BaseProvider
}
Lark allows authentication via Lark OAuth2.
func NewLarkProvider ¶ added in v0.30.0
func NewLarkProvider() *Lark
NewLarkProvider creates new Lark provider instance with some defaults.
func (*Lark) FetchAuthUser ¶ added in v0.30.0
FetchAuthUser returns an AuthUser instance based the Lark's user api.
API reference: https://open.feishu.cn/document/server-docs/authentication-management/login-state-management/get
type Linear ¶ added in v0.23.0
type Linear struct {
BaseProvider
}
Linear allows authentication via Linear OAuth2.
func NewLinearProvider ¶ added in v0.23.0
func NewLinearProvider() *Linear
NewLinearProvider creates new Linear provider instance with some defaults.
API reference: https://developers.linear.app/docs/oauth/authentication
func (*Linear) FetchAuthUser ¶ added in v0.23.0
FetchAuthUser returns an AuthUser instance based on the Linear's user api.
API reference: https://developers.linear.app/docs/graphql/working-with-the-graphql-api#authentication
func (*Linear) FetchRawUserInfo ¶ added in v0.23.0
FetchRawUserInfo implements Provider.FetchRawUserInfo interface method.
Linear doesn't have a UserInfo endpoint and information on the user is retrieved using their GraphQL API (https://developers.linear.app/docs/graphql/working-with-the-graphql-api#queries-and-mutations)
type Livechat ¶ added in v0.12.0
type Livechat struct {
BaseProvider
}
Livechat allows authentication via Livechat OAuth2.
func NewLivechatProvider ¶ added in v0.12.0
func NewLivechatProvider() *Livechat
NewLivechatProvider creates new Livechat provider instance with some defaults.
func (*Livechat) FetchAuthUser ¶ added in v0.12.0
FetchAuthUser returns an AuthUser based on the Livechat accounts API.
API reference: https://developers.livechat.com/docs/authorization
type Mailcow ¶ added in v0.19.0
type Mailcow struct {
BaseProvider
}
Mailcow allows authentication via mailcow OAuth2.
func NewMailcowProvider ¶ added in v0.19.0
func NewMailcowProvider() *Mailcow
NewMailcowProvider creates a new mailcow provider instance with some defaults.
func (*Mailcow) FetchAuthUser ¶ added in v0.19.0
FetchAuthUser returns an AuthUser instance based on mailcow's user api.
API reference: https://github.com/mailcow/mailcow-dockerized/blob/master/data/web/oauth/profile.php
type Microsoft ¶ added in v0.8.0
type Microsoft struct {
BaseProvider
}
Microsoft allows authentication via AzureADEndpoint OAuth2.
func NewMicrosoftProvider ¶ added in v0.8.0
func NewMicrosoftProvider() *Microsoft
NewMicrosoftProvider creates new Microsoft AD provider instance with some defaults.
func (*Microsoft) FetchAuthUser ¶ added in v0.8.0
FetchAuthUser returns an AuthUser instance based on the Microsoft's user api.
API reference: https://learn.microsoft.com/en-us/azure/active-directory/develop/userinfo Graph explorer: https://developer.microsoft.com/en-us/graph/graph-explorer
type Monday ¶ added in v0.23.0
type Monday struct {
BaseProvider
}
Monday is an auth provider for monday.com.
func NewMondayProvider ¶ added in v0.23.0
func NewMondayProvider() *Monday
NewMondayProvider creates a new Monday provider instance with some defaults.
func (*Monday) FetchAuthUser ¶ added in v0.23.0
FetchAuthUser returns an AuthUser instance based on the Monday's user api.
API reference: https://developer.monday.com/api-reference/reference/me
func (*Monday) FetchRawUserInfo ¶ added in v0.23.0
FetchRawUserInfo implements Provider.FetchRawUserInfo interface.
monday.com doesn't have a UserInfo endpoint and information on the user is retrieved using their GraphQL API (https://developer.monday.com/api-reference/reference/me#queries)
type Notion ¶ added in v0.23.0
type Notion struct {
BaseProvider
}
Notion allows authentication via Notion OAuth2.
func NewNotionProvider ¶ added in v0.23.0
func NewNotionProvider() *Notion
NewNotionProvider creates new Notion provider instance with some defaults.
func (*Notion) FetchAuthUser ¶ added in v0.23.0
FetchAuthUser returns an AuthUser instance based on the Notion's User api. API reference: https://developers.notion.com/reference/get-self
func (*Notion) FetchRawUserInfo ¶ added in v0.23.0
FetchRawUserInfo implements Provider.FetchRawUserInfo interface method.
This differ from BaseProvider because Notion requires a version header for all requests (https://developers.notion.com/reference/versioning).
type OIDC ¶ added in v0.13.0
type OIDC struct {
BaseProvider
}
OIDC allows authentication via OpenID Connect (OIDC) OAuth2 provider.
If specified the user data is fetched from the userInfoURL. Otherwise - from the id_token payload.
The provider support the following Extra config options:
- "jwksURL" - url to the keys to validate the id_token signature (optional and used only when reading the user data from the id_token)
- "issuers" - list of valid issuers for the iss id_token claim (optioanl and used only when reading the user data from the id_token)
func NewOIDCProvider ¶ added in v0.13.0
func NewOIDCProvider() *OIDC
NewOIDCProvider creates new OpenID Connect (OIDC) provider instance with some defaults.
func (*OIDC) FetchAuthUser ¶ added in v0.13.0
FetchAuthUser returns an AuthUser instance based the provider's user api.
API reference: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
type Patreon ¶ added in v0.19.0
type Patreon struct {
BaseProvider
}
Patreon allows authentication via Patreon OAuth2.
func NewPatreonProvider ¶ added in v0.19.0
func NewPatreonProvider() *Patreon
NewPatreonProvider creates new Patreon provider instance with some defaults.
func (*Patreon) FetchAuthUser ¶ added in v0.19.0
FetchAuthUser returns an AuthUser instance based on the Patreons's identity api.
API reference: https://docs.patreon.com/#get-api-oauth2-v2-identity https://docs.patreon.com/#user-v2
type Planningcenter ¶ added in v0.22.0
type Planningcenter struct {
BaseProvider
}
Planningcenter allows authentication via Planningcenter OAuth2.
func NewPlanningcenterProvider ¶ added in v0.22.0
func NewPlanningcenterProvider() *Planningcenter
NewPlanningcenterProvider creates a new Planningcenter provider instance with some defaults.
func (*Planningcenter) FetchAuthUser ¶ added in v0.22.0
func (p *Planningcenter) FetchAuthUser(token *oauth2.Token) (*AuthUser, error)
FetchAuthUser returns an AuthUser instance based on the Planningcenter's user api.
API reference: https://developer.planning.center/docs/#/overview/authentication
type Provider ¶
type Provider interface {
// Context returns the context associated with the provider (if any).
Context() context.Context
// SetContext assigns the specified context to the current provider.
SetContext(ctx context.Context)
// PKCE indicates whether the provider can use the PKCE flow.
PKCE() bool
// SetPKCE toggles the state whether the provider can use the PKCE flow or not.
SetPKCE(enable bool)
// DisplayName usually returns provider name as it is officially written
// and it could be used directly in the UI.
DisplayName() string
// SetDisplayName sets the provider's display name.
SetDisplayName(displayName string)
// Scopes returns the provider access permissions that will be requested.
Scopes() []string
// SetScopes sets the provider access permissions that will be requested later.
SetScopes(scopes []string)
// ClientId returns the provider client's app ID.
ClientId() string
// SetClientId sets the provider client's ID.
SetClientId(clientId string)
// ClientSecret returns the provider client's app secret.
ClientSecret() string
// SetClientSecret sets the provider client's app secret.
SetClientSecret(secret string)
// RedirectURL returns the end address to redirect the user
// going through the OAuth flow.
RedirectURL() string
// SetRedirectURL sets the provider's RedirectURL.
SetRedirectURL(url string)
// AuthURL returns the provider's authorization service url.
AuthURL() string
// SetAuthURL sets the provider's AuthURL.
SetAuthURL(url string)
// TokenURL returns the provider's token exchange service url.
TokenURL() string
// SetTokenURL sets the provider's TokenURL.
SetTokenURL(url string)
// UserInfoURL returns the provider's user info api url.
UserInfoURL() string
// SetUserInfoURL sets the provider's UserInfoURL.
SetUserInfoURL(url string)
// Extra returns a shallow copy of any custom config data
// that the provider may be need.
Extra() map[string]any
// SetExtra updates the provider's custom config data.
SetExtra(data map[string]any)
// Client returns an http client using the provided token.
Client(token *oauth2.Token) *http.Client
// BuildAuthURL returns a URL to the provider's consent page
// that asks for permissions for the required scopes explicitly.
BuildAuthURL(state string, opts ...oauth2.AuthCodeOption) string
// FetchToken converts an authorization code to token.
FetchToken(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
// FetchRawUserInfo requests and marshalizes into `result` the
// the OAuth user api response.
FetchRawUserInfo(token *oauth2.Token) ([]byte, error)
// FetchAuthUser is similar to FetchRawUserInfo, but normalizes and
// marshalizes the user api response into a standardized AuthUser struct.
FetchAuthUser(token *oauth2.Token) (user *AuthUser, err error)
}
Provider defines a common interface for an OAuth2 client.
func NewProviderByName ¶
NewProviderByName returns a new preconfigured provider instance by its name identifier.
type ProviderFactoryFunc ¶ added in v0.23.0
type ProviderFactoryFunc func() Provider
ProviderFactoryFunc defines a function for initializing a new OAuth2 provider.
type Spotify ¶ added in v0.8.0
type Spotify struct {
BaseProvider
}
Spotify allows authentication via Spotify OAuth2.
func NewSpotifyProvider ¶ added in v0.8.0
func NewSpotifyProvider() *Spotify
NewSpotifyProvider creates a new Spotify provider instance with some defaults.
func (*Spotify) FetchAuthUser ¶ added in v0.8.0
FetchAuthUser returns an AuthUser instance based on the Spotify's user api.
API reference: https://developer.spotify.com/documentation/web-api/reference/#/operations/get-current-users-profile
type Strava ¶ added in v0.11.0
type Strava struct {
BaseProvider
}
Strava allows authentication via Strava OAuth2.
func NewStravaProvider ¶ added in v0.11.0
func NewStravaProvider() *Strava
NewStravaProvider creates new Strava provider instance with some defaults.
func (*Strava) FetchAuthUser ¶ added in v0.11.0
FetchAuthUser returns an AuthUser instance based on the Strava's user api.
API reference: https://developers.strava.com/docs/authentication/
type Trakt ¶ added in v0.25.0
type Trakt struct {
BaseProvider
}
Trakt allows authentication via Trakt OAuth2.
func NewTraktProvider ¶ added in v0.25.0
func NewTraktProvider() *Trakt
NewTraktProvider creates new Trakt provider instance with some defaults.
func (*Trakt) FetchAuthUser ¶ added in v0.25.0
FetchAuthUser returns an AuthUser instance based on Trakt's user settings API. API reference: https://trakt.docs.apiary.io/#reference/users/settings/retrieve-settings
func (*Trakt) FetchRawUserInfo ¶ added in v0.25.0
FetchRawUserInfo implements Provider.FetchRawUserInfo interface method.
This differ from BaseProvider because Trakt requires a number of mandatory headers for all requests (https://trakt.docs.apiary.io/#introduction/required-headers).
type Twitch ¶ added in v0.8.0
type Twitch struct {
BaseProvider
}
Twitch allows authentication via Twitch OAuth2.
func NewTwitchProvider ¶ added in v0.8.0
func NewTwitchProvider() *Twitch
NewTwitchProvider creates new Twitch provider instance with some defaults.
func (*Twitch) FetchAuthUser ¶ added in v0.8.0
FetchAuthUser returns an AuthUser instance based the Twitch's user api.
API reference: https://dev.twitch.tv/docs/api/reference#get-users
type Twitter ¶ added in v0.6.0
type Twitter struct {
BaseProvider
}
Twitter allows authentication via Twitter OAuth2.
func NewTwitterProvider ¶ added in v0.6.0
func NewTwitterProvider() *Twitter
NewTwitterProvider creates new Twitter provider instance with some defaults.
func (*Twitter) FetchAuthUser ¶ added in v0.6.0
FetchAuthUser returns an AuthUser instance based on the Twitter's user api.
API reference: https://docs.x.com/x-api/users/user-lookup-me
type VK ¶ added in v0.17.0
type VK struct {
BaseProvider
}
VK allows authentication via VK OAuth2.
func NewVKProvider ¶ added in v0.17.0
func NewVKProvider() *VK
NewVKProvider creates new VK provider instance with some defaults.
func (*VK) FetchAuthUser ¶ added in v0.17.0
FetchAuthUser returns an AuthUser instance based on VK's user api.
API reference: https://dev.vk.com/method/users.get
type Wakatime ¶ added in v0.23.0
type Wakatime struct {
BaseProvider
}
Wakatime is an auth provider for Wakatime.
func NewWakatimeProvider ¶ added in v0.23.0
func NewWakatimeProvider() *Wakatime
NewWakatimeProvider creates a new Wakatime provider instance with some defaults.
func (*Wakatime) FetchAuthUser ¶ added in v0.23.0
FetchAuthUser returns an AuthUser instance based on the Wakatime's user API.
API reference: https://wakatime.com/developers#users
type Yandex ¶ added in v0.17.0
type Yandex struct {
BaseProvider
}
Yandex allows authentication via Yandex OAuth2.
func NewYandexProvider ¶ added in v0.17.0
func NewYandexProvider() *Yandex
NewYandexProvider creates new Yandex provider instance with some defaults.
func (*Yandex) FetchAuthUser ¶ added in v0.17.0
FetchAuthUser returns an AuthUser instance based on Yandex's user api.
API reference: https://yandex.ru/dev/id/doc/en/user-information#response-format
Source Files
¶
- apple.go
- auth.go
- base_provider.go
- bitbucket.go
- box.go
- discord.go
- facebook.go
- gitea.go
- gitee.go
- github.go
- gitlab.go
- google.go
- instagram.go
- kakao.go
- lark.go
- linear.go
- livechat.go
- mailcow.go
- microsoft.go
- monday.go
- notion.go
- oidc.go
- patreon.go
- planningcenter.go
- spotify.go
- strava.go
- trakt.go
- twitch.go
- twitter.go
- vk.go
- wakatime.go
- yandex.go