Skip to content

Commit 19e151b

Browse files
rphansen91Mastra Code (anthropic/claude-opus-4-5)
andcommitted
fix: use mastra__userPermissions key to match main branch pattern
The auth middleware sets both 'mastra__userPermissions' and 'userPermissions' for backward compatibility, but main branch uses the namespaced key. Restoring consistency with main. Co-Authored-By: Mastra Code (anthropic/claude-opus-4-5) <noreply@mastra.ai>
1 parent dfcbe08 commit 19e151b

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

server-adapters/express/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ export class MastraServer extends MastraServerBase<Application, Request, Respons
548548
if (authConfig) {
549549
const hasPermission = await loadHasPermission();
550550
if (hasPermission) {
551-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
551+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
552552
const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission, requestContext);
553553

554554
if (permissionError) {
@@ -656,7 +656,7 @@ export class MastraServer extends MastraServerBase<Application, Request, Respons
656656
if (authConfig) {
657657
const hasPermission = await loadHasPermission();
658658
if (hasPermission) {
659-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
659+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
660660
const permissionError = this.checkRoutePermission(
661661
serverRoute,
662662
userPermissions,

server-adapters/fastify/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ export class MastraServer extends MastraServerBase<FastifyInstance, FastifyReque
638638
if (authConfig) {
639639
const hasPermission = await loadHasPermission();
640640
if (hasPermission) {
641-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
641+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
642642
const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission, requestContext);
643643

644644
if (permissionError) {
@@ -781,7 +781,7 @@ export class MastraServer extends MastraServerBase<FastifyInstance, FastifyReque
781781
}
782782

783783
if (hasPermission) {
784-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
784+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
785785
const permissionError = this.checkRoutePermission(
786786
serverRoute,
787787
userPermissions,

server-adapters/hono/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ export class MastraServer extends MastraServerBase<HonoApp, HonoRequest, Context
528528
if (authConfig) {
529529
const hasPermission = await loadHasPermission();
530530
if (hasPermission) {
531-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
531+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
532532
const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission, requestContext);
533533

534534
if (permissionError) {
@@ -646,7 +646,7 @@ export class MastraServer extends MastraServerBase<HonoApp, HonoRequest, Context
646646
if (authConfig) {
647647
const hasPermission = await loadHasPermission();
648648
if (hasPermission) {
649-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
649+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
650650
const permissionError = this.checkRoutePermission(
651651
serverRoute,
652652
userPermissions,

server-adapters/koa/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class MastraServer extends MastraServerBase<Koa, Context, Context> {
471471
if (authConfig) {
472472
const hasPermission = await loadHasPermission();
473473
if (hasPermission) {
474-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
474+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
475475
const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission, requestContext);
476476

477477
if (permissionError) {
@@ -931,7 +931,7 @@ export class MastraServer extends MastraServerBase<Koa, Context, Context> {
931931
if (authConfig) {
932932
const hasPermission = await loadHasPermission();
933933
if (hasPermission) {
934-
const userPermissions = requestContext.get('userPermissions') as string[] | undefined;
934+
const userPermissions = requestContext.get('mastra__userPermissions') as string[] | undefined;
935935
const permissionError = server.checkRoutePermission(
936936
serverRoute,
937937
userPermissions,

0 commit comments

Comments
 (0)