-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: newtyped ID and nice session parsing #639
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0d99cbc
refactor: introduce newtyped ids in backend_domain
comavius 8578aa2
refactor: newtyped id instantiation for jwt
comavius 1480245
refactor: change visibility of inner uuid
comavius 8c9c879
refactor: improve order of impl blocks
comavius a79cfea
refactor: remove unused imports
comavius 51eaa23
refactor: improve session-user abstraction
comavius 72e12f7
refactor: implement get_session_user
comavius 4d5fe96
refactor: use into() conversion
comavius 43fc88c
refactor: update cargo.lock
comavius 9ab3063
refactor: remove unused imports
comavius d1bac27
refactor: usecase layer no longer depends on uuid crate
comavius 56581ba
refactor: usecase models should use newtyped id types
comavius dcf1d76
usecase tests depends on uuid
comavius 8c43aba
refactor: temporarily add default for testcase id
comavius aba4245
refactor: revert wrong changes on icon format
comavius 5db5d93
refactor: newtyped ids for usecase services
comavius ee12084
add axum-extra coockie feature
comavius 6a2f728
fix: misc forgotten fixes
comavius 53025ff
add customized extractor for coockie
comavius 6699803
customized extractor 2
comavius 2748833
newtyped id conversion for backend_app models
comavius db4bd1a
session repository injection
comavius 23ef39c
ues newtyped id with customized extractor
comavius 63b80b4
removed unused imports
comavius bae88fc
newtyped id conversion in tests
comavius 44e2165
Update app/backend_app/src/extractor/session.rs
comavius bfdc0d8
Update app/backend_app/src/extractor/session.rs
comavius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pub mod session; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| use crate::di::DiContainer; | ||
| use axum::{ | ||
| async_trait, | ||
| extract::FromRequestParts, | ||
| http::{StatusCode, request::Parts}, | ||
| }; | ||
| use axum_extra::extract::cookie::CookieJar; | ||
| use domain::{model::session::SessionUser, repository::session::SessionRepository}; | ||
|
|
||
| pub struct ExtractedSessionUser(pub Option<SessionUser>); | ||
|
|
||
| #[async_trait] | ||
| impl FromRequestParts<DiContainer> for ExtractedSessionUser { | ||
| type Rejection = (StatusCode, &'static str); | ||
|
|
||
| async fn from_request_parts( | ||
| parts: &mut Parts, | ||
| di_container: &DiContainer, | ||
| ) -> Result<Self, Self::Rejection> { | ||
| let jar = CookieJar::from_request_parts(parts, di_container) | ||
| .await | ||
| .map_err(|_| (StatusCode::BAD_REQUEST, "Invalid Cookie header"))?; | ||
|
|
||
| if let Some(session_id) = jar.get("session_id") { | ||
| let session_user = di_container | ||
| .session_repository() | ||
| .get_session_user(session_id.value()) | ||
| .await | ||
| .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, "Session retrieval error"))?; | ||
| Ok(ExtractedSessionUser(session_user)) | ||
| } else { | ||
| Ok(ExtractedSessionUser(None)) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.