Bug 1250711

Summary: Keystone cannot cope with being behind an SSL terminator for version list
Product: Red Hat OpenStack Reporter: Jack Waterworth <jwaterwo>
Component: openstack-keystoneAssignee: Adam Young <ayoung>
Status: CLOSED ERRATA QA Contact: Rodrigo Duarte <rduartes>
Severity: high Docs Contact:
Priority: high    
Version: 6.0 (Juno)CC: akaris, ayoung, dmaley, jschluet, jwaterwo, nkinder, nlevinki, srevivo
Target Milestone: asyncKeywords: ZStream
Target Release: 6.0 (Juno)   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: openstack-keystone-2014.2.3-3.el7ost Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-01 12:29:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jack Waterworth 2015-08-05 19:34:44 UTC
Description of problem:

When keystone set up behind SSL termintator then it returns 'http' as protocol in URLs returned by version list command -

$ curl -g -i -X GET https://node1.example.com:8776/ -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
{"versions": [{"status": "SUPPORTED", "updated": "2014-06-28T12:20:21Z", "id": "v1.0", "links": [{"href": "http://10.180.58.131:8776/v1/", "rel": "self"}]}, {"status": "CURRENT", "updated": "2012-11-21T11:33:21Z", "id": "v2.0", "links": [{"href": "http://10.180.58.131:8776/v2/", "rel": "self"}]}]}

Version-Release number of selected component (if applicable):
openstack-keystone-2014.2.3-1.el7ost.noarch
python-keystone-2014.2.3-1.el7ost.noarch
python-keystoneclient-0.11.1-1.el7ost.noarch
python-keystonemiddleware-1.2.0-2.el7ost.noarch

How reproducible:
every time

Comment 3 Jack Waterworth 2015-08-05 19:35:33 UTC
upstream bug:
https://bugs.launchpad.net/keystone/+bug/1370022

customer has patched their own enviornment with the following patch

diff --git a/keystone/common/config.py b/keystone/common/config.py
index cc59f9d..aa19ac4 100644
--- a/keystone/common/config.py
+++ b/keystone/common/config.py
@@ -140,7 +140,12 @@
                          'exceeds the maximum length, the operation will fail '
                          'with an HTTP 403 Forbidden error. If set to false, '
                          'passwords are automatically truncated to the '
-                         'maximum length.')],
+                         'maximum length.'),
+        cfg.StrOpt('secure_proxy_ssl_header',
+                    help='The HTTP header used to determine the scheme for the '
+                         'original request, even if it was removed by an SSL '
+                         'terminating proxy. Typical value is '
+                         '"HTTP_X_FORWARDED_PROTO".'),],
     'identity': [
         cfg.StrOpt('default_domain_id', default='default',
                    help='This references the domain to use for all '
diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py
index 7d1d06d..60f21bf 100644
--- a/keystone/common/wsgi.py
+++ b/keystone/common/wsgi.py
@@ -196,6 +196,16 @@ def __call__(self, req):
         context['headers'] = dict(six.iteritems(req.headers))
         context['path'] = req.environ['PATH_INFO']
         context['host_url'] = req.host_url
+        scheme = (None if not CONF.secure_proxy_ssl_header
+                  else req.headers.get(CONF.secure_proxy_ssl_header))
+        if scheme:
+            # NOTE(andrey-mp): "wsgi.url_scheme" contains the protocol used
+            # before the proxy removed it ('https' usually). So if
+            # the webob.Request instance is modified in order to use this
+            # scheme instead of the one defined by API, the call to
+            # webob.Request.relative_url() will return a URL with the correct
+            # scheme.
+            req.environ['wsgi.url_scheme'] = scheme
         params = req.environ.get(PARAMS_ENV, {})
         # authentication and authorization attributes are set as environment
         # values by the container and processed by the pipeline.  the complete

Comment 18 errata-xmlrpc 2016-06-01 12:29:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1195

Comment 19 Nathan Kinder 2017-03-07 17:04:13 UTC
*** Bug 1340527 has been marked as a duplicate of this bug. ***