Add Refresh token
This commit is contained in:
+21
-2
@@ -3,8 +3,10 @@ package config
|
||||
import "time"
|
||||
|
||||
type AuthConfig struct {
|
||||
jwtTokenExpiresTTL int
|
||||
jwtTokenSecret string
|
||||
jwtTokenExpiresTTL int
|
||||
jwtTokenSecret string
|
||||
refreshTokenExpiresTTL int
|
||||
refreshTokenSecret string
|
||||
}
|
||||
|
||||
type JWT struct {
|
||||
@@ -20,3 +22,20 @@ func (c *AuthConfig) AccessTokenExpiresDate() time.Time {
|
||||
duration := time.Duration(c.jwtTokenExpiresTTL)
|
||||
return time.Now().UTC().Add(time.Minute * duration)
|
||||
}
|
||||
|
||||
func (c *AuthConfig) RefreshTokenSecret() string {
|
||||
return c.refreshTokenSecret
|
||||
}
|
||||
|
||||
func (c *AuthConfig) RefreshTokenExpiresDate() time.Time {
|
||||
duration := time.Duration(c.refreshTokenExpiresTTL)
|
||||
return time.Now().UTC().Add(time.Minute * duration)
|
||||
}
|
||||
|
||||
func (c *AuthConfig) AccessTokenTTL() time.Duration {
|
||||
return time.Duration(c.jwtTokenExpiresTTL) * time.Minute
|
||||
}
|
||||
|
||||
func (c *AuthConfig) RefreshTokenTTL() time.Duration {
|
||||
return time.Duration(c.refreshTokenExpiresTTL) * time.Minute
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user