use axum::Json;
use serde::Serialize;
use uuid::Uuid;
use yorishiro_core::services::auth::ApiKeyScope;
use crate::http::middleware::auth::AuthContext;
#[derive(Serialize)]
pub struct WhoAmIResponse {
workspace_id: Uuid,
tenant_id: Uuid,
scope: ApiKeyScope,
user_id: Option<Uuid>,
}
pub async fn whoami(AuthContext(ctx): AuthContext) -> Json<WhoAmIResponse> {
Json(WhoAmIResponse {
workspace_id: ctx.workspace_id,
tenant_id: ctx.tenant_id,
scope: ctx.scope,
user_id: ctx.user_id,
})
}
#[cfg(test)]
#[path = "../../../tests/http/controllers/whoami.rs"]
mod tests;