Allow specifying the proxy's auth class.

This commit is contained in:
gholt 2010-07-14 15:11:08 -07:00
parent 86eb77a021
commit f71850f547
3 changed files with 17 additions and 6 deletions

View File

@ -30,10 +30,15 @@ if __name__ == '__main__':
print "Unable to read config file."
sys.exit(1)
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')
c = ConfigParser()
c.read(os.path.join(swift_dir, 'auth-server.conf'))
auth_conf = dict(c.items('auth-server'))
m, c = auth_conf.get('class',
'swift.common.auth.DevAuthMiddleware').rsplit('.', 1)
m = __import__(m, fromlist=[c])
authware = m.__dict__[c]
memcache = MemcacheRing([s.strip() for s in
conf.get('memcache_servers', '127.0.0.1:11211').split(',')
@ -41,5 +46,5 @@ if __name__ == '__main__':
logger = get_logger(conf, 'proxy')
app = Application(conf, memcache, logger)
# 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)

View File

@ -33,3 +33,9 @@
# rate_limit_account_whitelist = acct1,acct2,etc
# rate_limit_account_blacklist = acct3,acct4,etc
# container_put_lock_timeout = 5
# [auth-server]
# class = swift.common.auth.DevAuthMiddleware
# ip = 127.0.0.1
# port = 11000
# node_timeout = 10

View File

@ -34,8 +34,8 @@ class DevAuthMiddleware(object):
self.memcache_client = memcache_client
self.logger = logger
self.conf = conf
self.auth_host = conf.get('bind_ip', '127.0.0.1')
self.auth_port = int(conf.get('bind_port', 11000))
self.auth_host = conf.get('ip', '127.0.0.1')
self.auth_port = int(conf.get('port', 11000))
self.timeout = int(conf.get('node_timeout', 10))
def __call__(self, env, start_response):