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

Axum example #247

Open
ikehz opened this issue Jan 22, 2024 · 7 comments
Open

Axum example #247

ikehz opened this issue Jan 22, 2024 · 7 comments

Comments

@ikehz
Copy link
Contributor

ikehz commented Jan 22, 2024

I've been working on an example with Axum, & would be happy to clean it up & link here along with the Actix contributed example.

I'm not a security engineer, so it would need to be reviewed with some skepticism.

@ramosbugs
Copy link
Owner

Sounds good! I'll try to find some time to review it if you submit a PR adding the contributed example link.

@thor314
Copy link

thor314 commented Feb 23, 2024

@ikehz, would love to see your example if you've time.

@pickfire
Copy link

I have added an axum example for 5.0.0-alpha.4. I find the addition of type states made it a mess, I wonder how should I pass around the type next time.

struct AppState {
    client: BasicClient<EndpointSet, EndpointNotSet, EndpointNotSet, EndpointSet, EndpointSet>,
    ...
}

https://github.com/pickfire/oauth2-axum

@ramosbugs
Copy link
Owner

I have added an axum example for 5.0.0-alpha.4. I find the addition of type states made it a mess, I wonder how should I pass around the type next time.

I'd suggest using a type alias.

@Trojanking123
Copy link

Trojanking123 commented Sep 19, 2024

I have added an axum example for 5.0.0-alpha.4. I find the addition of type states made it a mess, I wonder how should I pass around the type next time.

I'd suggest using a type alias.

it's very hard to claim a Client varibal now.

@ramosbugs
Copy link
Owner

it's very hard to claim a Client varibal now.

What does "claim" mean in this context?

Regarding type aliases, is there some complexity I'm missing here? Something like this (applying it to @pickfire's snippet above) seems straightforward to use within application code:

pub type Oauth2ClientWithEndpoints = BasicClient<EndpointSet, _, _, EndpointSet, EndpointSet>;

struct AppState {
    client: Oauth2ClientWithEndpoints,
    ...
}

Note that _ can be used in place of EndpointNotSet since it's the default generic type for each type state generic.

This is just one additional line of code for the benefit of having the correct set of client endpoints enforced at compile time and avoiding configuration errors at runtime, which has caused issues for other users in the past.

@KevinMGranger
Copy link

Worth nothing that there's an existing example in the axum repo.

(Yes, it improperly handles csrf, but that's explicitly called out and there's a PR to fix that.)

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

No branches or pull requests

6 participants