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 {
|
trustAuthConfig struct {
|
||||||
CookieName string `json:"cookie-name"`
|
CookieName string `json:"cookie-name"`
|
||||||
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"`
|
||||||
TokenSecret string `json:"token-secret"`
|
ReportURLDuration int `json:"report-url-duration"`
|
||||||
Scope string `json:"scope"`
|
TokenSecret string `json:"token-secret"`
|
||||||
TokenType string `json:"token-type"`
|
Scope string `json:"scope"`
|
||||||
|
TokenType string `json:"token-type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
cookieConfig struct {
|
cookieConfig struct {
|
||||||
|
|||||||
@@ -102,13 +102,14 @@ func New() *Implm {
|
|||||||
DisableSignup: false,
|
DisableSignup: false,
|
||||||
},
|
},
|
||||||
TrustAuth: trustAuthConfig{
|
TrustAuth: trustAuthConfig{
|
||||||
CookieName: "TCT",
|
CookieName: "TCT",
|
||||||
CookieDomain: "localhost",
|
CookieDomain: "localhost",
|
||||||
CookieDuration: 24,
|
CookieDuration: 24,
|
||||||
TokenDuration: 168,
|
TokenDuration: 168,
|
||||||
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
ReportURLDuration: 15,
|
||||||
Scope: "trust_center_readonly",
|
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
||||||
TokenType: "trust_center_access",
|
Scope: "trust_center_readonly",
|
||||||
|
TokenType: "trust_center_access",
|
||||||
},
|
},
|
||||||
AWS: awsConfig{
|
AWS: awsConfig{
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
@@ -284,13 +285,14 @@ func (impl *Implm) Run(
|
|||||||
CookieSecret: impl.cfg.Auth.Cookie.Secret,
|
CookieSecret: impl.cfg.Auth.Cookie.Secret,
|
||||||
},
|
},
|
||||||
TrustAuth: api.TrustAuthConfig{
|
TrustAuth: api.TrustAuthConfig{
|
||||||
CookieName: impl.cfg.TrustAuth.CookieName,
|
CookieName: impl.cfg.TrustAuth.CookieName,
|
||||||
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,
|
||||||
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
ReportURLDuration: time.Duration(impl.cfg.TrustAuth.ReportURLDuration) * time.Minute,
|
||||||
Scope: impl.cfg.TrustAuth.Scope,
|
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
||||||
TokenType: impl.cfg.TrustAuth.TokenType,
|
Scope: impl.cfg.TrustAuth.Scope,
|
||||||
|
TokenType: impl.cfg.TrustAuth.TokenType,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -42,13 +42,14 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrustAuthConfig struct {
|
TrustAuthConfig struct {
|
||||||
CookieName string
|
CookieName string
|
||||||
CookieDomain string
|
CookieDomain string
|
||||||
CookieDuration time.Duration
|
CookieDuration time.Duration
|
||||||
TokenDuration time.Duration
|
TokenDuration time.Duration
|
||||||
TokenSecret string
|
ReportURLDuration time.Duration
|
||||||
Scope string
|
TokenSecret string
|
||||||
TokenType string
|
Scope string
|
||||||
|
TokenType string
|
||||||
}
|
}
|
||||||
|
|
||||||
Config struct {
|
Config struct {
|
||||||
@@ -170,13 +171,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
CookieSecret: s.cfg.Auth.CookieSecret,
|
CookieSecret: s.cfg.Auth.CookieSecret,
|
||||||
},
|
},
|
||||||
trust_v1.TrustAuthConfig{
|
trust_v1.TrustAuthConfig{
|
||||||
CookieName: s.cfg.TrustAuth.CookieName,
|
CookieName: s.cfg.TrustAuth.CookieName,
|
||||||
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,
|
||||||
TokenSecret: s.cfg.TrustAuth.TokenSecret,
|
ReportURLDuration: s.cfg.TrustAuth.ReportURLDuration,
|
||||||
Scope: s.cfg.TrustAuth.Scope,
|
TokenSecret: s.cfg.TrustAuth.TokenSecret,
|
||||||
TokenType: s.cfg.TrustAuth.TokenType,
|
Scope: s.cfg.TrustAuth.Scope,
|
||||||
|
TokenType: s.cfg.TrustAuth.TokenType,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -42,13 +42,14 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
TrustAuthConfig struct {
|
TrustAuthConfig struct {
|
||||||
CookieName string
|
CookieName string
|
||||||
CookieDomain string
|
CookieDomain string
|
||||||
CookieDuration time.Duration
|
CookieDuration time.Duration
|
||||||
TokenDuration time.Duration
|
TokenDuration time.Duration
|
||||||
TokenSecret string
|
ReportURLDuration time.Duration
|
||||||
Scope string
|
TokenSecret string
|
||||||
TokenType string
|
Scope string
|
||||||
|
TokenType string
|
||||||
}
|
}
|
||||||
|
|
||||||
Resolver struct {
|
Resolver struct {
|
||||||
|
|||||||
@@ -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