MastraJwtAuth 类
🌐 MastraJwtAuth Class
MastraJwtAuth 类为 Mastra 提供了一种轻量级的身份验证机制,使用 JSON Web Tokens (JWTs)。它基于共享密钥验证传入请求,并通过 auth 选项与 Mastra 服务器集成。
🌐 The MastraJwtAuth class provides a lightweight authentication mechanism for Mastra using JSON Web Tokens (JWTs). It verifies incoming requests based on a shared secret and integrates with the Mastra server using the auth option.
使用示例Direct link to 使用示例
🌐 Usage example
src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { MastraJwtAuth } from "@mastra/auth";
export const mastra = new Mastra({
server: {
auth: new MastraJwtAuth({
secret: "<your-secret>",
}),
},
});
构造函数参数Direct link to 构造函数参数
🌐 Constructor parameters
secret:
string
A unique string used to sign and verify JSON Web Tokens (JWTs) for authenticating incoming requests.
相关Direct link to 相关
🌐 Related