@mastra/core
Version:
28 lines (19 loc) • 813 B
Markdown
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
# MastraJwtAuth class
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.
## Usage example
```typescript
import { Mastra } from '@mastra/core'
import { MastraJwtAuth } from '@mastra/auth'
export const mastra = new Mastra({
server: {
auth: new MastraJwtAuth({
secret: '<your-secret>',
}),
},
})
```
## Constructor parameters
**secret** (`string`): A unique string used to sign and verify JSON Web Tokens (JWTs) for authenticating incoming requests.
## Related
- [JSON Web Token](https://mastra.ai/docs/server/auth/jwt)