Skip to content

guestlinks: Implement endpoints to create/verify initial guest login token #3069

Closed

Description

@rhafer

Create a new service (name: "guestauth"?) that is responsible for:

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 ShareCreated Event
  • 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> (v1 is 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 the notifications service for sending out the invitation link.
  • Also consume the ShareRemoved and ShareExpired events 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/redeem with 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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions