-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add support for Axum framework #32
Add support for Axum framework #32
Conversation
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.
Thank you so much for the PR @brunoribeiro127 - taking a first pass today and will come back with some review comments.
2cf05df
to
b770fcc
Compare
Nice PR @brunoribeiro127 - what's the status of this? I'd love to use this code as I'm also working with Axum. I'm still reading through the changes but it doesn't look like you used https://docs.rs/axum-login/latest/axum_login/ - any reason? |
@capveg-netdebug Thanks for reviewing. To be honest, I was not aware of axum_login at all. It seems like the best way forward though. |
Thanks for the quick reply. If that's the case, I might try to push some of my axum_login integration here for folks to look at/think about. It might be that my use-case is a bit unique in that I want to include some non-trivial state with the user identity that's stored locally to my app and not in Clerk but I'm curious how you're thinking about it as it affects the design. |
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.
I'd like to get this in too! I personally havent used axum much so not sure what best practices are here. I do like the idea of having a central authorizer that then gets consumed by the different web frameworks middleware setups so this seems right to me. I think maybe best approach would be to get this reviewed and merged as-is so that we can have axum support - after that, i'd be happy to take PRs for refactors/improvements
b770fcc
to
e145005
Compare
would love to have this merged in as well, thank you both for the work @brunoribeiro127 @DarrenBaldwin07 |
@DarrenBaldwin07 What would it take to get this merged? :) |
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.
There are a couple things I want to tweak but those can be done after merging this. Address my comments (and resolve conflicts) and we can get this merged + released 🚀
Thanks again for the PR!
src/validators/authorizer.rs
Outdated
} | ||
|
||
/// Validates a jwt token using a jwks | ||
fn validate_jwt(token: &str, jwks: JwksModel) -> Result<ClerkJwt, ()> { |
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.
This function needs to be exported - some users interface with this directly. I think its better if we revert this function back to what it was before (always returning true
or false
)
pub fn validate_jwt(token: &str, jwks: JwksModel) -> Result<(bool, ClerkJwt), 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.
Done.
@@ -1,6 +1,6 @@ | |||
[package] |
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.
Lets also make changes to lib.rs to export the authorizer.rs
module
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.
I've made the function public. The import path changed from use clerk_rs::validators::actix::validate_jwt
to use clerk_rs::validators::authorizer::validate_jwt
.
e145005
to
7d9a4d5
Compare
This MR adds support for the Axum framework.