-
Notifications
You must be signed in to change notification settings - Fork 377
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
base: main
Are you sure you want to change the base?
Conversation
Web viewer built successfully. If applicable, you should also test it:
Note: This comment is updated whenever you push a commit. |
/// 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); |
There was a problem hiding this comment.
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
pub struct Permission { | ||
write: bool, | ||
} |
There was a problem hiding this comment.
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:
pub struct Permission { | |
write: bool, | |
} | |
pub enum Permission { | |
ReadOnly, | |
ReadWrite | |
} |
token::Token, | ||
}; | ||
|
||
/// A common secret that is shared between the client and the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A common secret that is shared between the client and the server. | |
/// A secret key that is used to generate and verify tokens. |
What
This adds a new
re_auth
crate with the following features:jwt-simple
so that we can swap it out.SecretKey
from/tobase64
to be used withredap-cli
.tonic::Interceptor
s for both client and server side middleware with anauthorization: Bearer <token>
header.Here is what a
SecretKey
(HS256
) looks like inbase64
:We can use that to generate a basic token:
Which you can verify yourself via www.jwt.io.