feat: turn on oauth2 state check for PAIA

Closes #172
This commit is contained in:
Jovan Krunić
2022-01-25 20:53:25 +01:00
parent 72060cbed7
commit 5bd0b50816

View File

@@ -92,13 +92,12 @@ export class PAIAAuthorizationRequestHandler {
);
void this.removeItemsFromStorage(handle);
// const state: string | undefined = queryParams['state'];
const state: string | undefined = queryParameters['state'];
const error: string | undefined = queryParameters['error'];
// TODO: we need state from PAIA (we don't get state at the moment)
// if (state !== request.state) {
// throw new Error("State Does Not Match");
// }
if (state !== request.state) {
throw new Error('State Does Not Match');
}
return <PAIAAuthorizationRequestResponse>{
request: request, // request
@@ -212,6 +211,7 @@ export class PAIAAuthorizationRequestHandler {
const query = this.utils.stringify(requestMap);
const baseUrl = configuration.authorizationEndpoint;
return `${baseUrl}?${query}&grant_type=client_credentials`;
// required encoding (PAIA specific)
return `${baseUrl}?${encodeURIComponent(query)}`;
}
}