-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[auth] feat: axum with routes (#632)
* feat: router * feat: tracing and propagation * refactor: request tracing * tests: TraceLayer * refactor: clippy suggestion * refactor: better comments * Update gateway/src/api/latest.rs * tests: more deterministic
- Loading branch information
Showing
14 changed files
with
432 additions
and
114 deletions.
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 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 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 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 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 |
---|---|---|
@@ -1,3 +1,16 @@ | ||
mod args; | ||
mod router; | ||
|
||
pub use args::Args; | ||
use tracing::info; | ||
|
||
pub async fn start(args: Args) { | ||
let router = router::new(); | ||
|
||
info!(address=%args.address, "Binding to and listening at address"); | ||
|
||
axum::Server::bind(&args.address) | ||
.serve(router.into_make_service()) | ||
.await | ||
.unwrap_or_else(|_| panic!("Failed to bind to address: {}", args.address)); | ||
} |
This file contains 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 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,45 @@ | ||
use axum::{ | ||
middleware::from_extractor, | ||
routing::{get, post}, | ||
Router, | ||
}; | ||
use shuttle_common::{ | ||
backends::metrics::{Metrics, TraceLayer}, | ||
request_span, | ||
}; | ||
use tracing::field; | ||
|
||
pub fn new() -> Router { | ||
Router::new() | ||
.route("/login", post(login)) | ||
.route("/logout", post(logout)) | ||
.route("/auth/session", post(convert_cookie)) | ||
.route("/auth/key", post(convert_key)) | ||
.route("/auth/refresh", post(refresh_token)) | ||
.route("/public-key", get(get_public_key)) | ||
.route("/user/:account_name", get(get_user).post(post_user)) | ||
.route_layer(from_extractor::<Metrics>()) | ||
.layer( | ||
TraceLayer::new(|request| { | ||
request_span!(request, request.params.account_name = field::Empty) | ||
}) | ||
.with_propagation() | ||
.build(), | ||
) | ||
} | ||
|
||
async fn login() {} | ||
|
||
async fn logout() {} | ||
|
||
async fn convert_cookie() {} | ||
|
||
async fn convert_key() {} | ||
|
||
async fn refresh_token() {} | ||
|
||
async fn get_public_key() {} | ||
|
||
async fn get_user() {} | ||
|
||
async fn post_user() {} |
This file contains 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.