Skip to content

Kerb validation #9

@gabrc52

Description

@gabrc52

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:

  • Don't forget to namespace everything we store in local storage since we don't want to conflict with Element's.
  • Be extra sure that our code won't sign you out of Element. The sign out logic should be in a different route that only gets triggered via SSO.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions