Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConfigAuthURLEmpty = errors.New("oauth2: config auth url is empty")
ErrConfigAuthURLEmpty is the error of AuthURL is empty.
var ErrConfigClientIDEmpty = errors.New("oauth2: config client id is empty")
ErrConfigClientIDEmpty is the error of ClientID is empty.
var ErrConfigClientSecretEmpty = errors.New("oauth2: config client secret is empty")
ErrConfigClientSecretEmpty is the error of ClientSecret is empty.
var ErrConfigRedirectURIEmpty = errors.New("oauth2: config redirect uri is empty")
ErrConfigRedirectURIEmpty is the error of RedirectURI is empty.
var ErrConfigTokenURLEmpty = errors.New("oauth2: config token url is empty")
ErrConfigTokenURLEmpty is the error of TokenURL is empty.
var ErrConfigUserInfoURLEmpty = errors.New("oauth2: config user info url is empty")
ErrConfigUserInfoURLEmpty is the error of UserInfoURL is empty.
var Version = "1.7.2"
Version is the version of this package.
Functions ¶
func ApplyDefaultConfig ¶
ApplyDefaultConfig applies the default config.
func ValidateConfig ¶
ValidateConfig validates the config.
Types ¶
type Client ¶
type Client interface { Authorize(state string, callback func(loginUrl string)) Callback(code, state string, cb func(user *User, token *Token, err error)) Logout(callback func(logoutUrl string)) Register(callback func(registerUrl string)) // RefreshToken(refreshToken string) (*Token, error) }
Client is the oauth2 client interface.
type Config ¶
type Config struct { Name string AuthURL string TokenURL string UserInfoURL string // RefershTokenURL string // LogoutURL string // RegisterURL string // callback url = server url + callback path, example: https://example.com/login/callback RedirectURI string Scope string // ClientID string ClientSecret string // ClientIDAttributeName string ClientSecretAttributeName string RedirectURIAttributeName string ResponseTypeAttributeName string ScopeAttributeName string StateAttributeName string // Token.access_token, default: access_token AccessTokenAttributeName string // Token.refresh_token, default: refresh_token RefreshTokenAttributeName string // Token.expires_in, default: expires_in ExpiresInAttributeName string // Token.id_token, default: id_token TokenTypeAttributeName string // User.username, default: username UsernameAttributeName string // User.email, default: email EmailAttributeName string // User.id, default: id IDAttributeName string // User.nickname, default: nickname NicknameAttributeName string // User.avatar, default: avatar AvatarAttributeName string // User.homepage, default: homepage HomepageAttributeName string // User.permissions, default: permissions PermissionsAttributeName string // User.groups, default: groups GroupsAttributeName string // url: login(authorize) + logout GetLoginURL func(cfg *Config, state string) string GetLogoutURL func(cfg *Config) string GetRegisterURL func(cfg *Config) string // token GetAccessTokenResponse func(cfg *Config, code string, state string) (*fetch.Response, error) // user GetUserResponse func(cfg *Config, token *Token, code string) (*fetch.Response, error) // RefreshToken func(cfg *Config, refreshToken string) (*fetch.Response, error) // base url for identity providers, such as auth0, authing BaseURL string }
Config is the OAuth2 config.
type StepCallback ¶
type StepCallback struct { }
StepCallback is the callback ...
type Token ¶
type Token struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn int64 `json:"expires_in"` TokenType string `json:"token_type"` // contains filtered or unexported fields }
Token is the oauth2 token.
func RefreshToken ¶ added in v1.7.0
RefreshToken refresh the token by refresh token.
type User ¶
type User struct { ID string `json:"id"` Username string `json:"username"` Email string `json:"email"` Avatar string `json:"avatar"` Nickname string `json:"nickname"` Groups []string `json:"groups"` Permissions []string `json:"permissions"` // contains filtered or unexported fields }
User is the oauth2 user.