diff --git a/src/routes/auth.ts b/src/routes/auth.ts index 888abc0..fa46628 100644 --- a/src/routes/auth.ts +++ b/src/routes/auth.ts @@ -44,10 +44,10 @@ export default ( const getIssueTokenHandler = (fastify: FastifyInstance) => { return async (request: FastifyRequest, reply: FastifyReply) => { - const { authentication } = request.headers; + const { authorization } = request.headers; const { validity, scope, strict } = request.body; - if (!authenticateIssuerToken(authentication, fastify.config.SECRET)) { + if (!authenticateIssuerToken(authorization, fastify.config.SECRET)) { return reply.status(401).send({ statusCode: 401, error: "Invalid Issuer Token", diff --git a/src/schemas/auth.ts b/src/schemas/auth.ts index c045d39..bf04e9a 100644 --- a/src/schemas/auth.ts +++ b/src/schemas/auth.ts @@ -1,7 +1,7 @@ import { Static, Type } from "@sinclair/typebox"; export const IssueTokenRequestHeaders = Type.Object({ - authentication: Type.String(), + authorization: Type.String(), }); export type IssueTokenRequestHeadersType = Static; diff --git a/tests/auth.test.ts b/tests/auth.test.ts index 48dda50..8512507 100644 --- a/tests/auth.test.ts +++ b/tests/auth.test.ts @@ -73,7 +73,7 @@ test("POST '/api/v1/issue-token' issues token with default values", async (t) => scope: "https://example.com", }, headers: { - Authentication: `Bearer ${TEST_ISSUER_TOKEN}`, + Authorization: `Bearer ${TEST_ISSUER_TOKEN}`, }, }); @@ -105,7 +105,7 @@ test("POST '/api/v1/issue-token' issues token with custom validity", async (t) = validity: 3600, }, headers: { - Authentication: `Bearer ${TEST_ISSUER_TOKEN}`, + Authorization: `Bearer ${TEST_ISSUER_TOKEN}`, }, }); @@ -137,7 +137,7 @@ test("POST '/api/v1/issue-token' issues token with strict attribute", async (t) strict: true, }, headers: { - Authentication: `Bearer ${TEST_ISSUER_TOKEN}`, + Authorization: `Bearer ${TEST_ISSUER_TOKEN}`, }, }); @@ -155,7 +155,7 @@ test("POST '/api/v1/issue-token' issues token with strict attribute", async (t) t.assert(payload.iat! >= stamp); }); -test("POST '/api/v1/issue-token' rejects requests without authentication", async (t) => { +test("POST '/api/v1/issue-token' rejects requests without authorization", async (t) => { const { app } = t.context; const response = await app.inject({ @@ -171,11 +171,11 @@ test("POST '/api/v1/issue-token' rejects requests without authentication", async t.deepEqual(body, { statusCode: 400, error: "Bad Request", - message: "headers must have required property 'authentication'", + message: "headers must have required property 'authorization'", }); }); -test("POST '/api/v1/issue-token' rejects requests with invalid authentication", async (t) => { +test("POST '/api/v1/issue-token' rejects requests with invalid authorization", async (t) => { const { app } = t.context; const response = await app.inject({ @@ -186,7 +186,7 @@ test("POST '/api/v1/issue-token' rejects requests with invalid authentication", }, headers: { // correctly signed visit token - but not an issuer token - Authentication: `Bearer ${TEST_TOKEN}`, + Authorization: `Bearer ${TEST_TOKEN}`, }, }); diff --git a/tests/snapshots/swagger.test.ts.md b/tests/snapshots/swagger.test.ts.md index 3e5b6a7..7a2c6a4 100644 --- a/tests/snapshots/swagger.test.ts.md +++ b/tests/snapshots/swagger.test.ts.md @@ -296,7 +296,7 @@ Generated by [AVA](https://avajs.dev). parameters: [ { in: 'header', - name: 'authentication', + name: 'authorization', required: true, schema: { type: 'string', @@ -1043,7 +1043,7 @@ Generated by [AVA](https://avajs.dev). parameters: [ { in: 'header', - name: 'authentication', + name: 'authorization', required: true, schema: { type: 'string', diff --git a/tests/snapshots/swagger.test.ts.snap b/tests/snapshots/swagger.test.ts.snap index d1b4e44..11b2737 100644 Binary files a/tests/snapshots/swagger.test.ts.snap and b/tests/snapshots/swagger.test.ts.snap differ