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

Encrypt cookie value in session update #394

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Default password criteria are more restrictive (#372, `v24.20-alpha1`, Compatible with Seacat Auth Webui v24.19-alpha and later, Seacat Account Webui v24.08-beta and later)

### Fix
- Properly encrypt cookie value in session update (#394, `v24.20-alpha11`)
- Properly parse URL query before adding new parameters (#393, `v24.20-alpha11`)
- Delete client cookie on introspection failure (#385, `v24.20-alpha6`)
- Extend session expiration at cookie entrypoint (#383, `v24.20-alpha5`)
Expand Down
10 changes: 9 additions & 1 deletion seacatauth/session/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,18 @@ async def update_session(self, session_id: str, session_builders: list):

for session_builder in session_builders:
for key, value in session_builder:
upsertor.set(key, value, encrypt=(key in SessionAdapter.EncryptedAttributes))
if key in SessionAdapter.EncryptedIdentifierFields and value is not None:
value = SessionAdapter.EncryptedPrefix + self.aes_encrypt(value)
upsertor.set(key, value)
else:
upsertor.set(key, value, encrypt=(key in SessionAdapter.EncryptedAttributes))

await upsertor.execute(event_type=EventTypes.SESSION_UPDATED)

L.log(asab.LOG_NOTICE, "Session updated.", struct_data={
"sid": session_id,
"type": session_dict.get(SessionAdapter.FN.Session.Type),
})
return await self.get(session_id)


Expand Down
Loading