oauth

package
v0.0.0-...-c5ed977 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: GPL-2.0, GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMissingResponseType        = "missing response_type param"
	ErrMissingClientId            = "missing client_id param"
	ErrMissingRedirectUri         = "missing redirect_uri param"
	ErrMissingState               = "missing state param"
	ErrMissingCodeChallenge       = "missing code_challenge param"
	ErrMissingCodeChallengeMethod = "missing code_challenge_method param"
	ErrClientIdNotFound           = "client_id not found"
	ErrInvalidRedirectUri         = "invalid redirect_uri"
	ErrWhileProcessingRequest     = "an error ocurred while processing your request"
	ErrMissingGrantType           = "missing grant_type param"
	ErrMissingCodeVerifier        = "missing code_verifier param"
	ErrMissingScopes              = "missing scopes param"
	ErrMissingCode                = "missing code param"
	ErrMissingClientSecret        = "missing client_secret param"
	ErrInvalidClientIdOrSecret    = "invalid client_id or client_secret"
	ErrInvalidCodeVerifier        = "invalid code_verifier"
	ErrInvalidRefreshToken        = "invalid refresh_token"
	ErrMissingRefreshToken        = "missing refresh_token"
	ErrMissingToken               = "missing token"
)
View Source
const (
	CodeLen = 36
)

Variables

View Source
var (
	ErrInvalidPayload              = errors.New("payload not supported")
	ErrCodePayloadNotFound         = errors.New("code payload not found")
	ErrTokenPayloadNotFound        = errors.New("token payload not found")
	ErrRefreshTokenPayloadNotFound = errors.New("refresh_token payload not found")
)

Functions

This section is empty.

Types

type CodePayload

type CodePayload struct {
	Challenge string
	Method    oproto.CodeChallengeMethod
}

func (CodePayload) MarshalBinary

func (p CodePayload) MarshalBinary() ([]byte, error)

func (*CodePayload) UnmarshalBinary

func (p *CodePayload) UnmarshalBinary(data []byte) error

type Guard

type Guard struct{}

func NewGuard

func NewGuard() *Guard

func (*Guard) GenerateCode

func (g *Guard) GenerateCode() (string, error)

func (*Guard) GenerateToken

func (g *Guard) GenerateToken() (*oproto.Token, error)

type Guarder

type Guarder interface {
	GenerateCode() (string, error)
	GenerateToken() (*oproto.Token, error)
}

type Memory

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

func NewMemory

func NewMemory(cfg *goRedis.Options) *Memory

func (*Memory) FindCodePayload

func (m *Memory) FindCodePayload(ctx context.Context, key string) (*CodePayload, error)

func (*Memory) FindRefreshTokenPayload

func (m *Memory) FindRefreshTokenPayload(ctx context.Context, key string) (string, error)

func (*Memory) FindTokenPayload

func (m *Memory) FindTokenPayload(ctx context.Context, key string) (*TokenPayload, error)

func (*Memory) SetPayload

func (m *Memory) SetPayload(ctx context.Context, key string, payload interface{}) error

func (*Memory) WithCodeDuration

func (m *Memory) WithCodeDuration(duration time.Duration) *Memory

func (*Memory) WithRefreshTokenDuration

func (m *Memory) WithRefreshTokenDuration(duration time.Duration) *Memory

func (*Memory) WithTokenDuration

func (m *Memory) WithTokenDuration(duration time.Duration) *Memory

type MemoryStorer

type MemoryStorer interface {
	SetPayload(ctx context.Context, code string, payload interface{}) error
	FindCodePayload(ctx context.Context, code string) (*CodePayload, error)
	FindTokenPayload(ctx context.Context, code string) (*TokenPayload, error)
	FindRefreshTokenPayload(ctx context.Context, code string) (string, error)
}

type Service

type Service struct {
	oproto.UnimplementedOAuthServiceServer
	// contains filtered or unexported fields
}

func NewService

func NewService(guard Guarder, store Storer, memory MemoryStorer) *Service

func (*Service) Authorize

func (*Service) Instropect

func (*Service) Token

type Storer

type Storer interface {
	FindByIdentifier(ctx context.Context, identifier string) (*cproto.Client, error)
}

type TokenPayload

type TokenPayload oproto.Token

func (TokenPayload) MarshalBinary

func (p TokenPayload) MarshalBinary() ([]byte, error)

func (*TokenPayload) UnmarshalBinary

func (p *TokenPayload) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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