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

Create and select user_principal based on web authenticated user. #179

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pusateri
Copy link

I'm not expecting this to get merged right now. Just putting it here for a place holder and feedback. Will begin working on get_resource() ACLS.

Also updates nginx example to pass $remote_user as HTTP_X_REMOTE_USER from a proxy.

Pass $remote_user as HTTP_X_REMOTE_USER from a proxy.
Copy link
Owner

@jelmer jelmer left a comment

Choose a reason for hiding this comment

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

Thanks! I think this looks reasonable overall. Left two minor comments inline.

We should add similar logic for the non-wsgi codepath in xandikos/web.py

xandikos/web.py Outdated Show resolved Hide resolved
@@ -1030,6 +1030,14 @@ def get_resource(self, relpath):
except KeyError:
return None

def set_principal(self, user):
principal = "/%s/" % user
Copy link
Owner

Choose a reason for hiding this comment

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

Ideally this path would be configurable, but we could leave that for a follow-up PR.

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean something like:

def set_principal(self, user, principal_path_prefix="/", principal_path_suffix="/"):
    principal = principal_path_prefix + user + principal_path_suffix

Copy link
Owner

Choose a reason for hiding this comment

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

Yep, exactly. Though we'd probably want those extra paths to come from a command-line argument/configuration file.

Copy link
Author

Choose a reason for hiding this comment

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

Can you explain SCRIPT_NAME?

Copy link
Owner

Choose a reason for hiding this comment

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

SCRIPT_NAME is a bit of a misnomer, but it's named after a similar variable in the CGI world - it's the bit of the path to Xandikos itself. If Xandikos is under https://foo.example.com/dav/, then SCRIPT_NAME would be /dav/.

@pusateri
Copy link
Author

We should add similar logic for the non-wsgi codepath in xandikos/web.py

If the non-wsgi codepath is web.py:main(), doesn't the current_user_principal argument do the same thing? Or do you want read the REMOTE_USER as an environment variable? Is run_simple_server() even used anywhere?

@jelmer
Copy link
Owner

jelmer commented Aug 31, 2022

Sorry for the delay - I've been traveling - but should be able to follow up more quickly during the next couple of weeks.

We should add similar logic for the non-wsgi codepath in xandikos/web.py

If the non-wsgi codepath is web.py:main(), doesn't the current_user_principal argument do the same thing? Or do you want read the REMOTE_USER as an environment variable?

In the non-wsgi codepath, REMOTE_USER could vary per request, so we can't read it from the environment. Right now, we just have a single principal, but in the future XandikosApp can't have a current_user_principal variable since there will be multiple. Hope that makes sense.

is run_simple_server() even used anywhere?

run_simple_server() is (meant to be) used in the testsuites of CalDAV/CardDAV client applications and libraries like pycaldav and vdirsync. It allows them to quickly spin up a trivial server to run tests against.

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.

2 participants