oauth2

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Error string `json:"error"`
	Code  int    `json:"-"`
}

func (APIError) IsZero

func (a APIError) IsZero() bool

type Mailgun

type Mailgun struct {
	From          string
	Subject       string
	PlainTextTmpl *texttmpl.Template
	HTMLTmpl      *htmltmpl.Template
	Client        *mailgun.MailgunImpl
}

func (Mailgun) SendMail

func (m Mailgun) SendMail(ctx context.Context, email, code string) error

type Service

type Service struct {
	GoogleIDVerifier *oidc.IDTokenVerifier
	GoogleClients    []string
	TokenExpiresIn   int
	Accounts         accounts.Dependencies
	Clients          clients.Storer
	Grants           grants.Dependencies
	Refresh          tokens.Dependencies
	Scopes           scopes.Dependencies
	Sessions         sessions.Dependencies
	Log              *yall.Logger
	Emailer          emailer
}

func (Service) IssueAccessToken

func (s Service) IssueAccessToken(ctx context.Context, grant grants.Grant) (string, error)

IssueAccessToken creates a new access token from a Grant, filling in the values appropriately.

func (Service) IssueRefreshToken

func (s Service) IssueRefreshToken(ctx context.Context, grant grants.Grant) (string, error)

IssueRefreshToken creates a Refresh Token and stores it in the service indicated by `Refresh` on `s`. It fills the token with the appropriate values from `grant`, sets any unset defaults, and stores the token before returning it.

func (Service) Server

func (s Service) Server(prefix string) http.Handler

func (Service) UseRefreshToken

func (s Service) UseRefreshToken(ctx context.Context, tokenID string) error

UseRefreshToken marks a refresh token as used, making it so the token cannot be reused.

func (Service) ValidateRefreshToken

func (s Service) ValidateRefreshToken(ctx context.Context, token, client string) (tokens.RefreshToken, error)

ValidateRefreshToken verifies that a refresh token is valid and for the specified client, returning the struct representation of valid tokens.

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

Jump to

Keyboard shortcuts

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