Skip to content

Commit 71e83a0

Browse files
committed
fix: Check grant_type on token requests
Not sure why this was commented out. I might accidentally discover why at some point in the future after much frustration.
1 parent 981c989 commit 71e83a0

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

packages/uma/src/dialog/Input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Permission } from "../views/Permission";
77
*/
88
export const DialogInput = ({
99
"@context": $(string),
10+
grant_type: $(string),
1011
ticket: $(string),
1112
claim_token: $(string),
1213
claim_token_format: $(string), // TODO: switch to array of claims objects with unknown structure

packages/uma/src/routes/Token.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ export class TokenRequestHandler extends HttpHandler {
2121
this.logger.info(`Received token request.`);
2222
const params = input.request.body;
2323

24-
// if (params['grant_type'] !== 'urn:ietf:params:oauth:grant-type:uma-ticket') {
25-
// throw new BadRequestHttpError(
26-
// `Expected 'grant_type' to be set to 'urn:ietf:params:oauth:grant-type:uma-ticket'
27-
// `);
28-
// }
29-
3024
try {
3125
reType(params, DialogInput);
3226
} catch (e) {
3327
throw new BadRequestHttpError(`Invalid token request body: ${e instanceof Error ? e.message : ''}`);
3428
}
3529

30+
if (params['grant_type'] !== 'urn:ietf:params:oauth:grant-type:uma-ticket') {
31+
throw new BadRequestHttpError(
32+
`Expected 'grant_type' to be set to 'urn:ietf:params:oauth:grant-type:uma-ticket'
33+
`);
34+
}
35+
3636
try {
3737
const tokenResponse = await this.negotiator.negotiate(params);
3838

0 commit comments

Comments
 (0)