gtsocial-umbx

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

config.go (1484B)


      1 package manage
      2 
      3 import "time"
      4 
      5 // Config authorization configuration parameters
      6 type Config struct {
      7 	// access token expiration time, 0 means it doesn't expire
      8 	AccessTokenExp time.Duration
      9 	// refresh token expiration time, 0 means it doesn't expire
     10 	RefreshTokenExp time.Duration
     11 	// whether to generate the refreshing token
     12 	IsGenerateRefresh bool
     13 }
     14 
     15 // RefreshingConfig refreshing token config
     16 type RefreshingConfig struct {
     17 	// access token expiration time, 0 means it doesn't expire
     18 	AccessTokenExp time.Duration
     19 	// refresh token expiration time, 0 means it doesn't expire
     20 	RefreshTokenExp time.Duration
     21 	// whether to generate the refreshing token
     22 	IsGenerateRefresh bool
     23 	// whether to reset the refreshing create time
     24 	IsResetRefreshTime bool
     25 	// whether to remove access token
     26 	IsRemoveAccess bool
     27 	// whether to remove refreshing token
     28 	IsRemoveRefreshing bool
     29 }
     30 
     31 // default configs
     32 var (
     33 	DefaultCodeExp               = time.Minute * 10
     34 	DefaultAuthorizeCodeTokenCfg = &Config{AccessTokenExp: time.Hour * 2, RefreshTokenExp: time.Hour * 24 * 3, IsGenerateRefresh: true}
     35 	DefaultImplicitTokenCfg      = &Config{AccessTokenExp: time.Hour * 1}
     36 	DefaultPasswordTokenCfg      = &Config{AccessTokenExp: time.Hour * 2, RefreshTokenExp: time.Hour * 24 * 7, IsGenerateRefresh: true}
     37 	DefaultClientTokenCfg        = &Config{AccessTokenExp: time.Hour * 2}
     38 	DefaultRefreshTokenCfg       = &RefreshingConfig{IsGenerateRefresh: true, IsRemoveAccess: true, IsRemoveRefreshing: true}
     39 )