Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b64 crit #342

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/purple-colts-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/app-sdk": patch
---

WIP
6 changes: 5 additions & 1 deletion src/middleware/with-jwt-verified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export const withJWTVerified =

const JWKS = jose.createRemoteJWKSet(new URL(getJwksUrlFromSaleorApiUrl(saleorApiUrl)));
debug("Trying to compare JWKS with token");
await jose.jwtVerify(token, JWKS);
await jose.jwtVerify(token, JWKS, {
crit: {
b64: true,
},
});
} catch (e) {
debug("Failure: %s", e);
debug("Will return with Bad Request");
Expand Down
6 changes: 5 additions & 1 deletion src/verify-jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export const verifyJWT = async ({

const JWKS = jose.createRemoteJWKSet(new URL(getJwksUrlFromSaleorApiUrl(saleorApiUrl)));
debug("Trying to compare JWKS with token");
await jose.jwtVerify(token, JWKS);
await jose.jwtVerify(token, JWKS, {
crit: {
b64: true,
},
});
} catch (e) {
debug("Failure: %s", e);
debug("Will return with Bad Request");
Expand Down
6 changes: 6 additions & 0 deletions src/verify-signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const verifySignatureFromApiUrl = async (
protected: header,
payload: rawBody,
signature: jwsSignature,
header: {
b64: true,
},
};

const remoteJwks = jose.createRemoteJWKSet(
Expand Down Expand Up @@ -52,6 +55,9 @@ export const verifySignatureWithJwks = async (jwks: string, signature: string, r
protected: header,
payload: rawBody,
signature: jwsSignature,
header: {
b64: true,
},
};

let localJwks: jose.FlattenedVerifyGetKey;
Expand Down