-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "identity_server" | ||
version.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
description = "Self-custodial identity using did:web" | ||
publish = false | ||
|
||
[dependencies] | ||
axum.workspace = true | ||
clap.workspace = true | ||
color-eyre.workspace = true | ||
tokio = { workspace = true, features = ["full"] } | ||
tower-http = { workspace = true, features = ["trace"] } | ||
tracing-subscriber = { workspace = true, features = ["env-filter"] } | ||
tracing.workspace = true | ||
serde.workspace = true |
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,16 @@ | ||
pub mod v1; | ||
|
||
use axum::routing::get; | ||
use tower_http::trace::TraceLayer; | ||
|
||
/// Main router of API | ||
pub fn router() -> axum::Router<()> { | ||
axum::Router::new() | ||
.route("/", get(root)) | ||
.nest("/api/v1", crate::v1::router()) | ||
.layer(TraceLayer::new_for_http()) | ||
} | ||
|
||
async fn root() -> &'static str { | ||
"uwu hewwo this api is under constwuction" | ||
} |
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,33 @@ | ||
use std::net::{Ipv6Addr, SocketAddr}; | ||
|
||
use clap::Parser as _; | ||
use tracing::info; | ||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; | ||
|
||
#[derive(clap::Parser, Debug)] | ||
struct Cli { | ||
#[clap(default_value = "0")] | ||
port: u16, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> color_eyre::Result<()> { | ||
color_eyre::install()?; | ||
tracing_subscriber::registry() | ||
.with(EnvFilter::try_from_default_env().unwrap_or("info".into())) | ||
.with(tracing_subscriber::fmt::layer()) | ||
.init(); | ||
|
||
let cli = Cli::parse(); | ||
|
||
let listener = tokio::net::TcpListener::bind(SocketAddr::new( | ||
Ipv6Addr::UNSPECIFIED.into(), | ||
cli.port, | ||
)) | ||
.await | ||
.unwrap(); | ||
info!("listening on {}", listener.local_addr().unwrap()); | ||
axum::serve(listener, identity_server::router()) | ||
.await | ||
.map_err(|e| e.into()) | ||
} |
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,17 @@ | ||
//! V1 of the API. This is subject to change until we commit to stability, after | ||
//! which point any breaking changes will go in a V2 api. | ||
|
||
use axum::{routing::post, Json, Router}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Router of API V1 | ||
pub fn router() -> Router { | ||
Router::new().route("/create", post(create)) | ||
} | ||
|
||
async fn create(_pubkey: Json<JWK>) -> String { | ||
String::from("did:web:todo") | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
struct JWK; |