gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

manage.go (1715B)


      1 package oauth2
      2 
      3 import (
      4 	"context"
      5 	"net/http"
      6 	"time"
      7 )
      8 
      9 // TokenGenerateRequest provide to generate the token request parameters
     10 type TokenGenerateRequest struct {
     11 	ClientID            string
     12 	ClientSecret        string
     13 	UserID              string
     14 	RedirectURI         string
     15 	Scope               string
     16 	Code                string
     17 	CodeChallenge       string
     18 	CodeChallengeMethod CodeChallengeMethod
     19 	Refresh             string
     20 	CodeVerifier        string
     21 	AccessTokenExp      time.Duration
     22 	Request             *http.Request
     23 }
     24 
     25 // Manager authorization management interface
     26 type Manager interface {
     27 	// get the client information
     28 	GetClient(ctx context.Context, clientID string) (cli ClientInfo, err error)
     29 
     30 	// generate the authorization token(code)
     31 	GenerateAuthToken(ctx context.Context, rt ResponseType, tgr *TokenGenerateRequest) (authToken TokenInfo, err error)
     32 
     33 	// generate the access token
     34 	GenerateAccessToken(ctx context.Context, rt GrantType, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)
     35 
     36 	// refreshing an access token
     37 	RefreshAccessToken(ctx context.Context, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)
     38 
     39 	// use the access token to delete the token information
     40 	RemoveAccessToken(ctx context.Context, access string) (err error)
     41 
     42 	// use the refresh token to delete the token information
     43 	RemoveRefreshToken(ctx context.Context, refresh string) (err error)
     44 
     45 	// according to the access token for corresponding token information
     46 	LoadAccessToken(ctx context.Context, access string) (ti TokenInfo, err error)
     47 
     48 	// according to the refresh token for corresponding token information
     49 	LoadRefreshToken(ctx context.Context, refresh string) (ti TokenInfo, err error)
     50 }