Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session states do not match exception #82

Open
robintw opened this issue Feb 28, 2022 · 4 comments
Open

Session states do not match exception #82

robintw opened this issue Feb 28, 2022 · 4 comments

Comments

@robintw
Copy link
Contributor

robintw commented Feb 28, 2022

I've run into a strange problem where I'm suddenly getting a Session states do not match error when trying to login in my app using fastapi_aad_auth. Everything was working fine and then I suddenly started getting this error, and I'm pretty sure I haven't changed anything.

I can see that the error is raised from state.py, line 91:

raise AuthenticationError("Session states do not match")

Are you able to provide any information on why there might be a mismatch in session states occurring here? I've tried this on two different computers with two different AAD logins, and it is occurring in both situations. I've tried running locally and it is working fine, so I'm only running into the error on the version that is hosted on Azure. I've tried restarting the Azure Functions app, and that hasn't solved it.

Also, on a different note: my boss has just pointed out that I'm working for the same company as you! I'm working with Sam Murphy.

@djpugh
Copy link
Owner

djpugh commented Feb 28, 2022

If you are running multi-threaded/multi-instance, you will need to set the session secrets as env vars so they are consistent e.g. across functions

@djpugh
Copy link
Owner

djpugh commented Feb 28, 2022

See

class AuthSessionConfig(BaseSettings):
"""Authentication Session configuration.
Contains secret and salt information (should be set as environment
variables in a multi-worker/multi-processing environment to enable
authentication across workers)
"""
secret: SecretStr = Field(default_factory=lambda: str(uuid.uuid4()), description="Secret used for encoding authentication information",
env='SESSION_AUTH_SECRET')
salt: SecretStr = Field(default_factory=lambda: str(uuid.uuid4()), description="Salt used for encoding authentication information",
env='SESSION_AUTH_SALT')

@robintw
Copy link
Contributor Author

robintw commented Feb 28, 2022

Thanks, that's solved the problem :)

I'll see if I can find an appropriate place to put this in the docs and do a PR.

@djpugh
Copy link
Owner

djpugh commented Feb 28, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants