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()
return self.rsaEngine.decode(self.privatekey,cdata)
def setupAuth(self,app):
async def setupAuth(self,app):
# setup session middleware in aiohttp fashion
storage = EncryptedCookieStorage(urandom(32))
"""
if self.conf.website.session_redis:
url = self.conf.website.session_redis.url
# redis = await aioredis.from_url("redis://127.0.0.1:6379")
redis = await aioredis.from_url(url)
storage = aiohttp_session.redis_storage.RedisStorage(redis)
"""
aiohttp_session.setup(app, storage)
# Create an auth ticket mechanism that expires after 1 minute (60

View File

@ -39,10 +39,13 @@ class ConfiguredServer(AppLogger):
print(f'{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.setupAuth(self.app)
await auth.setupAuth(self.app)
return self.app
def run(self):
config = getConfig()
self.configPath(config)
a = TmpFileRecord()
@ -52,7 +55,7 @@ class ConfiguredServer(AppLogger):
ssl_context.load_cert_chain(config.website.ssl.crtfile,
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,
ssl_context=ssl_context)