Skip to content

Commit a4d72a6

Browse files
committed
add auth security scheme to api endpoints
1 parent ed3da44 commit a4d72a6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/api/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export function withRoles<T extends FastifyZodOpenApiSchema>(
3232
schema: T,
3333
): T & RoleSchema {
3434
return {
35+
security: [{ bearerAuth: [] }],
3536
"x-required-roles": roles,
3637
description: `Requires one of the following roles: ${roles.join(", ")}.${schema.description ? "\n\n" + schema.description : ""}`,
3738
...schema,

src/api/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ async function init(prettyPrint: boolean = false) {
165165
},
166166
],
167167
openapi: "3.0.3" satisfies ZodOpenApiVersion, // If this is not specified, it will default to 3.1.0
168+
components: {
169+
securitySchemes: {
170+
bearerAuth: {
171+
type: "http",
172+
scheme: "bearer",
173+
bearerFormat: "JWT",
174+
description:
175+
"Authorization: Bearer {token}\n\nThis API uses JWT tokens issued by Entra ID (Azure AD) with the Core API audience. Tokens must be included in the Authorization header as a Bearer token for all protected endpoints.",
176+
},
177+
},
178+
},
168179
},
169180
transform: fastifyZodOpenApiTransform,
170181
transformObject: fastifyZodOpenApiTransformObject,

0 commit comments

Comments
 (0)