oauth2

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitServer

func InitServer(manager oauth2.Manager, db *sql.DB, logger *log.Logger, secretKey string, timeout time.Duration) *oauth2server.Server

InitServer initialize the oauth2 server instance

func NewManager

func NewManager(tokenStore oauth2.TokenStore, clientStore oauth2.ClientStore, authenticator auth.Authenticator, repository userpersistence.UserRepository) oauth2.Manager

NewManager initialize the oauth2 manager service

Types

type ClientStore

type ClientStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ClientStore client information store

func NewClientStore

func NewClientStore(repository persistence.ClientRepository) *ClientStore

NewClientStore create client store

func (*ClientStore) GetByID

func (cs *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)

GetByID according to the ID for the client information

func (*ClientStore) Internal

func (cs *ClientStore) Internal(id string) (cli oauth2.ClientInfo, err error)

Internal according to the ID for the pkg client information

func (*ClientStore) SetInternal

func (cs *ClientStore) SetInternal(id string, cli oauth2.ClientInfo) (err error)

SetInternal set pkg system client information

type JWTAccess

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

JWTAccess generate the jwt access token

func NewJWTAccess

func NewJWTAccess(method jwt.SigningMethod, authenticator auth.Authenticator, repository userpersistence.UserRepository) *JWTAccess

NewJWTAccess create to generate the jwt access token instance

func (*JWTAccess) Token

func (a *JWTAccess) Token(ctx context.Context, data *oauth2.GenerateBasic, isGenRefresh bool) (string, string, error)

Token based on the UUID generated token

type JWTAccessClaims

type JWTAccessClaims struct {
	auth.Claims
}

JWTAccessClaims jwt claims

func (*JWTAccessClaims) Valid

func (c *JWTAccessClaims) Valid() error

Valid claims verification

type TokenStore

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

TokenStore token storage

func NewTokenStore

NewTokenStore create a token store instance

func (*TokenStore) Create

func (ts *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) error

Create create and store the new token information

func (*TokenStore) GetByAccess

func (ts *TokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)

GetByAccess use the access token for token information data

func (*TokenStore) GetByCode

func (ts *TokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)

GetByCode use the authorization code for token information data

func (*TokenStore) GetByRefresh

func (ts *TokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)

GetByRefresh use the refresh token for token information data

func (*TokenStore) RemoveByAccess

func (ts *TokenStore) RemoveByAccess(ctx context.Context, access string) error

RemoveByAccess use the access token to delete the token information

func (*TokenStore) RemoveByCode

func (ts *TokenStore) RemoveByCode(ctx context.Context, code string) error

RemoveByCode use the authorization code to delete the token information

func (*TokenStore) RemoveByRefresh

func (ts *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) error

RemoveByRefresh use the refresh token to delete the token information

Jump to

Keyboard shortcuts

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