Use configuration for report url duration
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -31,6 +31,7 @@ type (
|
|||||||
CookieDomain string `json:"cookie-domain"`
|
CookieDomain string `json:"cookie-domain"`
|
||||||
CookieDuration int `json:"cookie-duration"`
|
CookieDuration int `json:"cookie-duration"`
|
||||||
TokenDuration int `json:"token-duration"`
|
TokenDuration int `json:"token-duration"`
|
||||||
|
ReportURLDuration int `json:"report-url-duration"`
|
||||||
TokenSecret string `json:"token-secret"`
|
TokenSecret string `json:"token-secret"`
|
||||||
Scope string `json:"scope"`
|
Scope string `json:"scope"`
|
||||||
TokenType string `json:"token-type"`
|
TokenType string `json:"token-type"`
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ func New() *Implm {
|
|||||||
CookieDomain: "localhost",
|
CookieDomain: "localhost",
|
||||||
CookieDuration: 24,
|
CookieDuration: 24,
|
||||||
TokenDuration: 168,
|
TokenDuration: 168,
|
||||||
|
ReportURLDuration: 15,
|
||||||
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
||||||
Scope: "trust_center_readonly",
|
Scope: "trust_center_readonly",
|
||||||
TokenType: "trust_center_access",
|
TokenType: "trust_center_access",
|
||||||
@@ -288,6 +289,7 @@ func (impl *Implm) Run(
|
|||||||
CookieDomain: impl.cfg.TrustAuth.CookieDomain,
|
CookieDomain: impl.cfg.TrustAuth.CookieDomain,
|
||||||
CookieDuration: time.Duration(impl.cfg.TrustAuth.CookieDuration) * time.Hour,
|
CookieDuration: time.Duration(impl.cfg.TrustAuth.CookieDuration) * time.Hour,
|
||||||
TokenDuration: time.Duration(impl.cfg.TrustAuth.TokenDuration) * 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,
|
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
||||||
Scope: impl.cfg.TrustAuth.Scope,
|
Scope: impl.cfg.TrustAuth.Scope,
|
||||||
TokenType: impl.cfg.TrustAuth.TokenType,
|
TokenType: impl.cfg.TrustAuth.TokenType,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type (
|
|||||||
CookieDomain string
|
CookieDomain string
|
||||||
CookieDuration time.Duration
|
CookieDuration time.Duration
|
||||||
TokenDuration time.Duration
|
TokenDuration time.Duration
|
||||||
|
ReportURLDuration time.Duration
|
||||||
TokenSecret string
|
TokenSecret string
|
||||||
Scope string
|
Scope string
|
||||||
TokenType string
|
TokenType string
|
||||||
@@ -174,6 +175,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
CookieDomain: s.cfg.TrustAuth.CookieDomain,
|
CookieDomain: s.cfg.TrustAuth.CookieDomain,
|
||||||
CookieDuration: s.cfg.TrustAuth.CookieDuration,
|
CookieDuration: s.cfg.TrustAuth.CookieDuration,
|
||||||
TokenDuration: s.cfg.TrustAuth.TokenDuration,
|
TokenDuration: s.cfg.TrustAuth.TokenDuration,
|
||||||
|
ReportURLDuration: s.cfg.TrustAuth.ReportURLDuration,
|
||||||
TokenSecret: s.cfg.TrustAuth.TokenSecret,
|
TokenSecret: s.cfg.TrustAuth.TokenSecret,
|
||||||
Scope: s.cfg.TrustAuth.Scope,
|
Scope: s.cfg.TrustAuth.Scope,
|
||||||
TokenType: s.cfg.TrustAuth.TokenType,
|
TokenType: s.cfg.TrustAuth.TokenType,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type (
|
|||||||
CookieDomain string
|
CookieDomain string
|
||||||
CookieDuration time.Duration
|
CookieDuration time.Duration
|
||||||
TokenDuration time.Duration
|
TokenDuration time.Duration
|
||||||
|
ReportURLDuration time.Duration
|
||||||
TokenSecret string
|
TokenSecret string
|
||||||
Scope string
|
Scope string
|
||||||
TokenType string
|
TokenType string
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func (r *auditResolver) ReportURL(ctx context.Context, obj *types.Audit) (*strin
|
|||||||
return nil, nil
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot generate report URL: %w", err)
|
return nil, fmt.Errorf("cannot generate report URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user