Merge lp:~james-page/charms/trusty/keystone/bug-1371795 into lp:~openstack-charmers-archive/charms/trusty/keystone/next

Proposed by James Page
Status: Merged
Merged at revision: 81
Proposed branch: lp:~james-page/charms/trusty/keystone/bug-1371795
Merge into: lp:~openstack-charmers-archive/charms/trusty/keystone/next
Diff against target: 103 lines (+33/-22)
3 files modified
hooks/keystone_context.py (+15/-1)
hooks/keystone_utils.py (+12/-17)
templates/icehouse/keystone.conf (+6/-4)
To merge this branch: bzr merge lp:~james-page/charms/trusty/keystone/bug-1371795
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+235428@code.launchpad.net

Description of the change

Fixup keystone responses to unauthenticated requests when running under https

To post a comment you must log in.
Revision history for this message
Corey Bryant (corey.bryant) wrote :

The code looks good, I just have one comment inline below about adding a test. What is the minimal additional setup for getting up and running with https endpoints? Do I just need use-https = 'yes' and https-service-endpoints = 'true' for keystone?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/keystone_context.py'
2--- hooks/keystone_context.py 2014-08-12 05:39:51 +0000
3+++ hooks/keystone_context.py 2014-09-22 08:44:18 +0000
4@@ -94,7 +94,11 @@
5 interfaces = []
6
7 def __call__(self):
8- from keystone_utils import api_port, set_admin_token
9+ from keystone_utils import (
10+ api_port, set_admin_token,
11+ endpoint_url, resolve_address,
12+ PUBLIC, ADMIN
13+ )
14 ctxt = {}
15 ctxt['token'] = set_admin_token(config('admin-token'))
16 ctxt['admin_port'] = determine_api_port(api_port('keystone-admin'))
17@@ -116,4 +120,14 @@
18
19 if config('enable-pki') not in ['false', 'False', 'no', 'No']:
20 ctxt['signing'] = True
21+
22+ # Base endpoint URL's which are used in keystone responses
23+ # to unauthenticated requests to redirect clients to the
24+ # correct auth URL.
25+ ctxt['public_endpoint'] = endpoint_url(
26+ resolve_address(PUBLIC),
27+ api_port('keystone-public')).rstrip('v2.0')
28+ ctxt['admin_endpoint'] = endpoint_url(
29+ resolve_address(ADMIN),
30+ api_port('keystone-admin')).rstrip('v2.0')
31 return ctxt
32
33=== modified file 'hooks/keystone_utils.py'
34--- hooks/keystone_utils.py 2014-09-05 15:24:44 +0000
35+++ hooks/keystone_utils.py 2014-09-22 08:44:18 +0000
36@@ -495,26 +495,21 @@
37 auth_port=config("admin-port"),
38 region=region)
39
40+def endpoint_url(ip, port):
41+ proto = 'http'
42+ if https():
43+ proto = 'https'
44+ if is_ipv6(ip):
45+ ip = "[{}]".format(ip)
46+ return "%s://%s:%s/v2.0" % (proto, ip, port)
47+
48
49 def create_keystone_endpoint(public_ip, service_port,
50 internal_ip, admin_ip, auth_port, region):
51- proto = 'http'
52- if https():
53- log("Setting https keystone endpoint")
54- proto = 'https'
55-
56- if is_ipv6(public_ip):
57- public_ip = "[{}]".format(public_ip)
58- if is_ipv6(internal_ip):
59- internal_ip = "[{}]".format(internal_ip)
60- if is_ipv6(admin_ip):
61- admin_ip = "[{}]".format(admin_ip)
62-
63- public_url = "%s://%s:%s/v2.0" % (proto, public_ip, service_port)
64- admin_url = "%s://%s:%s/v2.0" % (proto, admin_ip, auth_port)
65- internal_url = "%s://%s:%s/v2.0" % (proto, internal_ip, service_port)
66- create_endpoint_template(region, "keystone", public_url,
67- admin_url, internal_url)
68+ create_endpoint_template(region, "keystone",
69+ endpoint_url(public_ip, service_port),
70+ endpoint_url(admin_ip, auth_port),
71+ endpoint_url(internal_ip, service_port))
72
73
74 def update_user_password(username, password):
75
76=== modified file 'templates/icehouse/keystone.conf'
77--- templates/icehouse/keystone.conf 2014-08-12 05:39:51 +0000
78+++ templates/icehouse/keystone.conf 2014-09-22 08:44:18 +0000
79@@ -11,6 +11,8 @@
80 log_config = /etc/keystone/logging.conf
81 debug = {{ debug }}
82 verbose = {{ verbose }}
83+public_endpoint = {{ public_endpoint }}
84+admin_endpoint = {{ admin_endpoint }}
85
86 [database]
87 {% if database_host -%}
88@@ -74,11 +76,11 @@
89 password = {{ ldap_password }}
90 suffix = {{ ldap_suffix }}
91
92-{% if ldap_config_flags -%}
93-{% for key, value in ldap_config_flags.iteritems() -%}
94+{% if ldap_config_flags -%}
95+{% for key, value in ldap_config_flags.iteritems() -%}
96 {{ key }} = {{ value }}
97-{% endfor -%}
98-{% endif -%}
99+{% endfor -%}
100+{% endif -%}
101
102 {% if ldap_readonly -%}
103 user_allow_create = False

Subscribers

People subscribed via source and target branches