Skip to content
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

fileserver: Add disable_canonical_uris Caddyfile subdirective #4222

Merged
merged 3 commits into from
Jul 1, 2021

Conversation

mritd
Copy link
Contributor

@mritd mritd commented Jun 27, 2021

add 'canonical_uris' parameter to caddyfile

reference #2741

Signed-off-by: mritd mritd@linux.com

add 'canonical_uris' parameter to caddyfile

reference caddyserver#2741

Signed-off-by: mritd <mritd@linux.com>
@CLAassistant
Copy link

CLAassistant commented Jun 27, 2021

CLA assistant check
All committers have signed the CLA.

@mholt mholt added the under review 🧐 Review is pending before merging label Jun 27, 2021
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch! This was an oversight when Caddyfile support was added to file_server early on it seems.

I think the UX of this option isn't consistent with other boolean options. Since CanonicalURIs being true is the same as being unset/nil (since the default is to enable the canonicalization redirects), I think the Caddyfile option should be called disable_canonical_uris and the argument should be removed.

Also, please add a Caddyfile adapt test (or update an existing one) to cover this option. See https://github.com/caddyserver/caddy/tree/master/caddytest/integration/caddyfile_adapt

@francislavoie francislavoie added this to the v2.4.4 milestone Jun 29, 2021
@francislavoie francislavoie changed the title feat(fileserver): add 'canonical_uris' parameter to caddyfile fileserver: Add canonical_uris Caddyfile subdirective Jun 29, 2021
mritd added 2 commits June 30, 2021 10:19
…nical_uris

rename subdirective canonical_uris to disable_canonical_uris

Signed-off-by: mritd <mritd@linux.com>
add disable_canonical_uris subdirective test file

Signed-off-by: mritd <mritd@linux.com>
@mritd
Copy link
Contributor Author

mritd commented Jun 30, 2021

Thanks for your reply, I have modified the subdirective UX, but I still have a question:

Is it necessary to add strict parameter verification here?

https://github.com/mritd/caddy/blob/737ead4e3de9b27d64f0b3dbd3e654149719b16c/modules/caddyhttp/fileserver/caddyfile.go#L117

case "disable_canonical_uris":
	if h.NextArg() {
		return nil, h.ArgErr()
	}

@francislavoie
Copy link
Member

Not necessary, but it's a nice to have to make sure invalid configs are rejected. If it's rejected, we know for sure nobody used an argument, so in the future if we want to add an argument for whatever reason, it wouldn't be a possibly breaking change.

@mritd
Copy link
Contributor Author

mritd commented Jun 30, 2021

Okay thank you 😁

@francislavoie francislavoie requested a review from mholt June 30, 2021 04:00
@mritd mritd changed the title fileserver: Add canonical_uris Caddyfile subdirective fileserver: Add disable_canonical_uris Caddyfile subdirective Jun 30, 2021
@mritd mritd changed the title fileserver: Add disable_canonical_uris Caddyfile subdirective fileserver: Add disable_canonical_uris Caddyfile subdirective Jun 30, 2021
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this'll probably come in handy.

@mholt mholt merged commit 4245ceb into caddyserver:master Jul 1, 2021
@mholt mholt removed the under review 🧐 Review is pending before merging label Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants