Skip to main content
Glama
supabase-auth-manager.ts1.29 kB
import { logMessage } from "../utils/logs.js"; import { AuthManager, AuthResult } from "./types.js"; import { SupabaseKeyManager } from "./supabase-key-manager.js"; import { SupabaseJWTAuthManager } from "./supabase-jwt-auth-manager.js"; // This manager is used to authenticate a token using both the JWT and API key managers. // It will first try to authenticate with the JWT manager, and if that fails, it will fall back to the API key manager (static keys). export class SupabaseAuthManager implements AuthManager { private jwtAuthManager: SupabaseJWTAuthManager; private keyAuthManager: SupabaseKeyManager; constructor() { this.jwtAuthManager = new SupabaseJWTAuthManager(); this.keyAuthManager = new SupabaseKeyManager(); } public async authenticate(token: string): Promise<AuthResult> { if (this.isJWT(token)) { const jwtResult = await this.jwtAuthManager.authenticate(token); if (jwtResult.success) { return jwtResult; } logMessage('debug', 'JWT authentication failed, falling back to API key lookup'); } return this.keyAuthManager.authenticate(token); } private isJWT(token: string): boolean { const parts = token.split('.'); return parts.length === 3 && parts.every(part => part.length > 0); } }

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/superglue-ai/superglue'

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