auth: add community token service seam
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
use axum::{Json, extract::State};
|
||||
use crank_core::{IssueAgentTokenRequest, IssueOneTimeAgentTokenRequest};
|
||||
|
||||
use crate::{error::ApiError, state::AppState};
|
||||
|
||||
pub async fn issue_agent_token(
|
||||
State(state): State<AppState>,
|
||||
Json(payload): Json<IssueAgentTokenRequest>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let response = state.service.issue_agent_token(payload).await?;
|
||||
Ok(Json(serde_json::json!(response)))
|
||||
}
|
||||
|
||||
pub async fn issue_one_time_agent_token(
|
||||
State(state): State<AppState>,
|
||||
Json(payload): Json<IssueOneTimeAgentTokenRequest>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let response = state.service.issue_one_time_agent_token(payload).await?;
|
||||
Ok(Json(serde_json::json!(response)))
|
||||
}
|
||||
Reference in New Issue
Block a user