Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into user-management
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeinated92 committed Jun 11, 2024
2 parents 017ea86 + 609335d commit 43f5dd3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ type Config struct {
OAuthClientID string `mapstructure:"api-oauth-client-id" toml:"api-oauth-client-id" json:"apiOAuthClientID"`
OAuthClientSecret string `mapstructure:"api-oauth-client-secret" toml:"api-oauth-client-secret" json:"apiOAuthClientSecret"`
CacheStaticMaxAge int `mapstructure:"cache-static-max-age" toml:"cache-static-max-age" json:"-"`
TokenTimeout int `mapstructure:"api-token-timeout" toml:"api-token-timeout" json:"apiTokenTimeout"`
//OAuthRedirectURL string `mapstructure:"api-oauth-redirect-url" toml:"git-url" json:"-"`
// BackupResticStoragePolicy string `mapstructure:"backup-restic-storage-policy" toml:"backup-restic-storage-policy" json:"backupResticStoragePolicy"`
//ProvMode string `mapstructure:"prov-mode" toml:"prov-mode" json:"provMode"` //InitContainer vs API
Expand Down
5 changes: 3 additions & 2 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (repman *ReplicationManager) loginHandler(w http.ResponseWriter, r *http.Re
//set claims
claims["iss"] = "https://api.replication-manager.signal18.io"
claims["iat"] = time.Now().Unix()
claims["exp"] = time.Now().Add(time.Hour * 48).Unix()
claims["exp"] = time.Now().Add(time.Hour * time.Duration(repman.Conf.TokenTimeout)).Unix()
claims["jti"] = "1" // should be user ID(?)
claims["CustomUserInfo"] = struct {
Name string
Expand All @@ -360,6 +360,7 @@ func (repman *ReplicationManager) loginHandler(w http.ResponseWriter, r *http.Re
//sk, _ := jwt.ParseRSAPublicKeyFromPEM(signingKey)

tokenString, err := signer.SignedString(sk)
// log.Printf("Token expiration: %d hour\n", repman.Conf.TokenTimeout)

if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down Expand Up @@ -461,7 +462,7 @@ func (repman *ReplicationManager) handlerMuxAuthCallback(w http.ResponseWriter,
//set claims
claims["iss"] = "https://api.replication-manager.signal18.io"
claims["iat"] = time.Now().Unix()
claims["exp"] = time.Now().Add(time.Hour * 48).Unix()
claims["exp"] = time.Now().Add(time.Hour * time.Duration(repman.Conf.TokenTimeout)).Unix()
claims["jti"] = "1" // should be user ID(?)
claims["CustomUserInfo"] = struct {
Name string
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (repman *ReplicationManager) SetDefaultFlags(v *viper.Viper) {
}

func (repman *ReplicationManager) AddFlags(flags *pflag.FlagSet, conf *config.Config) {
flags.IntVar(&conf.TokenTimeout, "api-token-timeout", 48, "Timespan of API Token before expired in hour")

if WithDeprecate == "ON" {
// initDeprecated() // not needed used alias in main
Expand Down

0 comments on commit 43f5dd3

Please sign in to comment.