Skip to content

Commit

Permalink
security: set authtkt cookie samesite Strict and httponly
Browse files Browse the repository at this point in the history
Also set session cookie samesite
  • Loading branch information
robvdl committed Mar 8, 2024
1 parent e514526 commit 08ac707
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sambal/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def __init__(self, secret):
self.authtkt = AuthTktCookieHelper(
secret=secret,
secure=SETTINGS["sambal.https"],
samesite="Strict",
http_only=True,
)

def identity(self, request) -> Optional[User]:
Expand Down
1 change: 1 addition & 0 deletions src/sambal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"redis.sessions.secret": os.getenv("SAMBAL_SESSION_SECRET"),
"redis.sessions.serialize": lambda s: json.dumps(s).encode("utf-8"),
"redis.sessions.deserialize": lambda s: json.loads(s.decode("utf-8")),
"redis.sessions.cookie_samesite": "Strict",
"redis.sessions.cookie_httponly": True,
}

Expand Down

0 comments on commit 08ac707

Please sign in to comment.