diff options
author | Anike Arni <aarni@thoughtworks.com> | 2017-02-16 18:51:26 -0200 |
---|---|---|
committer | Anike Arni <aarni@thoughtworks.com> | 2017-02-16 18:51:26 -0200 |
commit | 957599ae01687d6b3d02a3c34fdbe2ac6bd920f9 (patch) | |
tree | 7612fa7cfd33bd9657bce0eb9e8db47b076cedcc /service/pixelated/resources/root_resource.py | |
parent | 64780114ae90bb890d3ffa0a9aebe4686c6b74d3 (diff) |
[#907] Bundles login static files separately
Due to conflicts with public and protected urls, login and interstitial
files have to be on a different public url from inbox and resources that
require login. Therefore, here, we delegate that logic to webpack. Now
we have a '/public' url and a '/assets' url for those static assets.
Diffstat (limited to 'service/pixelated/resources/root_resource.py')
-rw-r--r-- | service/pixelated/resources/root_resource.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py index 37a0013e..320a1204 100644 --- a/service/pixelated/resources/root_resource.py +++ b/service/pixelated/resources/root_resource.py @@ -20,7 +20,7 @@ from string import Template from pixelated.resources.users import UsersResource from pixelated.resources import BaseResource, UnAuthorizedResource, UnavailableResource -from pixelated.resources import get_static_folder +from pixelated.resources import get_public_static_folder, get_protected_static_folder from pixelated.resources.attachments_resource import AttachmentsResource from pixelated.resources.sandbox_resource import SandboxResource from pixelated.resources.backup_account_resource import BackupAccountResource @@ -51,16 +51,17 @@ MODE_RUNNING = 2 class RootResource(BaseResource): def __init__(self, services_factory): BaseResource.__init__(self, services_factory) - self._static_folder = get_static_folder() - self._html_template = open(os.path.join(self._static_folder, 'index.html')).read() + self._public_static_folder = get_public_static_folder() + self._protected_static_folder = get_protected_static_folder() + self._html_template = open(os.path.join(self._protected_static_folder, 'index.html')).read() self._services_factory = services_factory self._child_resources = ChildResourcesMap() - with open(os.path.join(self._static_folder, 'interstitial.html')) as f: + with open(os.path.join(self._public_static_folder, 'interstitial.html')) as f: self.interstitial = f.read() self._startup_mode() def _startup_mode(self): - self.putChild('assets', File(self._static_folder)) + self.putChild('public', File(self._public_static_folder)) self.putChild('status', LoginStatusResource(self._services_factory)) self._mode = MODE_STARTUP @@ -89,8 +90,9 @@ class RootResource(BaseResource): return csrf_input and csrf_input == xsrf_token def initialize(self, provider=None, disclaimer_banner=None, authenticator=None): + self._child_resources.add('assets', File(self._protected_static_folder)) self._child_resources.add('backup-account', BackupAccountResource(self._services_factory)) - self._child_resources.add('sandbox', SandboxResource(self._static_folder)) + self._child_resources.add('sandbox', SandboxResource(self._protected_static_folder)) self._child_resources.add('keys', KeysResource(self._services_factory)) self._child_resources.add(AttachmentsResource.BASE_URL, AttachmentsResource(self._services_factory)) self._child_resources.add('contacts', ContactsResource(self._services_factory)) |