
Security News
/Research
Fake Corepack Site Distributes Infostealer and Proxyware to Developers
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.
@mastra/auth-workos
Advanced tools
Affected versions:
A WorkOS integration for Mastra that supports authentication, role-based access control (RBAC), and Fine-Grained Authorization (FGA).
MastraRBACWorkosMastraFGAWorkosnpm install @mastra/auth-workos
# or
yarn add @mastra/auth-workos
# or
pnpm add @mastra/auth-workos
import { Mastra } from '@mastra/core/mastra';
import { MastraFGAPermissions } from '@mastra/core/auth/ee';
import { MastraAuthWorkos, MastraFGAWorkos } from '@mastra/auth-workos';
// Initialize with environment variables
const auth = new MastraAuthWorkos();
// Or initialize with explicit configuration
const auth = new MastraAuthWorkos({
apiKey: 'your_workos_api_key',
clientId: 'your_workos_client_id',
redirectUri: 'https://your-app.com/auth/callback',
});
// Enable auth in Mastra
const mastra = new Mastra({
...
server: {
auth,
},
});
MastraAuthWorkos authorizes any authenticated WorkOS user by default.
If you also use MastraFGAWorkos, set fetchMemberships: true so Mastra loads organization memberships during authentication:
const auth = new MastraAuthWorkos({
apiKey: 'your_workos_api_key',
clientId: 'your_workos_client_id',
redirectUri: 'https://your-app.com/auth/callback',
fetchMemberships: true,
});
const fga = new MastraFGAWorkos({
apiKey: 'your_workos_api_key',
clientId: 'your_workos_client_id',
resourceMapping: {
thread: {
fgaResourceType: 'workspace-thread',
deriveId: ({ resourceId, user }) => resourceId ?? user.id,
},
},
permissionMapping: {
[MastraFGAPermissions.MEMORY_READ]: 'read',
[MastraFGAPermissions.MEMORY_WRITE]: 'update',
},
});
thread is the canonical Mastra resource key for memory authorization. MastraFGAWorkos also accepts the legacy alias memory for backward compatibility.
The package requires the following configuration:
WORKOS_API_KEY: Your WorkOS API keyWORKOS_CLIENT_ID: Your WorkOS client IDWORKOS_REDIRECT_URI: Your WorkOS redirect URI when you use the built-in AuthKit session flowYou can also provide these values directly when initializing the provider:
interface MastraAuthWorkosOptions {
apiKey?: string;
clientId?: string;
redirectUri?: string;
fetchMemberships?: boolean;
trustJwtClaims?: boolean;
jwtClaims?: {
userId?: string;
workosId?: string;
email?: string;
name?: string;
organizationId?: string;
organizationMembershipId?: string;
};
}
If your WorkOS JWT template includes custom claims for service principals or pre-resolved FGA context, you can map them directly into the authenticated WorkOSUser:
const auth = new MastraAuthWorkos({
apiKey: 'your_workos_api_key',
clientId: 'your_workos_client_id',
redirectUri: 'https://your-app.com/auth/callback',
trustJwtClaims: true,
jwtClaims: {
organizationMembershipId: 'urn:mastra:organization_membership_id',
organizationId: 'org_id',
},
});
With trustJwtClaims: true, Mastra can authenticate verified bearer tokens from a WorkOS custom JWT template even when workos.userManagement.getUser() is not the right lookup path, such as machine-to-machine or service-account tokens.
For in-process cron jobs, scheduled workflows, and other trusted background work that has no JWT or human membership, pass the core FGA actor option on the specific agent, workflow, or tool invocation instead of adding a fake membership to the user. The request context must include an organizationId; Mastra denies trusted actor FGA checks without tenant scope.
authenticateToken(token: string, request): Promise<WorkOSUser | null>Verifies a JWT token using WorkOS JWKS and returns the user information if valid.
authorizeUser(user: WorkOSUser, request): Promise<boolean>Authorizes an authenticated WorkOS user. By default, this returns true when the user has the required identifiers. Override this method in a subclass if you need stricter authorization.
FAQs
Mastra WorkOS Auth integration
The npm package @mastra/auth-workos receives a total of 2,354 weekly downloads. As such, @mastra/auth-workos popularity was classified as popular.
We found that @mastra/auth-workos demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.

Research
/Security News
A large-scale campaign abused GitHub Actions in compromised repositories to exploit CVE-2026-41940 in cPanel and WHM and steal server credentials.

Security News
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.