Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateState(config *config.Config, provider string, redirectTo string, ...) ([]byte, error)
- func GenerateStateForFlowAPI(isFlow bool) func(*State)
- func GetErrorUrl(redirectTo string, err error) string
- func IsAllowedRedirect(config config.ThirdParty, redirectTo string) bool
- type AccountLinkingResult
- type Claims
- type ClaimsAddress
- type DiscordUser
- type Email
- type Emails
- type FacebookUser
- type GithubUser
- type GithubUserEmail
- type GoogleUser
- type LinkedinUser
- type MicrosoftUser
- type OAuthProvider
- func GetProvider(config config.ThirdParty, id string) (OAuthProvider, error)
- func NewAppleProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewCustomThirdPartyProvider(config *config.CustomThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewDiscordProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewFacebookProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewGithubProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewGoogleProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewLinkedInProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- func NewMicrosoftProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
- type State
- type ThirdPartyError
- func ErrorInvalidRequest(desc string) *ThirdPartyError
- func ErrorMaxNumberOfAddresses(desc string) *ThirdPartyError
- func ErrorMultipleAccounts(desc string) *ThirdPartyError
- func ErrorServer(desc string) *ThirdPartyError
- func ErrorSignUpDisabled(desc string) *ThirdPartyError
- func ErrorUnverifiedProviderEmail(desc string) *ThirdPartyError
- func ErrorUserConflict(desc string) *ThirdPartyError
- func NewThirdPartyError(code string, description string) *ThirdPartyError
- type UserData
Constants ¶
View Source
const ( ErrorCodeInvalidRequest = "invalid_request" ErrorCodeServerError = "server_error" ErrorCodeUserConflict = "user_conflict" ErrorCodeMultipleAccounts = "multiple_accounts" ErrorCodeUnverifiedProviderEmail = "unverified_email" ErrorCodeMaxNumberOfAddresses = "email_maxnum" ErrorCodeSignUpDisabled = "signup_disabled" )
View Source
const ( AppleAPIBase = "https://appleid.apple.com" AppleAuthEndpoint = AppleAPIBase + "/auth/authorize" AppleTokenEndpoint = AppleAPIBase + "/auth/token" AppleKeysEndpoint = AppleAPIBase + "/auth/keys" )
View Source
const ( DiscordAPIBase = "https://discord.com/api" DiscordOauthAuthEndpoint = "https://discord.com/oauth2/authorize" DiscordOauthTokenEndpoint = DiscordAPIBase + "/oauth2/token" DiscordUserInfoEndpoint = DiscordAPIBase + "/users/@me" )
View Source
const ( FacebookAuthBase = "https://www.facebook.com" FacebookAPIBase = "https://graph.facebook.com" FacebookOauthAuthEndpoint = FacebookAuthBase + "/v21.0/dialog/oauth" FacebookOauthTokenEndpoint = FacebookAPIBase + "/v21.0/oauth/access_token" FacebookUserInfoEndpoint = FacebookAPIBase + "/me" )
View Source
const ( GithubAuthBase = "https://github.com" GithubAPIBase = "https://api.github.com" GithubOauthAuthEndpoint = GithubAuthBase + "/login/oauth/authorize" GithubOauthTokenEndpoint = GithubAuthBase + "/login/oauth/access_token" GithubUserInfoEndpoint = GithubAPIBase + "/user" GitHubEmailsEndpoint = GithubAPIBase + "/user/emails" )
View Source
const ( GoogleAuthBase = "https://accounts.google.com" GoogleAPIBase = "https://www.googleapis.com" GoogleOauthAuthEndpoint = GoogleAuthBase + "/o/oauth2/auth" GoogleOauthTokenEndpoint = GoogleAuthBase + "/o/oauth2/token" GoogleUserInfoEndpoint = GoogleAPIBase + "/oauth2/v3/userinfo" )
View Source
const ( MicrosoftAuthBase = "https://login.microsoftonline.com/common" MicrosoftKeysEndpoint = "https://login.microsoftonline.com/common/discovery/v2.0/keys" MicrosoftOAuthAuthEndpoint = MicrosoftAuthBase + "/oauth2/v2.0/authorize" MicrosoftOAuthTokenEndpoint = MicrosoftAuthBase + "/oauth2/v2.0/token" )
View Source
const (
LinkedInIssuer = "https://www.linkedin.com/oauth"
)
Variables ¶
View Source
var DefaultAppleScopes = []string{
"name",
"email",
}
View Source
var DefaultDiscordScopes = []string{
"identify",
"email",
}
View Source
var DefaultFacebookScopes = []string{
"email", "public_profile",
}
View Source
var DefaultGitHubScopes = []string{
"user:email",
}
View Source
var DefaultGoogleScopes = []string{
"email",
}
View Source
var DefaultLinkedinScopes = []string{
"openid",
"profile",
"email",
}
View Source
var DefaultScopes = []string{
"openid",
"profile",
"email",
}
Functions ¶
func GenerateState ¶
func GenerateStateForFlowAPI ¶ added in v1.0.0
func GetErrorUrl ¶
func IsAllowedRedirect ¶
func IsAllowedRedirect(config config.ThirdParty, redirectTo string) bool
Types ¶
type AccountLinkingResult ¶
type AccountLinkingResult struct { Type models.AuditLogType User *models.User WebhookEvent *events.Event UserCreated bool }
func LinkAccount ¶
type Claims ¶
type Claims struct { // Reserved claims Issuer string `json:"iss,omitempty" mapstructure:"iss,omitempty"` Subject string `json:"sub,omitempty" mapstructure:"sub,omitempty"` Aud string `json:"aud,omitempty" mapstructure:"aud,omitempty"` Iat float64 `json:"iat,omitempty" mapstructure:"iat,omitempty"` Exp float64 `json:"exp,omitempty" mapstructure:"exp,omitempty"` // Default profile claims Address *ClaimsAddress `json:"address,omitempty" mapstructure:"address,omitempty"` Birthdate string `json:"birthdate,omitempty" mapstructure:"birthdate,omitempty"` Email string `json:"email,omitempty" mapstructure:"email,omitempty"` EmailVerified bool `json:"email_verified,omitempty" mapstructure:"email_verified,omitempty"` FamilyName string `json:"family_name,omitempty" mapstructure:"family_name,omitempty"` Gender string `json:"gender,omitempty" mapstructure:"gender,omitempty"` GivenName string `json:"given_name,omitempty" mapstructure:"given_name,omitempty"` Locale string `json:"locale,omitempty" mapstructure:"locale,omitempty"` MiddleName string `json:"middle_name,omitempty" mapstructure:"middle_name,omitempty"` Name string `json:"name,omitempty" mapstructure:"name,omitempty"` NickName string `json:"nickname,omitempty" mapstructure:"nickname,omitempty"` Phone string `json:"phone,omitempty" mapstructure:"phone,omitempty"` PhoneVerified bool `json:"phone_verified,omitempty" mapstructure:"phone_verified,omitempty"` Picture string `json:"picture,omitempty" mapstructure:"picture,omitempty"` PreferredUsername string `json:"preferred_username,omitempty" mapstructure:"preferred_username,omitempty"` Profile string `json:"profile,omitempty" mapstructure:"profile,omitempty"` UpdatedAt string `json:"updated_at,omitempty" mapstructure:"updated_at,omitempty"` Website string `json:"website,omitempty" mapstructure:"website,omitempty"` ZoneInfo string `json:"zoneinfo,omitempty" mapstructure:"zoneinfo,omitempty"` // Custom profile claims that are oidc specific CustomClaims map[string]interface{} `json:"custom_claims,omitempty" mapstructure:"custom_claims,remain,omitempty"` }
type ClaimsAddress ¶ added in v1.3.0
type ClaimsAddress struct { Formatted string `json:"formatted,omitempty" mapstructure:"formatted,omitempty"` Locality string `json:"locality,omitempty" mapstructure:"locality,omitempty"` PostalCode string `json:"postal_code,omitempty" mapstructure:"postal_code,omitempty"` Region string `json:"region,omitempty" mapstructure:"region,omitempty"` Street string `json:"street_address,omitempty" mapstructure:"street_address,omitempty"` }
type DiscordUser ¶ added in v0.10.1
type FacebookUser ¶ added in v1.4.0
type FacebookUser struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` Picture struct { Data struct { URL string `json:"url"` } `json:"data"` } `json:"picture"` FirstName string `json:"first_name"` MiddleName string `json:"middle_name"` LastName string `json:"last_name"` }
type GithubUser ¶ added in v0.6.0
type GithubUserEmail ¶ added in v0.6.0
type GoogleUser ¶ added in v0.6.0
type LinkedinUser ¶ added in v0.12.0
type LinkedinUser struct { ID string `json:"sub"` Name string `json:"name"` GivenName string `json:"given_name"` FamilyName string `json:"family_name"` Picture string `json:"picture"` Locale struct { Country string `json:"country"` Language string `json:"language"` } `json:"locale"` Email string `json:"email"` Verified bool `json:"email_verified"` }
type MicrosoftUser ¶ added in v0.11.0
type OAuthProvider ¶
type OAuthProvider interface { AuthCodeURL(string, ...oauth2.AuthCodeOption) string GetUserData(*oauth2.Token) (*UserData, error) GetOAuthToken(string) (*oauth2.Token, error) ID() string }
func GetProvider ¶
func GetProvider(config config.ThirdParty, id string) (OAuthProvider, error)
func NewAppleProvider ¶ added in v0.7.0
func NewAppleProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
func NewCustomThirdPartyProvider ¶ added in v1.3.0
func NewCustomThirdPartyProvider(config *config.CustomThirdPartyProvider, redirectURL string) (OAuthProvider, error)
func NewDiscordProvider ¶ added in v0.10.1
func NewDiscordProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
NewDiscordProvider creates a Discord third party provider.
func NewFacebookProvider ¶ added in v1.4.0
func NewFacebookProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
NewFacebookProvider creates a Facebook third-party OAuth provider.
func NewGithubProvider ¶
func NewGithubProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
func NewGoogleProvider ¶
func NewGoogleProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
NewGoogleProvider creates a Google third party provider.
func NewLinkedInProvider ¶ added in v0.12.0
func NewLinkedInProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
NewLinkedInProvider creates a LinkedIn third party provider.
func NewMicrosoftProvider ¶ added in v0.11.0
func NewMicrosoftProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
NewMicrosoftProvider creates a Microsoft third party provider.
type State ¶
type ThirdPartyError ¶
func ErrorInvalidRequest ¶
func ErrorInvalidRequest(desc string) *ThirdPartyError
func ErrorMaxNumberOfAddresses ¶
func ErrorMaxNumberOfAddresses(desc string) *ThirdPartyError
func ErrorMultipleAccounts ¶
func ErrorMultipleAccounts(desc string) *ThirdPartyError
func ErrorServer ¶
func ErrorServer(desc string) *ThirdPartyError
func ErrorSignUpDisabled ¶ added in v0.10.0
func ErrorSignUpDisabled(desc string) *ThirdPartyError
func ErrorUnverifiedProviderEmail ¶
func ErrorUnverifiedProviderEmail(desc string) *ThirdPartyError
func ErrorUserConflict ¶
func ErrorUserConflict(desc string) *ThirdPartyError
func NewThirdPartyError ¶
func NewThirdPartyError(code string, description string) *ThirdPartyError
func (*ThirdPartyError) Error ¶
func (e *ThirdPartyError) Error() string
func (*ThirdPartyError) Query ¶
func (e *ThirdPartyError) Query() string
func (*ThirdPartyError) WithCause ¶
func (e *ThirdPartyError) WithCause(cause error) *ThirdPartyError
func (*ThirdPartyError) WithDescription ¶
func (e *ThirdPartyError) WithDescription(description string) *ThirdPartyError
Click to show internal directories.
Click to hide internal directories.