Skip to content

Commit 45c703f

Browse files
committed
update comments
1 parent d1fff4d commit 45c703f

File tree

8 files changed

+95
-130
lines changed

8 files changed

+95
-130
lines changed

const.go

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
package oauth2
22

3-
// ResponseType Response Type
3+
// ResponseType the type of authorization request
44
type ResponseType string
55

6+
// define the type of authorization request
67
const (
7-
// Code Authorization code type
8-
Code ResponseType = "code"
9-
// Token Token type
8+
Code ResponseType = "code"
109
Token ResponseType = "token"
1110
)
1211

1312
func (rt ResponseType) String() string {
1413
return string(rt)
1514
}
1615

17-
// GrantType Authorization Grant
16+
// GrantType authorization model
1817
type GrantType string
1918

19+
// define authorization model
2020
const (
21-
// AuthorizationCode Authorization Code
22-
AuthorizationCode GrantType = "authorization_code"
23-
// PasswordCredentials Resource Owner Password Credentials
21+
AuthorizationCode GrantType = "authorization_code"
2422
PasswordCredentials GrantType = "password"
25-
// ClientCredentials Client Credentials
26-
ClientCredentials GrantType = "clientcredentials"
27-
// Refreshing Refresh Token
28-
Refreshing GrantType = "refreshtoken"
29-
// Implicit Implicit Grant
30-
Implicit GrantType = "__implicit"
23+
ClientCredentials GrantType = "clientcredentials"
24+
Refreshing GrantType = "refreshtoken"
25+
Implicit GrantType = "__implicit"
3126
)
3227

3328
func (gt GrantType) String() string {

generate.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ package oauth2
33
import "time"
44

55
type (
6-
// GenerateBasic Provide the basis of the generated token data
6+
// GenerateBasic provide the basis of the generated token data
77
GenerateBasic struct {
8-
Client ClientInfo // The client information
9-
UserID string // The user id
10-
CreateAt time.Time // Creation time
8+
Client ClientInfo
9+
UserID string
10+
CreateAt time.Time
1111
}
1212

13-
// AuthorizeGenerate Generate the authorization code interface
13+
// AuthorizeGenerate generate the authorization code interface
1414
AuthorizeGenerate interface {
1515
Token(data *GenerateBasic) (code string, err error)
1616
}
1717

18-
// AccessGenerate Generate the access and refresh tokens interface
18+
// AccessGenerate generate the access and refresh tokens interface
1919
AccessGenerate interface {
2020
Token(data *GenerateBasic, isGenRefresh bool) (access, refresh string, err error)
2121
}

manage.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@ import (
44
"time"
55
)
66

7-
// TokenGenerateRequest Provide to generate the token request parameters
7+
// TokenGenerateRequest provide to generate the token request parameters
88
type TokenGenerateRequest struct {
9-
ClientID string // The client information
10-
ClientSecret string // The client secret
11-
UserID string // The user id
12-
RedirectURI string // Redirect URI
13-
Scope string // Scope of authorization
14-
Code string // Authorization code
15-
Refresh string // Refreshing token
16-
AccessTokenExp time.Duration // Access token expiration time (in seconds)
9+
ClientID string
10+
ClientSecret string
11+
UserID string
12+
RedirectURI string
13+
Scope string
14+
Code string
15+
Refresh string
16+
AccessTokenExp time.Duration
1717
}
1818

19-
// Manager Authorization management interface
19+
// Manager authorization management interface
2020
type Manager interface {
21-
// Check the interface implementation
21+
// check the interface implementation
2222
CheckInterface() (err error)
2323

24-
// Get the client information
24+
// get the client information
2525
GetClient(clientID string) (cli ClientInfo, err error)
2626

27-
// Generate the authorization token(code)
27+
// generate the authorization token(code)
2828
GenerateAuthToken(rt ResponseType, tgr *TokenGenerateRequest) (authToken TokenInfo, err error)
2929

30-
// Generate the access token
30+
// generate the access token
3131
GenerateAccessToken(rt GrantType, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)
3232

33-
// Refreshing an access token
33+
// refreshing an access token
3434
RefreshAccessToken(tgr *TokenGenerateRequest) (accessToken TokenInfo, err error)
3535

36-
// Use the access token to delete the token information
36+
// use the access token to delete the token information
3737
RemoveAccessToken(access string) (err error)
3838

39-
// Use the refresh token to delete the token information
39+
// use the refresh token to delete the token information
4040
RemoveRefreshToken(refresh string) (err error)
4141

42-
// According to the access token for corresponding token information
42+
// according to the access token for corresponding token information
4343
LoadAccessToken(access string) (ti TokenInfo, err error)
4444

45-
// According to the refresh token for corresponding token information
45+
// according to the refresh token for corresponding token information
4646
LoadRefreshToken(refresh string) (ti TokenInfo, err error)
4747
}

manage/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import "time"
44

55
// Config authorization configuration parameters
66
type Config struct {
7-
// access token expiration time (in seconds)
7+
// access token expiration time
88
AccessTokenExp time.Duration
9-
// refresh token expiration time(in seconds)
9+
// refresh token expiration time
1010
RefreshTokenExp time.Duration
1111
// whether to generate the refreshing token
1212
IsGenerateRefresh bool

model.go

+2-32
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,44 @@ package oauth2
33
import "time"
44

55
type (
6-
// ClientInfo The client information model interface
6+
// ClientInfo the client information model interface
77
ClientInfo interface {
8-
// The client id
98
GetID() string
10-
// The client secret
119
GetSecret() string
12-
// The client domain
1310
GetDomain() string
14-
// The extension data related to the client
1511
GetExtraData() interface{}
1612
}
1713

18-
// TokenInfo The token information model interface
14+
// TokenInfo the token information model interface
1915
TokenInfo interface {
20-
// Get client id
2116
GetClientID() string
22-
// Set client id
2317
SetClientID(string)
24-
// Get user id
2518
GetUserID() string
26-
// Set user id
2719
SetUserID(string)
28-
// Get Redirect URI
2920
GetRedirectURI() string
30-
// Set Redirect URI
3121
SetRedirectURI(string)
32-
// Get Scope of authorization
3322
GetScope() string
34-
// Set Scope of authorization
3523
SetScope(string)
3624

37-
// Get Authorization code
3825
GetCode() string
39-
// Set Authorization code
4026
SetCode(string)
41-
// Get Create Time
4227
GetCodeCreateAt() time.Time
43-
// Set Create Time
4428
SetCodeCreateAt(time.Time)
45-
// Get The lifetime in seconds of the authorization code
4629
GetCodeExpiresIn() time.Duration
47-
// Set The lifetime in seconds of the authorization code
4830
SetCodeExpiresIn(time.Duration)
4931

50-
// Get Access Token
5132
GetAccess() string
52-
// Set Access Token
5333
SetAccess(string)
54-
// Get Create Time
5534
GetAccessCreateAt() time.Time
56-
// Set Create Time
5735
SetAccessCreateAt(time.Time)
58-
// Get The lifetime in seconds of the access token
5936
GetAccessExpiresIn() time.Duration
60-
// Set The lifetime in seconds of the access token
6137
SetAccessExpiresIn(time.Duration)
6238

63-
// Get Refresh Token
6439
GetRefresh() string
65-
// Set Refresh Token
6640
SetRefresh(string)
67-
// Get Create Time
6841
GetRefreshCreateAt() time.Time
69-
// Set Create Time
7042
SetRefreshCreateAt(time.Time)
71-
// Get The lifetime in seconds of the access token
7243
GetRefreshExpiresIn() time.Duration
73-
// Set The lifetime in seconds of the access token
7444
SetRefreshExpiresIn(time.Duration)
7545
}
7646
)

models/client.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package models
22

3-
// Client Client model
3+
// Client client model
44
type Client struct {
5-
ID string // The client id
6-
Secret string // The client secret
7-
Domain string // The client domain
5+
ID string
6+
Secret string
7+
Domain string
88
}
99

1010
// GetID The client id

0 commit comments

Comments
 (0)