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

Fix templates which asset path points to external URL #1690

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

nabokihms
Copy link
Member

Description:

#1554 breaks the ability to specify an icon for header using external URL like this one.

I added check, that if assetURL points to external URL, no transformations required.

@sagikazarmark sagikazarmark added this to the v2.24.0 milestone May 12, 2020
@sagikazarmark
Copy link
Member

@nabokihms can you please rebase your branch?

@@ -176,6 +176,11 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
//assetPath is static/main.css
//relativeURL("/dex", "/dex/auth", "static/main.css") = "../static/main.css"
func relativeURL(serverPath, reqPath, assetPath string) string {
if u, err := url.ParseRequestURI(assetPath); err == nil && u.Scheme != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is actually correct. //kubernetes.io/images/favicon.png would be perfectly valid HTML as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

//kubernetes.io/images/favicon.png will be treated as a relative path because of the URL scheme is empty. Do you think we should limit the scheme to http/https instead?

Copy link
Member

Choose a reason for hiding this comment

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

//kubernetes.io/images/favicon.png is a valid URI and and I'm not sure it should be rewritten as a relative path.

Furthermore, Dex should usually be served over HTTPS, which means having an HTTP URL on the site will probably trigger browser security behavior.

TBH, that makes me think if supporting external URLs is a good idea in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made this PR because:

  • It can be handy to use with prebuilt docker images from the official repo. You only need to specify one URL in the config to add an icon instead of adding it to the docker image.
  • It fixes the broken behavior. Someone might suffer because of such breaking changes.

But I agree with the concerns that you raised. Frankly, we need to make a decision here.

Copy link
Member

Choose a reason for hiding this comment

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

So after thinking about this for a looooooong time, I think we can assume that people should always use HTTPS URLs these days, so not supporting the schemaless URL should be fine. I'm also not concerned about using http urls on an https site: if someone does that, it's their problem.

Limiting the scheme, however, is an interesting question. Does that pose a security risk if we just allow using any schemes there? not sure.

@sagikazarmark sagikazarmark modified the milestones: v2.24.0, v2.25.0 May 31, 2020
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
@nabokihms nabokihms changed the title Fix templates with asset paths that point to external URL Fix templates which asset path points to external URL Jul 16, 2020
Copy link
Member

@sagikazarmark sagikazarmark left a comment

Choose a reason for hiding this comment

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

Eh, let's just merge it. Thanks @nabokihms !

@@ -176,6 +176,11 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
//assetPath is static/main.css
//relativeURL("/dex", "/dex/auth", "static/main.css") = "../static/main.css"
func relativeURL(serverPath, reqPath, assetPath string) string {
if u, err := url.ParseRequestURI(assetPath); err == nil && u.Scheme != "" {
Copy link
Member

Choose a reason for hiding this comment

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

So after thinking about this for a looooooong time, I think we can assume that people should always use HTTPS URLs these days, so not supporting the schemaless URL should be fine. I'm also not concerned about using http urls on an https site: if someone does that, it's their problem.

Limiting the scheme, however, is an interesting question. Does that pose a security risk if we just allow using any schemes there? not sure.

@sagikazarmark sagikazarmark merged commit 9781e56 into dexidp:master Sep 29, 2020
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.

None yet

2 participants