Documentation
¶
Overview ¶
Package alipay implements the OAuth2 protocol for authenticating users through Alipay. This package can be used as a reference implementation of an OAuth2 provider for Goth.
Index ¶
- Constants
- Variables
- func FormatPKCS1PrivateKey(raw string) []byte
- func FormatPKCS8PrivateKey(raw string) []byte
- func FormatPublicKey(raw string) []byte
- func GenRSAKeyWithPKCS1(bits int) (privateKey, publicKey []byte, err error)
- func GenRSAKeyWithPKCS8(bits int) (privateKey, publicKey []byte, err error)
- func ParsePKCS1PrivateKey(data []byte) (key *rsa.PrivateKey, err error)
- func ParsePKCS8PrivateKey(data []byte) (key *rsa.PrivateKey, err error)
- func ParsePublicKey(data []byte) (key *rsa.PublicKey, err error)
- func RSADecrypt(ciphertext, key []byte) ([]byte, error)
- func RSADecryptWithKey(ciphertext []byte, key *rsa.PrivateKey) ([]byte, error)
- func RSADecryptWithPKCS1(ciphertext, key []byte) ([]byte, error)
- func RSADecryptWithPKCS8(ciphertext, key []byte) ([]byte, error)
- func RSAEncrypt(plaintext, key []byte) ([]byte, error)
- func RSAEncryptWithKey(plaintext []byte, key *rsa.PublicKey) ([]byte, error)
- func RSASignWithKey(plaintext []byte, key *rsa.PrivateKey, hash crypto.Hash) ([]byte, error)
- func RSASignWithPKCS1(plaintext, key []byte, hash crypto.Hash) ([]byte, error)
- func RSASignWithPKCS8(plaintext, key []byte, hash crypto.Hash) ([]byte, error)
- func RSAVerify(ciphertext, sign, key []byte, hash crypto.Hash) error
- func RSAVerifyWithKey(ciphertext, sign []byte, key *rsa.PublicKey, hash crypto.Hash) error
- func SignRSA(param url.Values, privateKey *rsa.PrivateKey) (string, error)
- func SignRSA2(param url.Values, privateKey *rsa.PrivateKey) (string, error)
- func SignRSAx(param url.Values, privateKey *rsa.PrivateKey, hash crypto.Hash) (string, error)
- func VerifyResponseData(data []byte, signType, sign string, key []byte) error
- func VerifySign(val url.Values, key []byte) error
- type Provider
- func (p *Provider) BeginAuth(state string) (goth.Session, error)
- func (p *Provider) Client() *http.Client
- func (p *Provider) Debug(debug bool)
- func (p *Provider) FetchUser(session goth.Session) (goth.User, error)
- func (p *Provider) Name() string
- func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error)
- func (p *Provider) RefreshTokenAvailable() bool
- func (p *Provider) SetName(name string)
- func (p *Provider) UnmarshalSession(data string) (goth.Session, error)
- type Session
Constants ¶
const ( KPKCS1Suffix = "-----END RSA PRIVATE KEY-----" KPKCS8Suffix = "-----END PRIVATE KEY-----" )
Variables ¶
var ( SandBoxAuthURL = "https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm" SandBoxAPIURL = "https://openapi.alipaydev.com/gateway.do" AuthURL = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm" APIURL = "https://openapi.alipay.com/gateway.do" )
These vars define the Authentication, Token, and API URLS for GitHub. If using GitHub enterprise you should change these values before calling New.
var ( ErrPrivateKeyFailedToLoad = errors.New("[oauth2s]alipay: private key failed to load") ErrPublicKeyFailedToLoad = errors.New("[oauth2s]alipay: public key failed to load") )
Functions ¶
func FormatPKCS1PrivateKey ¶ added in v0.4.1
func FormatPKCS8PrivateKey ¶ added in v0.4.1
func FormatPublicKey ¶ added in v0.4.1
func GenRSAKeyWithPKCS1 ¶ added in v0.4.1
func GenRSAKeyWithPKCS8 ¶ added in v0.4.1
func ParsePKCS1PrivateKey ¶ added in v0.4.1
func ParsePKCS1PrivateKey(data []byte) (key *rsa.PrivateKey, err error)
func ParsePKCS8PrivateKey ¶ added in v0.4.1
func ParsePKCS8PrivateKey(data []byte) (key *rsa.PrivateKey, err error)
func ParsePublicKey ¶ added in v0.4.1
func RSADecrypt ¶
func RSADecryptWithKey ¶ added in v0.4.1
func RSADecryptWithKey(ciphertext []byte, key *rsa.PrivateKey) ([]byte, error)
RSADecryptWithKey 使用私钥 key 对数据 data 进行 RSA 解密
func RSADecryptWithPKCS1 ¶ added in v0.4.1
RSADecryptWithPKCS1 使用私钥 key 对数据 data 进行 RSA 解密,key 的格式为 pkcs1
func RSADecryptWithPKCS8 ¶ added in v0.4.1
RSADecryptWithPKCS8 使用私钥 key 对数据 data 进行 RSA 解密,key 的格式为 pkcs8
func RSAEncrypt ¶
func RSAEncryptWithKey ¶ added in v0.4.1
RSAEncryptWithKey 使用公钥 key 对数据 data 进行 RSA 加密
func RSASignWithKey ¶ added in v0.4.1
func RSASignWithPKCS1 ¶ added in v0.4.1
func RSASignWithPKCS8 ¶ added in v0.4.1
func RSAVerifyWithKey ¶ added in v0.4.1
func VerifyResponseData ¶
Types ¶
type Provider ¶
type Provider struct { ClientKey string Secret string CallbackURL string HTTPClient *http.Client // contains filtered or unexported fields }
Provider is the implementation of `goth.Provider` for accessing Github.
func New ¶
New creates a new Github provider, and sets up important connection details. You should always call `github.New` to get a new Provider. Never try to create one manually.
func NewCustomisedURL ¶
func NewCustomisedURL(clientKey, privateKey, callbackURL, authURL string, apiURL string, scopes ...string) *Provider
NewCustomisedURL is similar to New(...) but can be used to set custom URLs to connect to
func (*Provider) BeginAuth ¶
BeginAuth asks Github for an authentication end-point. documentation https://opensupport.alipay.com/support/helpcenter/166/201602504335?ant_source=zsearch#
func (*Provider) FetchUser ¶
FetchUser will go to Github and access basic information about the user. documentation https://opendocs.alipay.com/apis/api_2/alipay.user.info.share
func (*Provider) RefreshToken ¶
RefreshToken refresh token is not provided by QQ
func (*Provider) RefreshTokenAvailable ¶
RefreshTokenAvailable refresh token is not provided by QQ
type Session ¶
type Session struct { AuthURL string AccessToken string RefreshToken string OpenID string Expiry time.Time }
Session stores data during the auth process with QQ.
func (*Session) Authorize ¶
Authorize the session with Github and return the access token to be stored for future use. ?state=state&app_id=hide&source=alipay_wallet&userOutputs=auth_user&scope=auth_user&alipay_token=&auth_code=7b7022f35fff49b896d0251bc763VX39 documentation https://opendocs.alipay.com/apis/api_9/alipay.system.oauth.token
func (Session) GetAuthURL ¶
GetAuthURL will return the URL set by calling the `BeginAuth` function on the QQ provider.