chore!: automatically use secure cookies if using https access-url (#22198)

`--secure-auth-cookie` now automatically sources it's default value from `--access-url`

If the access url uses HTTPS, secure is set to `true`. 
To revert to old behavior, set the value explicitly to `false`
This commit is contained in:
Steven Masley
2026-02-20 10:33:37 -06:00
committed by GitHub
parent efdaaa2c8f
commit b0f35316da
11 changed files with 25 additions and 9 deletions
+12
View File
@@ -1740,6 +1740,18 @@ func TestServer(t *testing.T) {
// Next, we instruct the same server to display the YAML config
// and then save it.
// Because this is literally the same invocation, DefaultFn sets the
// value of 'Default'. Which triggers a mutually exclusive error
// on the next parse.
// Usually we only parse flags once, so this is not an issue
for _, c := range inv.Command.Children {
if c.Name() == "server" {
for i := range c.Options {
c.Options[i].DefaultFn = nil
}
break
}
}
inv = inv.WithContext(testutil.Context(t, testutil.WaitMedium))
//nolint:gocritic
inv.Args = append(args, "--write-config")
+1 -1
View File
@@ -383,7 +383,7 @@ NETWORKING OPTIONS:
--samesite-auth-cookie lax|none, $CODER_SAMESITE_AUTH_COOKIE (default: lax)
Controls the 'SameSite' property is set on browser session cookies.
--secure-auth-cookie bool, $CODER_SECURE_AUTH_COOKIE
--secure-auth-cookie bool, $CODER_SECURE_AUTH_COOKIE (default: false)
Controls if the 'Secure' property is set on browser session cookies.
--wildcard-access-url string, $CODER_WILDCARD_ACCESS_URL
+1 -1
View File
@@ -176,7 +176,7 @@ networking:
# (default: <unset>, type: string-array)
proxyTrustedOrigins: []
# Controls if the 'Secure' property is set on browser session cookies.
# (default: <unset>, type: bool)
# (default: false, type: bool)
secureAuthCookie: false
# Controls the 'SameSite' property is set on browser session cookies.
# (default: lax, type: enum[lax\|none])
+1 -1
View File
@@ -22875,7 +22875,7 @@ const docTemplate = `{
]
},
"default": {
"description": "Default is parsed into Value if set.",
"description": "Default is parsed into Value if set.\nMust be ` + "`" + `\"\"` + "`" + ` if ` + "`" + `DefaultFn` + "`" + ` != nil",
"type": "string"
},
"description": {
+1 -1
View File
@@ -21045,7 +21045,7 @@
]
},
"default": {
"description": "Default is parsed into Value if set.",
"description": "Default is parsed into Value if set.\nMust be `\"\"` if `DefaultFn` != nil",
"type": "string"
},
"description": {
+3
View File
@@ -2890,6 +2890,9 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
Description: "Controls if the 'Secure' property is set on browser session cookies.",
Flag: "secure-auth-cookie",
Env: "CODER_SECURE_AUTH_COOKIE",
DefaultFn: func() string {
return strconv.FormatBool(c.AccessURL.Scheme == "https")
},
Value: &c.HTTPCookies.Secure,
Group: &deploymentGroupNetworking,
YAML: "secureAuthCookie",
+1 -1
View File
@@ -14123,7 +14123,7 @@ None
| Name | Type | Required | Restrictions | Description |
|------------------|--------------------------------------------|----------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| `annotations` | [serpent.Annotations](#serpentannotations) | false | | Annotations enable extensions to serpent higher up in the stack. It's useful for help formatting and documentation generation. |
| `default` | string | false | | Default is parsed into Value if set. |
| `default` | string | false | | Default is parsed into Value if set. Must be `""` if `DefaultFn` != nil |
| `description` | string | false | | |
| `env` | string | false | | Env is the environment variable used to configure this option. If unset, environment configuring is disabled. |
| `flag` | string | false | | Flag is the long name of the flag used to configure this option. If unset, flag configuring is disabled. |
+1 -1
View File
@@ -384,7 +384,7 @@ NETWORKING OPTIONS:
--samesite-auth-cookie lax|none, $CODER_SAMESITE_AUTH_COOKIE (default: lax)
Controls the 'SameSite' property is set on browser session cookies.
--secure-auth-cookie bool, $CODER_SECURE_AUTH_COOKIE
--secure-auth-cookie bool, $CODER_SECURE_AUTH_COOKIE (default: false)
Controls if the 'Secure' property is set on browser session cookies.
--wildcard-access-url string, $CODER_WILDCARD_ACCESS_URL
+1 -1
View File
@@ -101,7 +101,7 @@ require (
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0
github.com/coder/quartz v0.3.0
github.com/coder/retry v1.5.1
github.com/coder/serpent v0.13.0
github.com/coder/serpent v0.14.0
github.com/coder/terraform-provider-coder/v2 v2.13.1
github.com/coder/websocket v1.8.14
github.com/coder/wgtunnel v0.2.0
+2 -2
View File
@@ -959,8 +959,8 @@ github.com/coder/quartz v0.3.0 h1:bUoSEJ77NBfKtUqv6CPSC0AS8dsjqAqqAv7bN02m1mg=
github.com/coder/quartz v0.3.0/go.mod h1:BgE7DOj/8NfvRgvKw0jPLDQH/2Lya2kxcTaNJ8X0rZk=
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY=
github.com/coder/serpent v0.13.0 h1:6EoWjpEypkb8cS6i0eCF4qoAv9vrEVaX26RW+3FMMvo=
github.com/coder/serpent v0.13.0/go.mod h1:7OIvFBYMd+OqarMy5einBl8AtRr8LliopVU7pyrwucY=
github.com/coder/serpent v0.14.0 h1:g7vt2zBMp3nWyAvyhvQduaI53Ku65U3wITMi01+/8pU=
github.com/coder/serpent v0.14.0/go.mod h1:7OIvFBYMd+OqarMy5einBl8AtRr8LliopVU7pyrwucY=
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 h1:YoUSJ19E8AtuUFVYBpXuOD6a/zVP3rcxezNsoDseTUw=
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788/go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ=
github.com/coder/tailscale v1.1.1-0.20250829055706-6eafe0f9199e h1:9RKGKzGLHtTvVBQublzDGtCtal3cXP13diCHoAIGPeI=
+1
View File
@@ -4604,6 +4604,7 @@ export interface SerpentOption {
readonly yaml?: string;
/**
* Default is parsed into Value if set.
* Must be `""` if `DefaultFn` != nil
*/
readonly default?: string;
/**