Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth-gray committed Jun 26, 2024
1 parent 71b7640 commit 864313a
Show file tree
Hide file tree
Showing 10 changed files with 5,289 additions and 3,353 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ runs:
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# redis-user-sessions

Helper functions for managing redis user sessions.
Helper functions for managing redis user sessions. In particular; dealing with expiry in the redis store using TTL

## What is stored

2 things are stored:

1. The session id and it's associated data; userId (string), expires (UTC datetime) and data (json object of whatever data you'd like to store in a session)
2. A list of all session ids associated with a userId

Both things have a TTL set on them so that if the user forgets to log out specifically the sessions will naturally expire.

### List of all sessions against a user

This is stored separately for 2 reasons:

1. So that the user can list out a set of sessions and delete sessions they think should not exist any more

- This can only be achieved if the session ids are also accompanied by other information, such as machine name, date last accessed, IP address, etc. This must be implemented as part of the `data` property by the user of the library.

2. So that you can update data across all sessions that belong to a user all at once, such as:
- Deleting all sessions that belong to a user because there's been a security breach on their account
- Updating permissions stored on the session immediately (instead of waiting for a timeout or deleting all sessions unnecessarily)

## Benefits

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
"rimraf": "^4.1.2",
"tsup": "^6.5.0",
"typescript": "^4.9.4",
"vitest": "^0.28.1"
"vitest": "^1.6.0"
},
"dependencies": {
"safe-json-stringify": "^1.2.0",
"uid-safe": "^2.1.5",
"zod": "^3.20.2"
}
Expand Down
Loading

0 comments on commit 864313a

Please sign in to comment.