-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[Rust-Axum][Breaking Changes] Extracting Claims in Cookie/Header #20097
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
pub mod payments; | ||
|
||
/// API Key Authentication - Header. | ||
#[async_trait::async_trait] | ||
pub trait ApiKeyAuthHeader { | ||
fn extract_token_from_header( | ||
type Claims; | ||
|
||
/// Extracting Claims from Header. Return None if the Claims is invalid. | ||
async fn extract_claims_from_header( | ||
&self, | ||
headers: &axum::http::header::HeaderMap, | ||
key: &str, | ||
) -> Option<String>; | ||
) -> Option<Self::Claims>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User Impl this trait to extract Claims (e.g: JWT) from Header/Cookie. |
||
} | ||
/// Cookie Authentication. | ||
#[async_trait::async_trait] | ||
pub trait CookieAuthentication { | ||
fn extract_token_from_cookie( | ||
type Claims; | ||
|
||
/// Extracting Claims from Cookie. Return None if the Claims is invalid. | ||
async fn extract_claims_from_cookie( | ||
&self, | ||
cookies: &axum_extra::extract::CookieJar, | ||
key: &str, | ||
) -> Option<String>; | ||
) -> Option<Self::Claims>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ pub enum PostMakePaymentResponse { | |
#[async_trait] | ||
#[allow(clippy::ptr_arg)] | ||
pub trait Payments { | ||
type Claims; | ||
|
||
/// Get payment method by id. | ||
/// | ||
/// GetPaymentMethodById - GET /v71/paymentMethods/{id} | ||
|
@@ -68,7 +70,7 @@ pub trait Payments { | |
method: Method, | ||
host: Host, | ||
cookies: CookieJar, | ||
token_in_cookie: Option<String>, | ||
claims: Self::Claims, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extracted Claims (in previous step) is injected into Operation. User then can do whatever he/she wants with the Claims (e.g: get AccountID from the Claims) |
||
body: Option<models::Payment>, | ||
) -> Result<PostMakePaymentResponse, ()>; | ||
} |
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.
Bug fix here. We must use
keyParamName
instead of transforming