0
0
Fork 0

fix: cookie problem

This commit is contained in:
하누 2023-03-22 14:35:54 +00:00 committed by GitHub
parent e9630d8988
commit ae4f0ce925
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

5
app.py
View file

@ -64,13 +64,14 @@ async def link():
return RedirectResponse(auth_url) return RedirectResponse(auth_url)
@app.get('/callback/steam') @app.get('/callback/steam')
async def setup(request: Request, response: Response): async def setup(request: Request):
valid = await validate(dict(request.query_params)) valid = await validate(dict(request.query_params))
if not valid: if not valid:
raise HTTPException(status_code=404, detail="We can't verify that you have Steam profile.") raise HTTPException(status_code=404, detail="We can't verify that you have Steam profile.")
url = client.get_oauth_url() url = client.get_oauth_url()
response = RedirectResponse(url=url)
response.set_cookie(key="steam_id", value=encrypt(request.query_params.get("openid.claimed_id")), max_age=1800) response.set_cookie(key="steam_id", value=encrypt(request.query_params.get("openid.claimed_id")), max_age=1800)
return RedirectResponse(url=url) return response
async def validate(data: dict) -> bool: async def validate(data: dict) -> bool:
base = "https://steamcommunity.com/openid/login" base = "https://steamcommunity.com/openid/login"