@@ -358,7 +358,7 @@ type DeploymentValues struct {
358
358
Telemetry TelemetryConfig `json:"telemetry,omitempty" typescript:",notnull"`
359
359
TLS TLSConfig `json:"tls,omitempty" typescript:",notnull"`
360
360
Trace TraceConfig `json:"trace,omitempty" typescript:",notnull"`
361
- SecureAuthCookie serpent. Bool `json:"secure_auth_cookie ,omitempty" typescript:",notnull"`
361
+ HTTPCookies HTTPCookieConfig `json:"http_cookies ,omitempty" typescript:",notnull"`
362
362
StrictTransportSecurity serpent.Int64 `json:"strict_transport_security,omitempty" typescript:",notnull"`
363
363
StrictTransportSecurityOptions serpent.StringArray `json:"strict_transport_security_options,omitempty" typescript:",notnull"`
364
364
SSHKeygenAlgorithm serpent.String `json:"ssh_keygen_algorithm,omitempty" typescript:",notnull"`
@@ -586,6 +586,30 @@ type TraceConfig struct {
586
586
DataDog serpent.Bool `json:"data_dog" typescript:",notnull"`
587
587
}
588
588
589
+ type HTTPCookieConfig struct {
590
+ Secure serpent.Bool `json:"secure_auth_cookie,omitempty" typescript:",notnull"`
591
+ SameSite string `json:"same_site,omitempty" typescript:",notnull"`
592
+ }
593
+
594
+ func (cfg HTTPCookieConfig ) Apply (c * http.Cookie ) * http.Cookie {
595
+ c .Secure = cfg .Secure .Value ()
596
+ c .SameSite = cfg .HTTPSameSite ()
597
+ return c
598
+ }
599
+
600
+ func (cfg HTTPCookieConfig ) HTTPSameSite () http.SameSite {
601
+ switch strings .ToLower (cfg .SameSite ) {
602
+ case "lax" :
603
+ return http .SameSiteLaxMode
604
+ case "strict" :
605
+ return http .SameSiteStrictMode
606
+ case "none" :
607
+ return http .SameSiteNoneMode
608
+ default :
609
+ return http .SameSiteDefaultMode
610
+ }
611
+ }
612
+
589
613
type ExternalAuthConfig struct {
590
614
// Type is the type of external auth config.
591
615
Type string `json:"type" yaml:"type"`
@@ -2376,11 +2400,23 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
2376
2400
Description : "Controls if the 'Secure' property is set on browser session cookies." ,
2377
2401
Flag : "secure-auth-cookie" ,
2378
2402
Env : "CODER_SECURE_AUTH_COOKIE" ,
2379
- Value : & c .SecureAuthCookie ,
2403
+ Value : & c .HTTPCookies . Secure ,
2380
2404
Group : & deploymentGroupNetworking ,
2381
2405
YAML : "secureAuthCookie" ,
2382
2406
Annotations : serpent.Annotations {}.Mark (annotationExternalProxies , "true" ),
2383
2407
},
2408
+ {
2409
+ Name : "SameSite Auth Cookie" ,
2410
+ Description : "Controls the 'SameSite' property is set on browser session cookies." ,
2411
+ Flag : "samesite-auth-cookie" ,
2412
+ Env : "CODER_SAMESITE_AUTH_COOKIE" ,
2413
+ // Do not allow "strict" same-site cookies. That would potentially break workspace apps.
2414
+ Value : serpent .EnumOf (& c .HTTPCookies .SameSite , "lax" , "none" ),
2415
+ Default : "lax" ,
2416
+ Group : & deploymentGroupNetworking ,
2417
+ YAML : "sameSiteAuthCookie" ,
2418
+ Annotations : serpent.Annotations {}.Mark (annotationExternalProxies , "true" ),
2419
+ },
2384
2420
{
2385
2421
Name : "Terms of Service URL" ,
2386
2422
Description : "A URL to an external Terms of Service that must be accepted by users when logging in." ,
0 commit comments