-
Notifications
You must be signed in to change notification settings - Fork 896
fix: accept legacy redirect HTTP environment variables #10748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
cli/server.go
Outdated
// corresponding flag!) "CODER_TLS_REDIRECT_HTTP", and it appeared in a configuration | ||
// example, so we keep accepting it to not break backward compat. | ||
func redirectHTTPToHTTPSDeprecation(ctx context.Context, logger slog.Logger, inv *clibase.Invocation, cfg *codersdk.DeploymentValues) { | ||
if inv.Environ.Get("CODER_TLS_REDIRECT_HTTP") == "true" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use strconv.ParseBool
as well instead of comparing the raw values.
cli/server.go
Outdated
if inv.Environ.Get("CODER_TLS_REDIRECT_HTTP") == "true" || | ||
inv.Environ.Get("CODER_TLS_REDIRECT_HTTP_TO_HTTPS") == "true" || | ||
inv.ParsedFlags().Changed("tls-redirect-http-to-https") { | ||
logger.Warn(ctx, "--tls-redirect-http-to-https is deprecated, please use --redirect-to-access-url instead") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may sound silly, but adding some
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a mess indeed! Couple of suggestions.
30f40f1
to
1e1f734
Compare
Merge activity
|
Oh man, what a mess. It looks like
CODER_TLS_REDIRECT_HTTP
appears in our config docs. Maybe that was the initial name for the environment variable?At some point, both the flag and the environment variable were
--tls-redirect-http-to-https
andCODER_TLS_REDIRECT_HTTP_TO_HTTPS
.CODER_TLS_REDIRECT_HTTP
did nothing.However, then we introduced
CODER_REDIRECT_TO_ACCESS_URL
, we put in some deprecation code that was maybe fat-fingered such that we accept the environment variableCODER_TLS_REDIRECT_HTTP
but the flag--tls-redirect-http-to-https
. Our docs still refer toCODER_TLS_REDIRECT_HTTP
at https://coder.com/docs/v2/latest/admin/configure#addressSo, I think what we gotta do is still accept
CODER_TLS_REDIRECT_HTTP
since it was working and in an example doc, but also fix the deprecation code to acceptCODER_TLS_REDIRECT_HTTP_TO_HTTPS
environment variable.