Skip to content

Commit 30e71fa

Browse files
Jenkinsopenstack-gerrit
Jenkins
authored andcommitted
Merge "Use account_autocreate for tempauth."
2 parents 7286502 + 6170e66 commit 30e71fa

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

doc/source/development_saio.rst

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ Sample configuration files are provided with all defaults in line-by-line commen
270270
[app:proxy-server]
271271
use = egg:swift#proxy
272272
allow_account_management = true
273+
account_autocreate = true
273274

274275
[filter:tempauth]
275276
use = egg:swift#tempauth

swift/common/middleware/tempauth.py

+5-21
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class TempAuth(object):
4040
[pipeline:main]
4141
pipeline = catch_errors cache tempauth proxy-server
4242
43+
Set account auto creation to true in proxy-server.conf::
44+
45+
[app:proxy-server]
46+
account_autocreate = true
47+
4348
And add a tempauth filter section, such as::
4449
4550
[filter:tempauth]
@@ -94,7 +99,6 @@ def __init__(self, app, conf):
9499
groups = values
95100
self.users[conf_key.split('_', 1)[1].replace('_', ':')] = {
96101
'key': key, 'url': url, 'groups': values}
97-
self.created_accounts = False
98102

99103
def __call__(self, env, start_response):
100104
"""
@@ -116,26 +120,6 @@ def __call__(self, env, start_response):
116120
will be routed through the internal auth request handler (self.handle).
117121
This is to handle granting tokens, etc.
118122
"""
119-
# Ensure the accounts we handle have been created
120-
if not self.created_accounts and self.users:
121-
newenv = {'REQUEST_METHOD': 'HEAD', 'HTTP_USER_AGENT': 'TempAuth'}
122-
for name in ('swift.cache', 'HTTP_X_TRANS_ID'):
123-
if name in env:
124-
newenv[name] = env[name]
125-
for key, value in self.users.iteritems():
126-
account_id = value['url'].rsplit('/', 1)[-1]
127-
newenv['REQUEST_METHOD'] = 'HEAD'
128-
resp = Request.blank('/v1/' + account_id,
129-
environ=newenv).get_response(self.app)
130-
if resp.status_int // 100 != 2:
131-
newenv['REQUEST_METHOD'] = 'PUT'
132-
resp = Request.blank('/v1/' + account_id,
133-
environ=newenv).get_response(self.app)
134-
if resp.status_int // 100 != 2:
135-
raise Exception('Could not create account %s for user '
136-
'%s' % (account_id, key))
137-
self.created_accounts = True
138-
139123
if env.get('PATH_INFO', '').startswith(self.auth_prefix):
140124
return self.handle(env, start_response)
141125
s3 = env.get('HTTP_AUTHORIZATION')

0 commit comments

Comments
 (0)