Skip to content

Commit edcc767

Browse files
author
Miłosz Skaza
authored
rename auth header from authentication to authorization (#47)
1 parent fc0350c commit edcc767

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/routes/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export default (
4444

4545
const getIssueTokenHandler = (fastify: FastifyInstance) => {
4646
return async (request: FastifyRequest, reply: FastifyReply) => {
47-
const { authentication } = <IssueTokenRequestHeadersType>request.headers;
47+
const { authorization } = <IssueTokenRequestHeadersType>request.headers;
4848
const { validity, scope, strict } = <IssueTokenRequestType>request.body;
4949

50-
if (!authenticateIssuerToken(authentication, fastify.config.SECRET)) {
50+
if (!authenticateIssuerToken(authorization, fastify.config.SECRET)) {
5151
return reply.status(401).send({
5252
statusCode: 401,
5353
error: "Invalid Issuer Token",

src/schemas/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Static, Type } from "@sinclair/typebox";
22

33
export const IssueTokenRequestHeaders = Type.Object({
4-
authentication: Type.String(),
4+
authorization: Type.String(),
55
});
66
export type IssueTokenRequestHeadersType = Static<typeof IssueTokenRequestHeaders>;
77

tests/auth.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ test("POST '/api/v1/issue-token' issues token with default values", async (t) =>
7373
scope: "https://example.com",
7474
},
7575
headers: {
76-
Authentication: `Bearer ${TEST_ISSUER_TOKEN}`,
76+
Authorization: `Bearer ${TEST_ISSUER_TOKEN}`,
7777
},
7878
});
7979

@@ -105,7 +105,7 @@ test("POST '/api/v1/issue-token' issues token with custom validity", async (t) =
105105
validity: 3600,
106106
},
107107
headers: {
108-
Authentication: `Bearer ${TEST_ISSUER_TOKEN}`,
108+
Authorization: `Bearer ${TEST_ISSUER_TOKEN}`,
109109
},
110110
});
111111

@@ -137,7 +137,7 @@ test("POST '/api/v1/issue-token' issues token with strict attribute", async (t)
137137
strict: true,
138138
},
139139
headers: {
140-
Authentication: `Bearer ${TEST_ISSUER_TOKEN}`,
140+
Authorization: `Bearer ${TEST_ISSUER_TOKEN}`,
141141
},
142142
});
143143

@@ -155,7 +155,7 @@ test("POST '/api/v1/issue-token' issues token with strict attribute", async (t)
155155
t.assert(payload.iat! >= stamp);
156156
});
157157

158-
test("POST '/api/v1/issue-token' rejects requests without authentication", async (t) => {
158+
test("POST '/api/v1/issue-token' rejects requests without authorization", async (t) => {
159159
const { app } = t.context;
160160

161161
const response = await app.inject({
@@ -171,11 +171,11 @@ test("POST '/api/v1/issue-token' rejects requests without authentication", async
171171
t.deepEqual(body, {
172172
statusCode: 400,
173173
error: "Bad Request",
174-
message: "headers must have required property 'authentication'",
174+
message: "headers must have required property 'authorization'",
175175
});
176176
});
177177

178-
test("POST '/api/v1/issue-token' rejects requests with invalid authentication", async (t) => {
178+
test("POST '/api/v1/issue-token' rejects requests with invalid authorization", async (t) => {
179179
const { app } = t.context;
180180

181181
const response = await app.inject({
@@ -186,7 +186,7 @@ test("POST '/api/v1/issue-token' rejects requests with invalid authentication",
186186
},
187187
headers: {
188188
// correctly signed visit token - but not an issuer token
189-
Authentication: `Bearer ${TEST_TOKEN}`,
189+
Authorization: `Bearer ${TEST_TOKEN}`,
190190
},
191191
});
192192

tests/snapshots/swagger.test.ts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ Generated by [AVA](https://avajs.dev).
296296
parameters: [
297297
{
298298
in: 'header',
299-
name: 'authentication',
299+
name: 'authorization',
300300
required: true,
301301
schema: {
302302
type: 'string',
@@ -1043,7 +1043,7 @@ Generated by [AVA](https://avajs.dev).
10431043
parameters: [
10441044
{
10451045
in: 'header',
1046-
name: 'authentication',
1046+
name: 'authorization',
10471047
required: true,
10481048
schema: {
10491049
type: 'string',

tests/snapshots/swagger.test.ts.snap

-16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)