oauth

package
v1.12.12-beta005 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// AuthorizationPrefix is authorization prefix
	AuthorizationPrefix = "Bearer"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizedClient

type AuthorizedClient struct {
	Client *http.Client
	Token  *oauth2.Token
}

AuthorizedClient is authorized client and token

type GithubValidator added in v1.2.4

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

GithubValidator is github oauth validator

func NewGithubValidator added in v1.2.4

func NewGithubValidator(client *http.Client, clientID, clientSecret string, scopes []string) *GithubValidator

NewGithubValidator creates new github validator

func (GithubValidator) GetEndpoint added in v1.2.4

func (v GithubValidator) GetEndpoint() oauth2.Endpoint

GetEndpoint returns endpoint

func (GithubValidator) Validate added in v1.2.4

func (v GithubValidator) Validate(accessToken string) error

Validate validates oauth token

type GithubValidatorRequest added in v1.2.4

type GithubValidatorRequest struct {
	AccessToken string `json:"access_token"`
}

GithubValidatorRequest contains github validation request

type GithubValidatorResponse added in v1.2.4

type GithubValidatorResponse struct {
	ExpiresAt *time.Time `json:"expires_at"`
	Scopes    []string   `json:"scopes"`
}

GithubValidatorResponse contains github validation response

type Provider

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

Provider contains oauth provider config

func NewProvider

func NewProvider(clientID, clientSecret string, scopes []string) Provider

NewProvider returns new provider

func (Provider) AddValidator added in v1.2.4

func (p Provider) AddValidator(providerType ProviderType, validator Validator)

AddValidator adds validator

func (Provider) AuthenticateUser

func (p Provider) AuthenticateUser(providerType ProviderType) (client *AuthorizedClient, err error)

AuthenticateUser starts the login process

func (Provider) CallbackHandler

func (p Provider) CallbackHandler(ctx context.Context, clientChan chan *AuthorizedClient,
	providerType ProviderType) func(w http.ResponseWriter, r *http.Request)

CallbackHandler is oauth callback handler

func (Provider) ErrorHandler

func (p Provider) ErrorHandler() func(w http.ResponseWriter, r *http.Request)

ErrorHandler is oauth error handler

func (Provider) GetValidator added in v1.2.4

func (p Provider) GetValidator(providerType ProviderType) (Validator, error)

GetValidator returns validator

func (Provider) ValidateAccessToken added in v1.2.4

func (p Provider) ValidateAccessToken(providerType ProviderType, accessToken string) error

ValidateAccessToken validates access token

func (Provider) ValidateToken

func (p Provider) ValidateToken(providerType ProviderType, token *oauth2.Token) (*oauth2.Token, error)

ValidateToken validates token

type ProviderType added in v1.2.4

type ProviderType string

ProviderType is provider type

const (
	// GithubProviderType is github provider type
	GithubProviderType ProviderType = "github"
)

type Validator added in v1.2.4

type Validator interface {
	// Validate validates oauth token
	Validate(accessToken string) error
	// GetEndpoint returns oauth endpoint
	GetEndpoint() oauth2.Endpoint
}

Validator describes ouath validation methods

Jump to

Keyboard shortcuts

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