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

Add support for Axum framework #32

Merged
merged 5 commits into from
May 14, 2024

Conversation

brunoribeiro127
Copy link
Contributor

@brunoribeiro127 brunoribeiro127 commented Jan 22, 2024

This MR adds support for the Axum framework.

Copy link
Owner

@DarrenBaldwin07 DarrenBaldwin07 left a 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.

@capveg-netdebug
Copy link
Contributor

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?

@brunoribeiro127
Copy link
Contributor Author

brunoribeiro127 commented Mar 4, 2024

@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.

@capveg-netdebug
Copy link
Contributor

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.

Copy link
Owner

@DarrenBaldwin07 DarrenBaldwin07 left a 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

@mies
Copy link

mies commented Apr 23, 2024

would love to have this merged in as well, thank you both for the work @brunoribeiro127 @DarrenBaldwin07

@hazelmeow
Copy link
Contributor

@DarrenBaldwin07 What would it take to get this merged? :)

Copy link
Owner

@DarrenBaldwin07 DarrenBaldwin07 left a 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!

}

/// Validates a jwt token using a jwks
fn validate_jwt(token: &str, jwks: JwksModel) -> Result<ClerkJwt, ()> {
Copy link
Owner

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> {

Copy link
Contributor Author

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]
Copy link
Owner

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

Copy link
Contributor Author

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.

@DarrenBaldwin07 DarrenBaldwin07 merged commit 11d1b3c into DarrenBaldwin07:main May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants