Implement /generate-server-padlock-2
This commit is contained in:
parent
8d4b969419
commit
045d5394ca
1 changed files with 28 additions and 0 deletions
|
@ -42,6 +42,10 @@ pub async fn run(
|
|||
"/generate-user-server-key-2",
|
||||
post(generate_user_server_key_2),
|
||||
)
|
||||
.route(
|
||||
"/generate-server-padlock-2",
|
||||
post(generate_server_padlock_2),
|
||||
)
|
||||
.with_state(app_state);
|
||||
let listener = tokio::net::TcpListener::bind((Ipv6Addr::UNSPECIFIED, port)).await?;
|
||||
axum::serve(listener, app).await?;
|
||||
|
@ -151,3 +155,27 @@ async fn generate_user_server_key_2(
|
|||
server_key_timestamp,
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ServerPadlockResponse {
|
||||
server_hash: ServerHash,
|
||||
server_padlock: String,
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn generate_server_padlock_2(
|
||||
State(state): State<Arc<AppState>>,
|
||||
Query(ApiVersion { api_version }): Query<ApiVersion>,
|
||||
) -> ApiResult<Json<ServerPadlockResponse>> {
|
||||
event!(Level::INFO, "Creating server padlock");
|
||||
|
||||
let server_hash = ServerPadlockGenerator::generate_hash();
|
||||
let server_padlock = state
|
||||
.server_padlock_generator
|
||||
.generate_padlock(&server_hash);
|
||||
|
||||
Ok(Json(ServerPadlockResponse {
|
||||
server_hash,
|
||||
server_padlock: server_padlock.0.expose_secret().to_owned(),
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue