Skip to content

Commit

Permalink
Merge pull request #177 from communitiesuk/bau/secure-cookie
Browse files Browse the repository at this point in the history
Set cookie attributes for "security"
  • Loading branch information
samuelhwilliams authored Oct 21, 2024
2 parents ec65273 + e2f4d21 commit 925b7e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions fsd_utils/locale_selector/set_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def set_language_cookie(locale: str, response: Response):
current_app.config["COOKIE_DOMAIN"]
),
max_age=86400 * 30, # 30 days
httponly=True,
secure=True,
samesite="Lax",
)

def __init__(self, app):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "funding-service-design-utils"

version = "5.1.2"
version = "5.1.3"

authors = [
{ name="MHCLG", email="FundingService@communities.gov.uk" },
Expand Down
3 changes: 3 additions & 0 deletions tests/test_set_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ def test_set_lang(flask_test_client):
response_cookie = response.headers.get("Set-Cookie")
assert response_cookie is not None, "No cookie set for language"
assert response_cookie.split(";")[0] == ("language" + "=cy")
assert "Secure" in response_cookie
assert "HttpOnly" in response_cookie
assert "SameSite=Lax" in response_cookie

0 comments on commit 925b7e9

Please sign in to comment.