Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic JWT-based authentication and authorization #8627

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

grtlr
Copy link
Contributor

@grtlr grtlr commented Jan 9, 2025

What

This adds a new re_auth crate with the following features:

  • JWT-based symmetric authorization and authentication (basic read/write modes).
  • Rerun-ified abstraction over jwt-simple so that we can swap it out.
  • Helpers to convert a SecretKey from/to base64 to be used with redap-cli.
  • tonic::Interceptors for both client and server side middleware with an authorization: Bearer <token> header.

Here is what a SecretKey (HS256) looks like in base64:

n1J0G5zfqZ8tyVvFkmR6f4huhZ9YMInzrlQg8vrtPtI=

We can use that to generate a basic token:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MzY0MjMwNzcsImV4cCI6MTczNjQyMzEzNywibmJmIjoxNzM2NDIzMDc3LCJhdWQiOiJyZXJ1biIsIndyaXRlIjpmYWxzZX0.SR4pyzxfWOgwphTEesbv9SmvayHDQlIGHYGE1atwrcA

Which you can verify yourself via www.jwt.io.

image

@grtlr grtlr added exclude from changelog PRs with this won't show up in CHANGELOG.md dataplatform Rerun Data Platform integration labels Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

Web viewer built successfully. If applicable, you should also test it:

  • I have tested the web viewer
Result Commit Link Manifest
f7b733d https://rerun.io/viewer/pr/8627 +nightly +main

Note: This comment is updated whenever you push a commit.

@grtlr grtlr marked this pull request as ready for review January 10, 2025 13:54
Comment on lines +19 to +28
/// A common secret that is shared between the client and the server.
///
/// This represents a symmetric authentication scheme, which means that the
/// same key is used to both sign and verify the token.
/// In the future, we will need to support asymmetric schemes too.
///
/// The key is stored unencrypted in memory.
#[derive(Clone)]
#[repr(transparent)]
pub struct SecretKey(HS256Key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this key should not actually be shared by clients.

This key is exclusively for the identity provider. The fact that we are going to share the key with clients so they can act as their own identity-provider is more of a short-term management detail.

I would actually move this whole bit into another module like provider.rs

Comment on lines +9 to +11
pub struct Permission {
write: bool,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that write=false still implies read isn't totally obvious or necessarily expected.

Let's be explicit:

Suggested change
pub struct Permission {
write: bool,
}
pub enum Permission {
ReadOnly,
ReadWrite
}

token::Token,
};

/// A common secret that is shared between the client and the server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A common secret that is shared between the client and the server.
/// A secret key that is used to generate and verify tokens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dataplatform Rerun Data Platform integration exclude from changelog PRs with this won't show up in CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants