gtsocial-umbx

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

token.go (4591B)


      1 package models
      2 
      3 import (
      4 	"time"
      5 
      6 	"github.com/superseriousbusiness/oauth2/v4"
      7 )
      8 
      9 // NewToken create to token model instance
     10 func NewToken() *Token {
     11 	return &Token{}
     12 }
     13 
     14 // Token token model
     15 type Token struct {
     16 	ClientID            string        `bson:"ClientID"`
     17 	UserID              string        `bson:"UserID"`
     18 	RedirectURI         string        `bson:"RedirectURI"`
     19 	Scope               string        `bson:"Scope"`
     20 	Code                string        `bson:"Code"`
     21 	CodeChallenge       string        `bson:"CodeChallenge"`
     22 	CodeChallengeMethod string        `bson:"CodeChallengeMethod"`
     23 	CodeCreateAt        time.Time     `bson:"CodeCreateAt"`
     24 	CodeExpiresIn       time.Duration `bson:"CodeExpiresIn"`
     25 	Access              string        `bson:"Access"`
     26 	AccessCreateAt      time.Time     `bson:"AccessCreateAt"`
     27 	AccessExpiresIn     time.Duration `bson:"AccessExpiresIn"`
     28 	Refresh             string        `bson:"Refresh"`
     29 	RefreshCreateAt     time.Time     `bson:"RefreshCreateAt"`
     30 	RefreshExpiresIn    time.Duration `bson:"RefreshExpiresIn"`
     31 }
     32 
     33 // New create to token model instance
     34 func (t *Token) New() oauth2.TokenInfo {
     35 	return NewToken()
     36 }
     37 
     38 // GetClientID the client id
     39 func (t *Token) GetClientID() string {
     40 	return t.ClientID
     41 }
     42 
     43 // SetClientID the client id
     44 func (t *Token) SetClientID(clientID string) {
     45 	t.ClientID = clientID
     46 }
     47 
     48 // GetUserID the user id
     49 func (t *Token) GetUserID() string {
     50 	return t.UserID
     51 }
     52 
     53 // SetUserID the user id
     54 func (t *Token) SetUserID(userID string) {
     55 	t.UserID = userID
     56 }
     57 
     58 // GetRedirectURI redirect URI
     59 func (t *Token) GetRedirectURI() string {
     60 	return t.RedirectURI
     61 }
     62 
     63 // SetRedirectURI redirect URI
     64 func (t *Token) SetRedirectURI(redirectURI string) {
     65 	t.RedirectURI = redirectURI
     66 }
     67 
     68 // GetScope get scope of authorization
     69 func (t *Token) GetScope() string {
     70 	return t.Scope
     71 }
     72 
     73 // SetScope get scope of authorization
     74 func (t *Token) SetScope(scope string) {
     75 	t.Scope = scope
     76 }
     77 
     78 // GetCode authorization code
     79 func (t *Token) GetCode() string {
     80 	return t.Code
     81 }
     82 
     83 // SetCode authorization code
     84 func (t *Token) SetCode(code string) {
     85 	t.Code = code
     86 }
     87 
     88 // GetCodeCreateAt create Time
     89 func (t *Token) GetCodeCreateAt() time.Time {
     90 	return t.CodeCreateAt
     91 }
     92 
     93 // SetCodeCreateAt create Time
     94 func (t *Token) SetCodeCreateAt(createAt time.Time) {
     95 	t.CodeCreateAt = createAt
     96 }
     97 
     98 // GetCodeExpiresIn the lifetime in seconds of the authorization code
     99 func (t *Token) GetCodeExpiresIn() time.Duration {
    100 	return t.CodeExpiresIn
    101 }
    102 
    103 // SetCodeExpiresIn the lifetime in seconds of the authorization code
    104 func (t *Token) SetCodeExpiresIn(exp time.Duration) {
    105 	t.CodeExpiresIn = exp
    106 }
    107 
    108 // GetCodeChallenge challenge code
    109 func (t *Token) GetCodeChallenge() string {
    110 	return t.CodeChallenge
    111 }
    112 
    113 // SetCodeChallenge challenge code
    114 func (t *Token) SetCodeChallenge(code string) {
    115 	t.CodeChallenge = code
    116 }
    117 
    118 // GetCodeChallengeMethod challenge method
    119 func (t *Token) GetCodeChallengeMethod() oauth2.CodeChallengeMethod {
    120 	return oauth2.CodeChallengeMethod(t.CodeChallengeMethod)
    121 }
    122 
    123 // SetCodeChallengeMethod challenge method
    124 func (t *Token) SetCodeChallengeMethod(method oauth2.CodeChallengeMethod) {
    125 	t.CodeChallengeMethod = string(method)
    126 }
    127 
    128 // GetAccess access Token
    129 func (t *Token) GetAccess() string {
    130 	return t.Access
    131 }
    132 
    133 // SetAccess access Token
    134 func (t *Token) SetAccess(access string) {
    135 	t.Access = access
    136 }
    137 
    138 // GetAccessCreateAt create Time
    139 func (t *Token) GetAccessCreateAt() time.Time {
    140 	return t.AccessCreateAt
    141 }
    142 
    143 // SetAccessCreateAt create Time
    144 func (t *Token) SetAccessCreateAt(createAt time.Time) {
    145 	t.AccessCreateAt = createAt
    146 }
    147 
    148 // GetAccessExpiresIn the lifetime in seconds of the access token
    149 func (t *Token) GetAccessExpiresIn() time.Duration {
    150 	return t.AccessExpiresIn
    151 }
    152 
    153 // SetAccessExpiresIn the lifetime in seconds of the access token
    154 func (t *Token) SetAccessExpiresIn(exp time.Duration) {
    155 	t.AccessExpiresIn = exp
    156 }
    157 
    158 // GetRefresh refresh Token
    159 func (t *Token) GetRefresh() string {
    160 	return t.Refresh
    161 }
    162 
    163 // SetRefresh refresh Token
    164 func (t *Token) SetRefresh(refresh string) {
    165 	t.Refresh = refresh
    166 }
    167 
    168 // GetRefreshCreateAt create Time
    169 func (t *Token) GetRefreshCreateAt() time.Time {
    170 	return t.RefreshCreateAt
    171 }
    172 
    173 // SetRefreshCreateAt create Time
    174 func (t *Token) SetRefreshCreateAt(createAt time.Time) {
    175 	t.RefreshCreateAt = createAt
    176 }
    177 
    178 // GetRefreshExpiresIn the lifetime in seconds of the refresh token
    179 func (t *Token) GetRefreshExpiresIn() time.Duration {
    180 	return t.RefreshExpiresIn
    181 }
    182 
    183 // SetRefreshExpiresIn the lifetime in seconds of the refresh token
    184 func (t *Token) SetRefreshExpiresIn(exp time.Duration) {
    185 	t.RefreshExpiresIn = exp
    186 }