Allow specifying the proxy's auth class.
This commit is contained in:
@@ -30,10 +30,15 @@ if __name__ == '__main__':
|
|||||||
print "Unable to read config file."
|
print "Unable to read config file."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
conf = dict(c.items('proxy-server'))
|
conf = dict(c.items('proxy-server'))
|
||||||
|
if c.has_section('auth-server'):
|
||||||
|
auth_conf = dict(c.items('auth-server'))
|
||||||
|
else:
|
||||||
|
auth_conf = {}
|
||||||
swift_dir = conf.get('swift_dir', '/etc/swift')
|
swift_dir = conf.get('swift_dir', '/etc/swift')
|
||||||
c = ConfigParser()
|
m, c = auth_conf.get('class',
|
||||||
c.read(os.path.join(swift_dir, 'auth-server.conf'))
|
'swift.common.auth.DevAuthMiddleware').rsplit('.', 1)
|
||||||
auth_conf = dict(c.items('auth-server'))
|
m = __import__(m, fromlist=[c])
|
||||||
|
authware = m.__dict__[c]
|
||||||
|
|
||||||
memcache = MemcacheRing([s.strip() for s in
|
memcache = MemcacheRing([s.strip() for s in
|
||||||
conf.get('memcache_servers', '127.0.0.1:11211').split(',')
|
conf.get('memcache_servers', '127.0.0.1:11211').split(',')
|
||||||
@@ -41,5 +46,5 @@ if __name__ == '__main__':
|
|||||||
logger = get_logger(conf, 'proxy')
|
logger = get_logger(conf, 'proxy')
|
||||||
app = Application(conf, memcache, logger)
|
app = Application(conf, memcache, logger)
|
||||||
# Wrap the app with auth
|
# Wrap the app with auth
|
||||||
app = DevAuthMiddleware(app, auth_conf, memcache, logger)
|
app = authware(app, auth_conf, memcache, logger)
|
||||||
run_wsgi(app, conf, logger=logger, default_port=80)
|
run_wsgi(app, conf, logger=logger, default_port=80)
|
||||||
|
@@ -33,3 +33,9 @@
|
|||||||
# rate_limit_account_whitelist = acct1,acct2,etc
|
# rate_limit_account_whitelist = acct1,acct2,etc
|
||||||
# rate_limit_account_blacklist = acct3,acct4,etc
|
# rate_limit_account_blacklist = acct3,acct4,etc
|
||||||
# container_put_lock_timeout = 5
|
# container_put_lock_timeout = 5
|
||||||
|
|
||||||
|
# [auth-server]
|
||||||
|
# class = swift.common.auth.DevAuthMiddleware
|
||||||
|
# ip = 127.0.0.1
|
||||||
|
# port = 11000
|
||||||
|
# node_timeout = 10
|
||||||
|
@@ -34,8 +34,8 @@ class DevAuthMiddleware(object):
|
|||||||
self.memcache_client = memcache_client
|
self.memcache_client = memcache_client
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.auth_host = conf.get('bind_ip', '127.0.0.1')
|
self.auth_host = conf.get('ip', '127.0.0.1')
|
||||||
self.auth_port = int(conf.get('bind_port', 11000))
|
self.auth_port = int(conf.get('port', 11000))
|
||||||
self.timeout = int(conf.get('node_timeout', 10))
|
self.timeout = int(conf.get('node_timeout', 10))
|
||||||
|
|
||||||
def __call__(self, env, start_response):
|
def __call__(self, env, start_response):
|
||||||
|
Reference in New Issue
Block a user