This commit is contained in:
yumoqing 2023-07-19 11:38:09 +08:00
parent 1f1dc764d4
commit 43b45f2645
2 changed files with 8 additions and 7 deletions

View File

@ -35,17 +35,15 @@ class AuthAPI(AppLogger):
self.getPrivateKey() self.getPrivateKey()
return self.rsaEngine.decode(self.privatekey,cdata) return self.rsaEngine.decode(self.privatekey,cdata)
def setupAuth(self,app): async def setupAuth(self,app):
# setup session middleware in aiohttp fashion # setup session middleware in aiohttp fashion
storage = EncryptedCookieStorage(urandom(32)) storage = EncryptedCookieStorage(urandom(32))
"""
if self.conf.website.session_redis: if self.conf.website.session_redis:
url = self.conf.website.session_redis.url url = self.conf.website.session_redis.url
# redis = await aioredis.from_url("redis://127.0.0.1:6379") # redis = await aioredis.from_url("redis://127.0.0.1:6379")
redis = await aioredis.from_url(url) redis = await aioredis.from_url(url)
storage = aiohttp_session.redis_storage.RedisStorage(redis) storage = aiohttp_session.redis_storage.RedisStorage(redis)
"""
aiohttp_session.setup(app, storage) aiohttp_session.setup(app, storage)
# Create an auth ticket mechanism that expires after 1 minute (60 # Create an auth ticket mechanism that expires after 1 minute (60

View File

@ -40,9 +40,12 @@ class ConfiguredServer(AppLogger):
print(f'{client_max_size=}') print(f'{client_max_size=}')
self.app = web.Application(client_max_size=client_max_size) self.app = web.Application(client_max_size=client_max_size)
def run(self): async def init_auth(self):
auth = self.auth_klass() auth = self.auth_klass()
auth.setupAuth(self.app) await auth.setupAuth(self.app)
return self.app
def run(self):
config = getConfig() config = getConfig()
self.configPath(config) self.configPath(config)
a = TmpFileRecord() a = TmpFileRecord()
@ -52,7 +55,7 @@ class ConfiguredServer(AppLogger):
ssl_context.load_cert_chain(config.website.ssl.crtfile, ssl_context.load_cert_chain(config.website.ssl.crtfile,
config.website.ssl.keyfile) config.website.ssl.keyfile)
web.run_app(self.app,host=config.website.host or '0.0.0.0', web.run_app(self.init_auth(),host=config.website.host or '0.0.0.0',
port=config.website.port or 8080, port=config.website.port or 8080,
ssl_context=ssl_context) ssl_context=ssl_context)