Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateState(config *config.Config, provider string, redirectTo string) ([]byte, error)
- func GetErrorUrl(redirectTo string, err error) string
- func IsAllowedRedirect(config config.ThirdParty, redirectTo string) bool
- type AccountLinkingResult
- type Claims
- type Email
- type Emails
- type GithubUser
- type GithubUserEmail
- type GoogleUser
- type OAuthProvider
- func GetProvider(config config.ThirdParty, name string) (OAuthProvider, error)
- func NewAppleProvider(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)
- 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 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" )
View Source
const ( AppleAPIBase = "https://appleid.apple.com" AppleAuthEndpoint = AppleAPIBase + "/auth/authorize" AppleTokenEndpoint = AppleAPIBase + "/auth/token" AppleKeysEndpoint = AppleAPIBase + "/auth/keys" )
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" )
Variables ¶
View Source
var DefaultAppleScopes = []string{
"name",
"email",
}
View Source
var DefaultGitHubScopes = []string{
"user:email",
}
View Source
var DefaultGoogleScopes = []string{
"email",
}
Functions ¶
func GenerateState ¶
func GetErrorUrl ¶
func IsAllowedRedirect ¶
func IsAllowedRedirect(config config.ThirdParty, redirectTo string) bool
Types ¶
type AccountLinkingResult ¶
type AccountLinkingResult struct { Type models.AuditLogType User *models.User }
func LinkAccount ¶
func LinkAccount(tx *pop.Connection, cfg *config.Config, p persistence.Persister, userData *UserData, providerName string) (*AccountLinkingResult, error)
type Claims ¶
type Claims struct { // Reserved claims Issuer string `json:"iss,omitempty" structs:"iss,omitempty"` Subject string `json:"sub,omitempty" structs:"sub,omitempty"` Aud string `json:"aud,omitempty" structs:"aud,omitempty"` Iat float64 `json:"iat,omitempty" structs:"iat,omitempty"` Exp float64 `json:"exp,omitempty" structs:"exp,omitempty"` // Default profile claims Name string `json:"name,omitempty" structs:"name,omitempty"` FamilyName string `json:"family_name,omitempty" structs:"family_name,omitempty"` GivenName string `json:"given_name,omitempty" structs:"given_name,omitempty"` MiddleName string `json:"middle_name,omitempty" structs:"middle_name,omitempty"` NickName string `json:"nickname,omitempty" structs:"nickname,omitempty"` PreferredUsername string `json:"preferred_username,omitempty" structs:"preferred_username,omitempty"` Profile string `json:"profile,omitempty" structs:"profile,omitempty"` Picture string `json:"picture,omitempty" structs:"picture,omitempty"` Website string `json:"website,omitempty" structs:"website,omitempty"` Gender string `json:"gender,omitempty" structs:"gender,omitempty"` Birthdate string `json:"birthdate,omitempty" structs:"birthdate,omitempty"` ZoneInfo string `json:"zoneinfo,omitempty" structs:"zoneinfo,omitempty"` Locale string `json:"locale,omitempty" structs:"locale,omitempty"` UpdatedAt string `json:"updated_at,omitempty" structs:"updated_at,omitempty"` Email string `json:"email,omitempty" structs:"email,omitempty"` EmailVerified bool `json:"email_verified,omitempty" structs:"email_verified,omitempty"` Phone string `json:"phone,omitempty" structs:"phone,omitempty"` PhoneVerified bool `json:"phone_verified,omitempty" structs:"phone_verified,omitempty"` // Custom profile claims that are provider specific CustomClaims map[string]interface{} `json:"custom_claims,omitempty" structs:"custom_claims,omitempty"` }
type GithubUser ¶ added in v0.6.0
type GithubUserEmail ¶ added in v0.6.0
type GoogleUser ¶ added in v0.6.0
type OAuthProvider ¶
type OAuthProvider interface { AuthCodeURL(string, ...oauth2.AuthCodeOption) string GetUserData(*oauth2.Token) (*UserData, error) GetOAuthToken(string) (*oauth2.Token, error) Name() string }
func GetProvider ¶
func GetProvider(config config.ThirdParty, name string) (OAuthProvider, error)
func NewAppleProvider ¶ added in v0.7.0
func NewAppleProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error)
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.
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 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.