30 lines
890 B
Go
30 lines
890 B
Go
|
package auth
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
// Config authorization configuration parameters
|
||
|
type Config struct {
|
||
|
// access token expiration time, 0 means it doesn't expire
|
||
|
AccessTokenExp time.Duration
|
||
|
// refresh token expiration time, 0 means it doesn't expire
|
||
|
RefreshTokenExp time.Duration
|
||
|
// whether to generate the refreshing token
|
||
|
IsGenerateRefresh bool
|
||
|
}
|
||
|
|
||
|
// RefreshConfig refreshing token config
|
||
|
type RefreshConfig struct {
|
||
|
// whether to reset the refreshing creation time
|
||
|
IsResetRefreshTime bool
|
||
|
// whether to remove access token
|
||
|
IsRemoveAccess bool
|
||
|
// whether to remove refreshing token
|
||
|
IsRemoveRefreshing bool
|
||
|
}
|
||
|
|
||
|
// default configs
|
||
|
var (
|
||
|
DefaultAccessTokenCfg = &Config{AccessTokenExp: time.Hour * 24, RefreshTokenExp: time.Hour * 24 * 7, IsGenerateRefresh: true}
|
||
|
DefaultRefreshTokenCfg = &RefreshConfig{IsResetRefreshTime: true, IsRemoveAccess: true, IsRemoveRefreshing: true}
|
||
|
)
|