sipb / class_group_chats

Join your group chats for your MIT classes.
0 stars 0 forks source link

Kerb validation #9

Open gabrc52 opened 1 year ago

gabrc52 commented 1 year ago

Possible implementation that does not require reinventing the kerb authentication wheel:

  1. Check if the user is signed into Element, and get the access token from local storage
  2. Otherwise, act as a Matrix client and implement single-sign-on
  3. Issue a more restrictive token via https://playground.matrix.org/#post-/_matrix/client/v3/user/-userId-/openid/request_token. (not a full access token, just for verifying identity)
  4. If we did #\2, sign out immediately (our custom SSO destination would extract the token, get a new OpenID token, and then shortly sign out)
  5. Keep the OpenID token in local storage, and use it as an auth token when doing requests.
  6. The backend should validate this token via https://spec.matrix.org/v1.8/server-server-api/#get_matrixfederationv1openiduserinfo (perhaps in SvelteKit via variables) and deny unauthorized requests
  7. Corollary: once all backend requests are authenticated, we can safely assume that it is the user themselves requesting to do actions, so we can add additional features or backend endpoints such as "what class group chats am I already in?" (not something I would add at the moment since I don't want people being able to query other people's list)

Notes on OpenID:

Third-party services can exchange an access token previously generated by the Client-Server API for information about a user. This can help verify that a user is who they say they are without granting full access to the user’s account.

(https://spec.matrix.org/v1.8/server-server-api/#openid)

Note that Matrix doesn't use OIDC for authentication yet and uses its own custom-built auth: https://areweoidcyet.com/

Some considerations:

gabrc52 commented 9 months ago

This implementation has been done -- we are not giving it to the backend yet since we still want to support simply entering your kerb in the mobile case