Documentation ¶
Index ¶
- Constants
- type AccessTokenClaims
- type AccessTokenExtended
- type AuthURLParams
- type AuthUrlResult
- type AuthenticationClientOptions
- type Client
- func (client *Client) BuildAuthUrl(params *AuthURLParams) (AuthUrlResult, error)
- func (client *Client) BuildLogoutUrl(params *LogoutURLParams) (string, error)
- func (client *Client) GetLoginStateByAuthCode(params *CodeToTokenParams) (*LoginState, error)
- func (client *Client) GetUserInfo(accessToken string) (*UserInfo, error)
- func (client *Client) ParsedAccessToken(tokenStr string) (*AccessTokenClaims, error)
- func (client *Client) ParsedIDToken(tokenStr string) (*IDTokenClaims, error)
- func (client *Client) RefreshLoginState(refreshToken string) (*LoginState, error)
- type CodeToTokenParams
- type IDTokenClaims
- type IDTokenExtended
- type LoginState
- type LogoutURLParams
- type UserInfo
- type UserInfoCommon
Constants ¶
View Source
const ALG_HS256 = "HS256"
View Source
const JWK_PATH = "/oidc/.well-known/jwks.json"
View Source
const RandStringLen = 16
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenClaims ¶
type AccessTokenClaims struct { jwt.StandardClaims AccessTokenExtended }
type AccessTokenExtended ¶
type AccessTokenExtended struct {
Scope string `json:"scope,omitempty"`
}
type AuthURLParams ¶
type AuthUrlResult ¶
type AuthenticationClientOptions ¶
type AuthenticationClientOptions struct { /** 应用 ID */ AppId string /** 应用 Secret */ AppSecret string /** 应用对应的用户池域名,例如 pool.authing.cn */ Domain string /** 认证完成后的重定向目标 URL */ RedirectUri string /** 登出完成后的重定向目标 URL, 可选 */ LogoutRedirectUri string /** * @optional * 应用侧向 Authing 请求的权限,以空格分隔,默认为 'openid profile' * * 成功获取的权限会出现在 Access Token 的 scope 字段中 * * 一些示例: * - openid OIDC 标准规定的权限,必须包含 * - profile 获取用户的基本身份信息 * - offline_access 获取用户的 Refresh Token,可用于调用 refreshLoginState 刷新用户的登录态 */ Scope string }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(options *AuthenticationClientOptions) (*Client, error)
func (*Client) BuildAuthUrl ¶
func (client *Client) BuildAuthUrl(params *AuthURLParams) (AuthUrlResult, error)
func (*Client) BuildLogoutUrl ¶
func (client *Client) BuildLogoutUrl(params *LogoutURLParams) (string, error)
func (*Client) GetLoginStateByAuthCode ¶
func (client *Client) GetLoginStateByAuthCode(params *CodeToTokenParams) (*LoginState, error)
func (*Client) GetUserInfo ¶
func (*Client) ParsedAccessToken ¶
func (client *Client) ParsedAccessToken(tokenStr string) (*AccessTokenClaims, error)
func (*Client) ParsedIDToken ¶
func (client *Client) ParsedIDToken(tokenStr string) (*IDTokenClaims, error)
func (*Client) RefreshLoginState ¶
func (client *Client) RefreshLoginState(refreshToken string) (*LoginState, error)
type CodeToTokenParams ¶
type IDTokenClaims ¶
type IDTokenClaims struct { UserInfoCommon IDTokenExtended jwt.StandardClaims }
type IDTokenExtended ¶
type LoginState ¶
type LoginState struct { AccessToken string `json:"access_token"` IDToken string `json:"id_token"` RefreshToken string `json:"refresh_token"` //可选 ExpiresIn uint64 `json:"expires_in"` ExpireAt time.Time ParsedIDToken *IDTokenClaims ParsedAccessToken *AccessTokenClaims }
type LogoutURLParams ¶
type UserInfo ¶
type UserInfo struct { Subject string `json:"sub,omitempty"` // 用户 ID UserInfoCommon }
type UserInfoCommon ¶
type UserInfoCommon struct { Name string `json:"name,omitempty"` Nickname string `json:"nickname,omitempty"` GivenName string `json:"given_name,omitempty"` FamilyName string `json:"family_name,omitempty"` Birthdate string `json:"birthdate,omitempty"` Gender string `json:"gender,omitempty"` //'M' | 'F' | 'U' Picture string `json:"picture,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` Zoneinfo string `json:"zoneinfo,omitempty"` PreferredUsername string `json:"preferred_username,omitempty"` Locale string `json:"locale,omitempty"` }
Click to show internal directories.
Click to hide internal directories.