provider

package
v0.0.0-...-4dbf48f Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const NameGithub = "github"
View Source
const NameGoogle string = "google"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUser

type AuthUser struct {
	Id        string `json:"id"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	AvatarUrl string `json:"avatar_url"`
}

type Github

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

func NewGithub

func NewGithub(opts ...ProviderOption) *Github

func (Github) AuthUrl

func (p Github) AuthUrl() string

func (Github) Client

func (p Github) Client(token *oauth2.Token) *http.Client

func (Github) ClientId

func (p Github) ClientId() string

func (Github) ClientSecret

func (p Github) ClientSecret() string

func (Github) Context

func (p Github) Context() context.Context

func (Github) DisplayName

func (p Github) DisplayName() string

func (Github) FetchRawUserData

func (p Github) FetchRawUserData(token *oauth2.Token) (data []byte, err error)

func (Github) FetchToken

func (p Github) FetchToken(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

func (*Github) FetchUser

func (p *Github) FetchUser(token *oauth2.Token) (*AuthUser, error)

func (Github) RedirectUrl

func (p Github) RedirectUrl() string

func (Github) Scopes

func (p Github) Scopes() []string

func (Github) SetAuthUrl

func (p Github) SetAuthUrl(authUrl string)

func (Github) SetClientId

func (p Github) SetClientId(clientId string)

func (Github) SetClientSecret

func (p Github) SetClientSecret(clientSecret string)

func (Github) SetContext

func (p Github) SetContext(ctx context.Context)

func (Github) SetRedirectUrl

func (p Github) SetRedirectUrl(redirectUrl string)

func (Github) SetScopes

func (p Github) SetScopes(scopes []string)

func (Github) SetTokenUrl

func (p Github) SetTokenUrl(tokenUrl string)

func (Github) SetUserApiUrl

func (p Github) SetUserApiUrl(userApiUrl string)

func (Github) TokenUrl

func (p Github) TokenUrl() string

func (Github) UserApiUrl

func (p Github) UserApiUrl() string

type Google

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

func NewGoogle

func NewGoogle(opts ...ProviderOption) *Google

func (Google) AuthUrl

func (p Google) AuthUrl() string

func (Google) Client

func (p Google) Client(token *oauth2.Token) *http.Client

func (Google) ClientId

func (p Google) ClientId() string

func (Google) ClientSecret

func (p Google) ClientSecret() string

func (Google) Context

func (p Google) Context() context.Context

func (Google) DisplayName

func (p Google) DisplayName() string

func (Google) FetchRawUserData

func (p Google) FetchRawUserData(token *oauth2.Token) (data []byte, err error)

func (*Google) FetchToken

func (p *Google) FetchToken(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)

func (*Google) FetchUser

func (p *Google) FetchUser(token *oauth2.Token) (*AuthUser, error)

func (Google) RedirectUrl

func (p Google) RedirectUrl() string

func (Google) Scopes

func (p Google) Scopes() []string

func (Google) SetAuthUrl

func (p Google) SetAuthUrl(authUrl string)

func (Google) SetClientId

func (p Google) SetClientId(clientId string)

func (Google) SetClientSecret

func (p Google) SetClientSecret(clientSecret string)

func (Google) SetContext

func (p Google) SetContext(ctx context.Context)

func (Google) SetRedirectUrl

func (p Google) SetRedirectUrl(redirectUrl string)

func (Google) SetScopes

func (p Google) SetScopes(scopes []string)

func (Google) SetTokenUrl

func (p Google) SetTokenUrl(tokenUrl string)

func (Google) SetUserApiUrl

func (p Google) SetUserApiUrl(userApiUrl string)

func (Google) TokenUrl

func (p Google) TokenUrl() string

func (Google) UserApiUrl

func (p Google) UserApiUrl() string

type Provider

type Provider interface {
	Context() context.Context
	SetContext(ctx context.Context)

	DisplayName() string

	Scopes() []string
	SetScopes(scopes []string)

	ClientId() string
	SetClientId(clientId string)

	ClientSecret() string
	SetClientSecret(clientSecret string)

	RedirectUrl() string
	SetRedirectUrl(redirectUrl string)

	AuthUrl() string
	SetAuthUrl(authUrl string)

	TokenUrl() string
	SetTokenUrl(tokenUrl string)

	UserApiUrl() string
	SetUserApiUrl(userApiUrl string)

	Client(token *oauth2.Token) *http.Client
	FetchToken(code string, opts ...oauth2.AuthCodeOption) (*oauth2.Token, error)
	FetchUser(token *oauth2.Token) (user *AuthUser, err error)
}

type ProviderOption

type ProviderOption func(Provider)

func WithClientId

func WithClientId(clientId string) ProviderOption

func WithClientSecret

func WithClientSecret(clientSecret string) ProviderOption

func WithRedirectUrl

func WithRedirectUrl(redirectUrl string) ProviderOption

Jump to

Keyboard shortcuts

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