Merge "Use account_autocreate for tempauth."
This commit is contained in:
commit
30e71fa175
@ -270,6 +270,7 @@ Sample configuration files are provided with all defaults in line-by-line commen
|
||||
[app:proxy-server]
|
||||
use = egg:swift#proxy
|
||||
allow_account_management = true
|
||||
account_autocreate = true
|
||||
|
||||
[filter:tempauth]
|
||||
use = egg:swift#tempauth
|
||||
|
@ -40,6 +40,11 @@ class TempAuth(object):
|
||||
[pipeline:main]
|
||||
pipeline = catch_errors cache tempauth proxy-server
|
||||
|
||||
Set account auto creation to true in proxy-server.conf::
|
||||
|
||||
[app:proxy-server]
|
||||
account_autocreate = true
|
||||
|
||||
And add a tempauth filter section, such as::
|
||||
|
||||
[filter:tempauth]
|
||||
@ -94,7 +99,6 @@ class TempAuth(object):
|
||||
groups = values
|
||||
self.users[conf_key.split('_', 1)[1].replace('_', ':')] = {
|
||||
'key': key, 'url': url, 'groups': values}
|
||||
self.created_accounts = False
|
||||
|
||||
def __call__(self, env, start_response):
|
||||
"""
|
||||
@ -116,26 +120,6 @@ class TempAuth(object):
|
||||
will be routed through the internal auth request handler (self.handle).
|
||||
This is to handle granting tokens, etc.
|
||||
"""
|
||||
# Ensure the accounts we handle have been created
|
||||
if not self.created_accounts and self.users:
|
||||
newenv = {'REQUEST_METHOD': 'HEAD', 'HTTP_USER_AGENT': 'TempAuth'}
|
||||
for name in ('swift.cache', 'HTTP_X_TRANS_ID'):
|
||||
if name in env:
|
||||
newenv[name] = env[name]
|
||||
for key, value in self.users.iteritems():
|
||||
account_id = value['url'].rsplit('/', 1)[-1]
|
||||
newenv['REQUEST_METHOD'] = 'HEAD'
|
||||
resp = Request.blank('/v1/' + account_id,
|
||||
environ=newenv).get_response(self.app)
|
||||
if resp.status_int // 100 != 2:
|
||||
newenv['REQUEST_METHOD'] = 'PUT'
|
||||
resp = Request.blank('/v1/' + account_id,
|
||||
environ=newenv).get_response(self.app)
|
||||
if resp.status_int // 100 != 2:
|
||||
raise Exception('Could not create account %s for user '
|
||||
'%s' % (account_id, key))
|
||||
self.created_accounts = True
|
||||
|
||||
if env.get('PATH_INFO', '').startswith(self.auth_prefix):
|
||||
return self.handle(env, start_response)
|
||||
s3 = env.get('HTTP_AUTHORIZATION')
|
||||
|
Loading…
Reference in New Issue
Block a user