Skip to content

Commit

Permalink
GH-112: Explicitly mark session cookie as lax
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Jun 14, 2024
1 parent acd947a commit 504c686
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions schemes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Config:
# Flask
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_SAMESITE = "Lax"
PERMANENT_SESSION_LIFETIME = timedelta(hours=1)

# Flask-SQLAlchemy
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def test_authorize_redirect_sets_http_only_session_cookie(
value = response.headers["Set-Cookie"].split("; ")
assert value[0].startswith("session=") and "HttpOnly" in value

def test_authorize_redirect_sets_same_site_session_cookie(
self, oidc_server: StubOidcServer, client: FlaskClient
) -> None:
response = client.get("/schemes")

value = response.headers["Set-Cookie"].split("; ")
assert value[0].startswith("session=") and "SameSite=Lax" in value

@responses.activate
def test_callback_logs_in(self, oidc_server: StubOidcServer, users: UserRepository, client: FlaskClient) -> None:
users.add(User("boardman@example.com", authority_id=1))
Expand Down

0 comments on commit 504c686

Please sign in to comment.