config.go 890 B

1234567891011121314151617181920212223242526272829
  1. package auth
  2. import "time"
  3. // Config authorization configuration parameters
  4. type Config struct {
  5. // access token expiration time, 0 means it doesn't expire
  6. AccessTokenExp time.Duration
  7. // refresh token expiration time, 0 means it doesn't expire
  8. RefreshTokenExp time.Duration
  9. // whether to generate the refreshing token
  10. IsGenerateRefresh bool
  11. }
  12. // RefreshConfig refreshing token config
  13. type RefreshConfig struct {
  14. // whether to reset the refreshing creation time
  15. IsResetRefreshTime bool
  16. // whether to remove access token
  17. IsRemoveAccess bool
  18. // whether to remove refreshing token
  19. IsRemoveRefreshing bool
  20. }
  21. // default configs
  22. var (
  23. DefaultAccessTokenCfg = &Config{AccessTokenExp: time.Hour * 24, RefreshTokenExp: time.Hour * 24 * 7, IsGenerateRefresh: true}
  24. DefaultRefreshTokenCfg = &RefreshConfig{IsResetRefreshTime: true, IsRemoveAccess: true, IsRemoveRefreshing: true}
  25. )