Skip to main content
Glama
whoami.rs1.28 kB
use axum::{ Json, Router, response::IntoResponse, routing::get, }; use dal::{ UserPk, WorkspacePk, }; use serde::{ Deserialize, Serialize, }; use si_jwt_public_key::SiJwt; use crate::{ AppState, extract::{ request::ValidatedToken, workspace::{ AuthorizedForAutomationRole, TargetWorkspaceIdFromToken, WorkspaceAuthorization, }, }, }; pub fn routes() -> Router<AppState> { Router::new().route("/", get(whoami)) } #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] struct WhoamiResponse { pub user_id: UserPk, pub user_email: String, pub workspace_id: WorkspacePk, pub token: SiJwt, } async fn whoami( // TODO this isn't really necessary; we don't need to check you have a workspace ID. _: TargetWorkspaceIdFromToken, // Just because this is the most permissive role we have right now _: AuthorizedForAutomationRole, ValidatedToken(token): ValidatedToken, WorkspaceAuthorization { workspace_id, user, .. }: WorkspaceAuthorization, ) -> impl IntoResponse { Json(WhoamiResponse { workspace_id, user_id: user.pk(), user_email: user.email().clone(), token, }) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server