apple

package
v0.5.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BuildOAuthPageURL Apple OAuth2 构建授权页面 URL 的请求地址
	BuildOAuthPageURL = "https://appleid.apple.com/auth/authorize"
	// EndpointPublicKeyURL Apple OAuth2 获取公钥的请求地址
	EndpointPublicKeyURL = "https://appleid.apple.com/auth/keys"
)
View Source
const (
	// OAuthUrlIdentifierKey 构建生成的授权 URL 标识键,用于验证授权来源
	OAuthUrlIdentifierKey = "apple.oauth2.url.identifier.%s"
)

Variables

This section is empty.

Functions

func ConvertKeyToPEM added in v0.5.17

func ConvertKeyToPEM(nStr, eStr string) ([]byte, error)

ConvertKeyToPEM 将 Apple 公钥的 n 和 e 转换为 PEM 格式

func ExtractKidFromIDToken added in v0.5.17

func ExtractKidFromIDToken(idToken string) string

ExtractKidFromIDToken 从 id_token 提取 kid

func GetOAuthURLIdentifierKey added in v0.5.17

func GetOAuthURLIdentifierKey(state string) string

func VerifyIDToken added in v0.5.17

func VerifyIDToken(idToken string, publicKeyPEM []byte) (map[string]interface{}, error)

VerifyIDToken 验证 id_token

Types

type GetPublicKeyResp added in v0.5.17

type GetPublicKeyResp struct {
	Keys []struct {
		Kid string `json:"kid"`
		N   string `json:"n"`
		E   string `json:"e"`
	} `json:"keys"`
}

GetPublicKeyResp 获取公钥响应参数

type OAuth

type OAuth struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *OAuth

func (*OAuth) BuildAuthPageURL added in v0.5.17

func (oauth *OAuth) BuildAuthPageURL() (string, error)

func (*OAuth) HandleOAuth2ByAPPAuthToken added in v0.5.17

func (oauth *OAuth) HandleOAuth2ByAPPAuthToken(token string) (*plugin.OAuthUser, error)

func (*OAuth) HandleOAuth2ByAuthCode added in v0.5.17

func (oauth *OAuth) HandleOAuth2ByAuthCode(code *plugin.VerifyCode) (*plugin.OAuthUser, error)

func (*OAuth) HandlerAuth

func (oauth *OAuth) HandlerAuth(code string) (*plugin.OAuthUser, error)

func (*OAuth) Provide

func (oauth *OAuth) Provide(ctx context.Context) any

type Option

type Option func(o *Options)

func WithClientID

func WithClientID(clientID string) Option

func WithClientSecret

func WithClientSecret(clientSecret string) Option

func WithClientSecretFile

func WithClientSecretFile(clientSecretFile string) Option

func WithKeyId

func WithKeyId(keyId string) Option

func WithRedirectURL

func WithRedirectURL(redirectURL string) Option

func WithTeamId

func WithTeamId(teamId string) Option

type Options

type Options struct {
	ClientId         string
	KeyId            string
	ClientSecret     string
	ClientSecretFile string
	TeamId           string
	RedirectURL      string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL