Use configuration for report url duration
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -27,13 +27,14 @@ type (
|
||||
}
|
||||
|
||||
trustAuthConfig struct {
|
||||
CookieName string `json:"cookie-name"`
|
||||
CookieDomain string `json:"cookie-domain"`
|
||||
CookieDuration int `json:"cookie-duration"`
|
||||
TokenDuration int `json:"token-duration"`
|
||||
TokenSecret string `json:"token-secret"`
|
||||
Scope string `json:"scope"`
|
||||
TokenType string `json:"token-type"`
|
||||
CookieName string `json:"cookie-name"`
|
||||
CookieDomain string `json:"cookie-domain"`
|
||||
CookieDuration int `json:"cookie-duration"`
|
||||
TokenDuration int `json:"token-duration"`
|
||||
ReportURLDuration int `json:"report-url-duration"`
|
||||
TokenSecret string `json:"token-secret"`
|
||||
Scope string `json:"scope"`
|
||||
TokenType string `json:"token-type"`
|
||||
}
|
||||
|
||||
cookieConfig struct {
|
||||
|
||||
@@ -102,13 +102,14 @@ func New() *Implm {
|
||||
DisableSignup: false,
|
||||
},
|
||||
TrustAuth: trustAuthConfig{
|
||||
CookieName: "TCT",
|
||||
CookieDomain: "localhost",
|
||||
CookieDuration: 24,
|
||||
TokenDuration: 168,
|
||||
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
||||
Scope: "trust_center_readonly",
|
||||
TokenType: "trust_center_access",
|
||||
CookieName: "TCT",
|
||||
CookieDomain: "localhost",
|
||||
CookieDuration: 24,
|
||||
TokenDuration: 168,
|
||||
ReportURLDuration: 15,
|
||||
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
||||
Scope: "trust_center_readonly",
|
||||
TokenType: "trust_center_access",
|
||||
},
|
||||
AWS: awsConfig{
|
||||
Region: "us-east-1",
|
||||
@@ -284,13 +285,14 @@ func (impl *Implm) Run(
|
||||
CookieSecret: impl.cfg.Auth.Cookie.Secret,
|
||||
},
|
||||
TrustAuth: api.TrustAuthConfig{
|
||||
CookieName: impl.cfg.TrustAuth.CookieName,
|
||||
CookieDomain: impl.cfg.TrustAuth.CookieDomain,
|
||||
CookieDuration: time.Duration(impl.cfg.TrustAuth.CookieDuration) * time.Hour,
|
||||
TokenDuration: time.Duration(impl.cfg.TrustAuth.TokenDuration) * time.Hour,
|
||||
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
||||
Scope: impl.cfg.TrustAuth.Scope,
|
||||
TokenType: impl.cfg.TrustAuth.TokenType,
|
||||
CookieName: impl.cfg.TrustAuth.CookieName,
|
||||
CookieDomain: impl.cfg.TrustAuth.CookieDomain,
|
||||
CookieDuration: time.Duration(impl.cfg.TrustAuth.CookieDuration) * time.Hour,
|
||||
TokenDuration: time.Duration(impl.cfg.TrustAuth.TokenDuration) * time.Hour,
|
||||
ReportURLDuration: time.Duration(impl.cfg.TrustAuth.ReportURLDuration) * time.Minute,
|
||||
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
||||
Scope: impl.cfg.TrustAuth.Scope,
|
||||
TokenType: impl.cfg.TrustAuth.TokenType,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -42,13 +42,14 @@ type (
|
||||
}
|
||||
|
||||
TrustAuthConfig struct {
|
||||
CookieName string
|
||||
CookieDomain string
|
||||
CookieDuration time.Duration
|
||||
TokenDuration time.Duration
|
||||
TokenSecret string
|
||||
Scope string
|
||||
TokenType string
|
||||
CookieName string
|
||||
CookieDomain string
|
||||
CookieDuration time.Duration
|
||||
TokenDuration time.Duration
|
||||
ReportURLDuration time.Duration
|
||||
TokenSecret string
|
||||
Scope string
|
||||
TokenType string
|
||||
}
|
||||
|
||||
Config struct {
|
||||
@@ -170,13 +171,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
CookieSecret: s.cfg.Auth.CookieSecret,
|
||||
},
|
||||
trust_v1.TrustAuthConfig{
|
||||
CookieName: s.cfg.TrustAuth.CookieName,
|
||||
CookieDomain: s.cfg.TrustAuth.CookieDomain,
|
||||
CookieDuration: s.cfg.TrustAuth.CookieDuration,
|
||||
TokenDuration: s.cfg.TrustAuth.TokenDuration,
|
||||
TokenSecret: s.cfg.TrustAuth.TokenSecret,
|
||||
Scope: s.cfg.TrustAuth.Scope,
|
||||
TokenType: s.cfg.TrustAuth.TokenType,
|
||||
CookieName: s.cfg.TrustAuth.CookieName,
|
||||
CookieDomain: s.cfg.TrustAuth.CookieDomain,
|
||||
CookieDuration: s.cfg.TrustAuth.CookieDuration,
|
||||
TokenDuration: s.cfg.TrustAuth.TokenDuration,
|
||||
ReportURLDuration: s.cfg.TrustAuth.ReportURLDuration,
|
||||
TokenSecret: s.cfg.TrustAuth.TokenSecret,
|
||||
Scope: s.cfg.TrustAuth.Scope,
|
||||
TokenType: s.cfg.TrustAuth.TokenType,
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@@ -42,13 +42,14 @@ import (
|
||||
|
||||
type (
|
||||
TrustAuthConfig struct {
|
||||
CookieName string
|
||||
CookieDomain string
|
||||
CookieDuration time.Duration
|
||||
TokenDuration time.Duration
|
||||
TokenSecret string
|
||||
Scope string
|
||||
TokenType string
|
||||
CookieName string
|
||||
CookieDomain string
|
||||
CookieDuration time.Duration
|
||||
TokenDuration time.Duration
|
||||
ReportURLDuration time.Duration
|
||||
TokenSecret string
|
||||
Scope string
|
||||
TokenType string
|
||||
}
|
||||
|
||||
Resolver struct {
|
||||
|
||||
@@ -73,7 +73,7 @@ func (r *auditResolver) ReportURL(ctx context.Context, obj *types.Audit) (*strin
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
url, err := trust.Audits.GenerateReportURL(ctx, obj.ID, 15*time.Minute)
|
||||
url, err := trust.Audits.GenerateReportURL(ctx, obj.ID, r.trustAuthCfg.ReportURLDuration)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate report URL: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user