fix: raise RuntimeError when SESSION_SECRET_KEY is not set in setup_o…#103
Open
piyushdotcomm wants to merge 1 commit intosugarlabs:mainfrom
Open
fix: raise RuntimeError when SESSION_SECRET_KEY is not set in setup_o…#103piyushdotcomm wants to merge 1 commit intosugarlabs:mainfrom
piyushdotcomm wants to merge 1 commit intosugarlabs:mainfrom
Conversation
…auth Previously, setup_oauth() used a hardcoded fallback 'supersecretkey' when SESSION_SECRET_KEY was not set in the environment. This allowed anyone to forge session cookies and bypass OAuth authentication. Now the app refuses to start with a clear RuntimeError if the environment variable is missing, preventing silent deployment with an insecure secret. Adds tests/test_auth_setup.py with two pytest tests: - test_setup_oauth_raises_when_secret_missing - test_setup_oauth_succeeds_when_secret_set Fixes: sugarlabs#101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
setup_oauth() in app/auth.py used a hardcoded fallback value:
If
SESSION_SECRET_KEYwas not set in the environment, the app silentlyused
"supersecretkey"as the session signing key. Since this value ispublicly visible in the source code, anyone could forge valid session
cookies and gain authenticated access without going through OAuth.
The app gave no warning and did not refuse to start when running with
this insecure fallback.
Fix
Removed the hardcoded fallback. The app now validates
SESSION_SECRET_KEYat startup and raises a
RuntimeErrorwith a clear message if it is missing,preventing silent insecure deployments.
Fixes #101