fix(platform-service): TODO-4 \u2014 typed cast for request.auth augmentation
The DevOps admin preHandler read 'auth' as '(request as any).auth'.
The proper Fastify pattern is 'declare module' augmentation in
@bytelyst/fastify-auth, but the inline cast through 'unknown' is
sufficient for now and avoids touching the shared auth package.
Changed:
- 'const auth = (request as any).auth;' \u2192
'const auth = (request as unknown as { auth?: { role?: string } }).auth;'
Inline comment notes the cleaner 'declare module' alternative.
Final ecosystem state:
scripts/check-rule-violations.sh: 0 findings across all rules \u2713
web-hardcoded-hex: 0 \u2713
b5-hardcoded-product-id: 0 \u2713
b4-console-log: 0 \u2713
b4-swift-print: 0 \u2713
b4-python-print: 0 \u2713
ts-any-type: 0 \u2713
b7-emoji-in-code: 0 \u2713
This commit is contained in:
parent
47af9f816a
commit
9d405952e2
@ -300,8 +300,11 @@ await app.register(
|
|||||||
'/devops/info',
|
'/devops/info',
|
||||||
{
|
{
|
||||||
preHandler: async (request, reply) => {
|
preHandler: async (request, reply) => {
|
||||||
// Require admin role
|
// Require admin role. The `auth` property is decorated onto the
|
||||||
const auth = (request as any).auth;
|
// Fastify request by the auth preHandler upstream; cast through
|
||||||
|
// `unknown` to read it without `any` (a `declare module` augmentation
|
||||||
|
// would be cleaner but requires touching @bytelyst/fastify-auth).
|
||||||
|
const auth = (request as unknown as { auth?: { role?: string } }).auth;
|
||||||
if (!auth || auth.role !== 'admin') {
|
if (!auth || auth.role !== 'admin') {
|
||||||
return reply.code(403).send({ error: 'Admin access required' });
|
return reply.code(403).send({ error: 'Admin access required' });
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user