Extract merchant id from url

Change-Id: Ide09cbf2cec70b190795a79a29517f208e37fbc2
This commit is contained in:
Endre Karlson 2013-07-28 16:19:37 +00:00
parent d58917d573
commit 5897c3cf5a
1 changed files with 8 additions and 1 deletions

View File

@ -43,10 +43,17 @@ def pipeline_factory(loader, global_conf, **local_conf):
class NoAuthContextMiddleware(wsgi.Middleware):
def merchant_id(self, request):
parts = [p for p in request.path_info.split('/') if p]
if parts[0] == 'merchants' and len(parts) >= 2:
return parts[1]
def process_request(self, request):
merchant_id = self.merchant_id(request)
# NOTE(kiall): This makes the assumption that disabling authentication
# means you wish to allow full access to everyone.
context = RequestContext(is_admin=True)
context = RequestContext(is_admin=True, tenant=merchant_id)
# Store the context where oslo-log exepcts to find it.
local.store.context = context