Repository navigation
Closed
Labels
Description
Create a new service (name: "guestauth"?) that is responsible for:
- creating and persiting the initial guest login token when a guest-link was created
- provding an endpoint to redeem that token and exchange it for a session-cookie (similar to what is described in Discuss/Define authentication mechansim for "magiclinks" #2517) that can later be validated/authenticated by the proxy (guestlinks: proxy middleware to validate guestlink cookies for authentication #3070)
We're ignoring the renewal bits of #2517 here for now.
The service is part of the default service set and should not need to be explicitly enabled with OC_ADD_RUN_SERVICES
Creating and persisting the initial guest token
- Work event based, consume the
ShareCreatedEvent - Generates a secure random secret (url-safe)
- Using that secret and the shareid a structured token is generated. Suggested format:
v1.<hashed-url-safe-shareid>.<secret>(v1is intended as a version identifier in case we want to change the token format in the future, do we really need that? - Persists the token information for that share.
- Suggestion: let's not use jsoncs3 for storage here, but write directly to the filesystem (using filesystem locking primitives)
- Simple JSON files (one file per share), naming based on the shareid (the same hash as in the token?). It might make sense to use a sharded directory tree
- Minimal data that needs to be persisted,
shareid,token secret(hashed?),token expiry,token_redeemed(flag "has this token been redeemed") - Implement an abstraction that allows to replace the persistence in the future (e.g. to allow a simple in-memory implemenation for testing or a NATS implementation)
- Emit an event
GuestTokenCreated(?) that can later be picked up by thenotificationsservice for sending out the invitation link. - Also consume the
ShareRemovedandShareExpiredevents to cleanup stored tokens that are not longer needed.
Public redemption endpoint
Token can be redeemed (i.e. exchanged for a session-cookie) like this:
- user clicks the invitation link
- The web page loads, retrieves the token from the URL and trades it for a cookie by sending it to redemption y endpoint in the backend:
POST /graph/v1beta1/guestInvitations/redeemwith the token in the request body. (Note the path is a deviation from Discuss/Define authentication mechansim for "magiclinks" #2517) - The backend looks up the token, validates it (also validates the share still exists and is not expired), signs a JWT and sets the session cookie.
JWT Session cookie
- use a dedicated signing secret (no fallback to OC_JWT_SECRET)
- default JWT ttl: 24h
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity