cc29fe8618fc75957ccfc1840965084d01ffed4b
[openstack-build/django_openstack_auth-build.git] / centos7 / rpm / SOURCES / 0006-Use-unscoped-token-for-scoping-to-project.patch
1 From cb5040934c3132dbddbb5c24d45f76d2f4fbc062 Mon Sep 17 00:00:00 2001
2 From: lin-hua-cheng <os.lcheng@gmail.com>
3 Date: Wed, 15 Jul 2015 11:13:38 -0700
4 Subject: [PATCH] Use unscoped token for scoping to project
5
6 When authenticating a user in v3, always request
7 for an unscoped token. Otherwise it would automatically
8 default to the default project.
9
10 Change-Id: I9e1d9129e2fb35933c803096fca9f1236affc27f
11 Closes-Bug: #1474893
12 (cherry picked from commit e4062e37069d58814b7c09299d3018297a75ba1d)
13 ---
14  openstack_auth/backend.py         | 8 +++-----
15  openstack_auth/plugin/password.py | 3 ++-
16  openstack_auth/tests/tests.py     | 3 ++-
17  3 files changed, 7 insertions(+), 7 deletions(-)
18
19 diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py
20 index 46c32d4..3859638 100644
21 --- a/openstack_auth/backend.py
22 +++ b/openstack_auth/backend.py
23 @@ -138,11 +138,9 @@ class KeystoneBackend(object):
24          request = kwargs.get('request')
25  
26          if request:
27 -            # Check if token is automatically scoped to default_project
28 -            # grab the project from this token, to use as a default
29 -            # if no recent_project is found in the cookie
30 -            recent_project = request.COOKIES.get('recent_project',
31 -                                                 unscoped_auth_ref.project_id)
32 +            # Grab recent_project found in the cookie, try to scope
33 +            # to the last project used.
34 +            recent_project = request.COOKIES.get('recent_project')
35  
36          # if a most recent project was found, try using it first
37          if recent_project:
38 diff --git a/openstack_auth/plugin/password.py b/openstack_auth/plugin/password.py
39 index 484adc2..4143f25 100644
40 --- a/openstack_auth/plugin/password.py
41 +++ b/openstack_auth/plugin/password.py
42 @@ -42,7 +42,8 @@ class PasswordPlugin(base.BasePlugin):
43              return v3_auth.Password(auth_url=auth_url,
44                                      username=username,
45                                      password=password,
46 -                                    user_domain_name=user_domain_name)
47 +                                    user_domain_name=user_domain_name,
48 +                                    unscoped=True)
49  
50          else:
51              return v2_auth.Password(auth_url=auth_url,
52 diff --git a/openstack_auth/tests/tests.py b/openstack_auth/tests/tests.py
53 index 09bdc76..467f814 100644
54 --- a/openstack_auth/tests/tests.py
55 +++ b/openstack_auth/tests/tests.py
56 @@ -496,7 +496,8 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin, test.TestCase):
57          return auth_v3.Password(auth_url=url,
58                                  password=password,
59                                  username=username,
60 -                                user_domain_name=DEFAULT_DOMAIN)
61 +                                user_domain_name=DEFAULT_DOMAIN,
62 +                                unscoped=True)
63  
64      def _create_token_auth(self, project_id, token=None, url=None):
65          if not token: