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

[enh] exclude .well-known subpaths from conflict checks #1647

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

tituspijean
Copy link
Contributor

Attempts to solve:
Fixes YunoHost/issues#684
Fixes YunoHost/issues#2016

It basically adds an exception for app conflicts if an app is installed at the root of a domain and another app tries to add a ./well-known/foo subpath, but keeps returning a conflict if any two apps try to register the same ./well-known/foo subpath.

PR Status

Finished? Untested.

How to test

...

@@ -2869,7 +2869,7 @@ def _get_conflicting_apps(domain, path, ignore_app=None):
for p, a in apps_map[domain].items():
if a["id"] == ignore_app:
continue
if path == p or path == "/" or p == "/":
if path == p or ( not path.startswith("/.well-known/") and path == "/" ) or ( not path.startswith("/.well-known/") and p == "/" ):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if path == p or ( not path.startswith("/.well-known/") and path == "/" ) or ( not path.startswith("/.well-known/") and p == "/" ):
if path == p or ( not path.startswith("/.well-known/") and ( path == "/" or p == "/" ) ):

A bit of factorization

@alexAubin
Copy link
Member

Hmmmm, I'm confused by this PR 🤔 If two apps do add a location /.well-known/foo in nginx for the same domain, won't nginx refuse the configuration ? I feel like I'm missing something 😬

@tituspijean
Copy link
Contributor Author

It's been a while, I cannot remember why I implemented that. Basically this PR allows apps to publish something in /.well-known even though an app is installed at the root of the domain.

(and you misread the description, it states we still return an error if apps try to register the same ./well-known/foo path ;) )

@rodneyrod
Copy link

rodneyrod commented Apr 9, 2024

Thanks for the contribution, just to mention from testing I've done on a testbed server, it looks like the full_domain flag may need to have extra logic to prevent scripts for install and upgrade failing with the full_domain error.
I believe the step that's causing my tests to fail is this one (not a programmer by trade so I could be reading this wrong):

def _assert_no_conflicting_apps(domain, path, ignore_app=None, full_domain=False):
    conflicts = _get_conflicting_apps(domain, path, ignore_app)

    if conflicts:
        apps = []
        for path, app_id, app_label in conflicts:
            apps.append(f" * {domain}{path}{app_label} ({app_id})")

        if full_domain:
            raise YunohostValidationError("app_full_domain_unavailable", domain=domain)
        else:
            raise YunohostValidationError(
                "app_location_unavailable", apps="\n".join(apps)
            )

For testing, I've installed Friendica on example.com, then installed Synapse on m.example.com but configuring accounts to use user@example.com using the option in the setup script for that.
This works to install those apps if done in that order.
However, upgrading Friendica fails as example.com is detected as in use.
Additionally, if Synapse is installed first, Friendica will fail to install as the domain is detected as in use.

@tituspijean
Copy link
Contributor Author

Thank you for your testing! Can you share the failed installation log?

@centralscrutinizer21
Copy link

It worked for me. Bludit on / domain.com Synapse on matrix.domain.com and server name domain.com.
Recoverd Synapse from a backup, and then changed URL for Bludit from the temporary site.domain.com I had move it to, back to its original domain.com

@tituspijean tituspijean marked this pull request as draft April 29, 2024 18:59
@tituspijean
Copy link
Contributor Author

After further consideration, I would push for a dedicated "well-known path" resource, rather than patching the current "path" one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants