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

Support .well-known serving in handlers #1087

Closed
sbordet opened this issue Nov 9, 2016 · 9 comments · Fixed by #7000
Closed

Support .well-known serving in handlers #1087

sbordet opened this issue Nov 9, 2016 · 9 comments · Fixed by #7000
Assignees

Comments

@sbordet
Copy link
Contributor

sbordet commented Nov 9, 2016

The .well-known directory is being used for more and more things to automate operations related to websites.

For example, see #794.
Also, Let's Encrypt uses the .well-known directory to automate the issue of certificates.

For "normal" contexts, this is rather easy, since it's enough to add the .well-known directory to the resourceBase and it's done.

For less "normal" contexts, this is not doable.
For example, a MovedContextHandler would need to be able to serve content under .well-known and if that fails, fall back to the "moved" behavior.
Same goes for contexts that use a RedirectHandler.

The major problem is trying to serve the "/" URI.

Currently, a handler that has a resourceBase will try to serve / as a directory, or give a 403 if directory listing is not allowed.

What would be needed is a handler with some logic along these lines:

  • If URI matches /.well-known and descendants => serve it like a ResourceHandler would from file system
  • If URI matches / => forward to next/wrapped handler

So that is basically a ResourceHandler, but only for a particular directory (or set of paths).

If there are ways to achieve this, will be great to know.

@sbordet
Copy link
Contributor Author

sbordet commented Nov 10, 2016

Doh.

It's enough to add a context mapped to /.well-known.
It will be more specific than / and so preferred.

One such context could serve for multiple virtual hosts.

@sbordet sbordet closed this as completed Nov 10, 2016
@joakime
Copy link
Contributor

joakime commented Nov 10, 2016

@sbordet and @WalkerWatch would it be worth documenting this?

I can imagine this being a pretty common setup.

@gregw
Copy link
Contributor

gregw commented Nov 10, 2016

I think we should create a demo-base/webapps/well-known and a demo-base/webapps/well-known.xml in the standard jetty distro and then document it as well.

@joakime
Copy link
Contributor

joakime commented Dec 14, 2016

Interestingly, the concept of /.well-known/ in a URI is actually an RFC.

https://tools.ietf.org/html/rfc5785

@stale
Copy link

stale bot commented Nov 20, 2019

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale For auto-closed stale issues and pull requests label Nov 20, 2019
@joakime
Copy link
Contributor

joakime commented Nov 20, 2019

From a ${jetty.base} point of view, I think supporting something like we do for ${jetty.base}/webapps/ROOT/, but for this usecase.

Perhaps something like ${jetty.base}/webapps/WELL-KNOWN/ is a good start.

I didn't suggest ``${jetty.base}/webapps/.well-known/as that doesn't work (the directory starting with.` is seen as a hidden directory by the DeploymentManager currently.

We could make that specific directory /.well-known/ an exception in DeploymentManager.

If we go this route, should we allow directory listing by default?

For embedded-jetty, a ResourceHandler with .well-known directory support is already well supported.

@stale stale bot removed the Stale For auto-closed stale issues and pull requests label Nov 20, 2019
@sbordet
Copy link
Contributor Author

sbordet commented Nov 20, 2019

I don't think we need anything special, this XML file is enough:

<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
  <Set name="contextPath">/.well-known</Set>
  <Set name="handler">
    <New class="org.eclipse.jetty.server.handler.ResourceHandler">
      <Set name="resourceBase">/your/directory/.well-known</Set>
      <Set name="directoriesListed">false</Set>
    </New>
  </Set>
</Configure>

I guess it's only a documentation issue, and perhaps an example in demo-base.

@stale
Copy link

stale bot commented Nov 24, 2020

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale For auto-closed stale issues and pull requests label Nov 24, 2020
@stale
Copy link

stale bot commented Dec 24, 2020

This issue has been closed due to it having no activity.

@stale stale bot closed this as completed Dec 24, 2020
@WalkerWatch WalkerWatch reopened this Dec 24, 2020
@stale stale bot removed the Stale For auto-closed stale issues and pull requests label Dec 24, 2020
lachlan-roberts added a commit that referenced this issue Oct 15, 2021
lachlan-roberts added a commit that referenced this issue Oct 22, 2021
lachlan-roberts added a commit that referenced this issue Oct 24, 2021
lachlan-roberts added a commit that referenced this issue Nov 12, 2021
Signed-off-by: Lachlan Roberts <[email protected]>
lachlan-roberts added a commit that referenced this issue Nov 16, 2021
Issue #1087 - add module for a .well-known handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants