Code Repositories xandikos / 5aa6f4b
Use SCRIPT_NAME to determine current user principal. Jelmer Vernooń≥ 2 years ago
4 changed file(s) with 8 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
757757 """A wsgi App that provides a Xandikos web server.
758758 """
759759
760 def __init__(self, backend, current_user_principal_href):
760 def __init__(self, backend, current_user_principal):
761761 super(XandikosApp, self).__init__(backend)
762762 self.register_properties([
763763 webdav.ResourceTypeProperty(),
764764 webdav.CurrentUserPrincipalProperty(
765 current_user_principal_href),
765 current_user_principal),
766766 webdav.PrincipalURLProperty(),
767767 webdav.DisplayNameProperty(),
768768 webdav.GetETagProperty(),
938938 'Run xandikos with --autocreate?',
939939 options.current_user_principal)
940940
941 current_user_principal_href = posixpath.join(
942 options.route_prefix,
943 options.current_user_principal.lstrip('/'))
944
945941 app = XandikosApp(
946942 backend,
947 current_user_principal_href=current_user_principal_href)
943 current_user_principal=options.current_user_principal)
948944
949945 from wsgiref.simple_server import make_server
950946 app = WellknownRedirector(app, options.route_prefix)
487487 def __init__(self, current_user_principal):
488488 super(CurrentUserPrincipalProperty, self).__init__()
489489 self.current_user_principal = ensure_trailing_slash(
490 current_user_principal)
490 current_user_principal.lstrip('/'))
491491
492492 def get_value(self, href, resource, el, environ):
493493 """Get property with specified name.
497497 if self.current_user_principal is None:
498498 ET.SubElement(el, '{DAV:}unauthenticated')
499499 else:
500 # TODO(jelmer): Ideally this should receive
501 # SCRIPT_NAME and prefix the returned URL with that.
502 el.append(create_href(self.current_user_principal))
500 el.append(create_href(
501 self.current_user_principal, environ['SCRIPT_NAME']))
503502
504503
505504 class PrincipalURLProperty(Property):
2121
2222 import logging
2323 import os
24 import urllib.parse
2524
2625 from xandikos.web import XandikosBackend, XandikosApp
2726
4645 current_user_principal))
4746
4847 backend._mark_as_principal(current_user_principal)
49 current_user_principal_href = urllib.parse.urljoin(
50 os.environ.get('ROUTE_PREFIX', '/'), current_user_principal.lstrip('/'))
51 app = XandikosApp(backend, current_user_principal_href)
48 app = XandikosApp(backend, current_user_principal)
3131 Path to current user principal.
3232 .TP
3333 \fB\-\-route\-prefix\fR=\fI\,ROUTE_PREFIX\/\fR
34 Path to Xandikos. This is useful when Xandikos is behind a reverse proxy, and e.g. being served from a path.
34 Path to Xandikos. This is useful when Xandikos is behind a reverse proxy, and not being served from the root of the host.
3535 .PP
3636 E.g. if Xandikos is served from http://example.com/dav/, specify --route-prefix=/dav/.
3737 .TP