mirror of
https://github.com/weloe/token-go.git
synced 2025-11-03 01:53:26 +08:00
feat: add config
This commit is contained in:
68
config/token.go
Normal file
68
config/token.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package config
|
||||
|
||||
type tokenConfig struct {
|
||||
// TokenName prefix
|
||||
TokenStyle string
|
||||
TokenPrefix string
|
||||
TokenName string
|
||||
|
||||
Timeout int64
|
||||
ActivityTimeout int64
|
||||
// Data clean period
|
||||
DataRefreshPeriod int64
|
||||
// Auto refresh token
|
||||
AutoRenew bool
|
||||
|
||||
// Allow multi login
|
||||
IsConcurrent bool
|
||||
IsShare bool
|
||||
// If (IsConcurrent == true && IsShare == false), support MaxLoginCount
|
||||
MaxLoginCount int16
|
||||
|
||||
// Read token method
|
||||
// Set to true to read token from these method before login.
|
||||
IsReadBody bool
|
||||
IsReadHeader bool
|
||||
IsReadCookie bool
|
||||
|
||||
// Write token to response header.
|
||||
// Set to true to write after login.
|
||||
IsWriteHeader bool
|
||||
|
||||
TokenSessionCheckLogin bool
|
||||
|
||||
JwtSecretKey string
|
||||
|
||||
CurDomain string
|
||||
|
||||
SameTokenTimeout int64
|
||||
|
||||
CheckSameToken bool
|
||||
|
||||
CookieConfig *cookieConfig
|
||||
}
|
||||
|
||||
func DefaultTokenConfig() *tokenConfig {
|
||||
return &tokenConfig{
|
||||
TokenStyle: "uuid",
|
||||
TokenPrefix: "",
|
||||
TokenName: "tokenGo",
|
||||
Timeout: 60 * 60 * 24 * 30,
|
||||
ActivityTimeout: -1,
|
||||
DataRefreshPeriod: 30,
|
||||
AutoRenew: true,
|
||||
IsConcurrent: true,
|
||||
IsShare: true,
|
||||
MaxLoginCount: 12,
|
||||
IsReadBody: true,
|
||||
IsReadHeader: true,
|
||||
IsReadCookie: true,
|
||||
IsWriteHeader: false,
|
||||
TokenSessionCheckLogin: true,
|
||||
JwtSecretKey: "",
|
||||
CurDomain: "",
|
||||
SameTokenTimeout: 60 * 60 * 24,
|
||||
CheckSameToken: false,
|
||||
CookieConfig: DefaultCookieConfig(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user