Skip to content

Commit

Permalink
Add access token validation for google
Browse files Browse the repository at this point in the history
  • Loading branch information
nkshah2 committed Sep 7, 2023
1 parent b8f2841 commit a6c0dea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/build/recipe/thirdparty/providers/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ function Google(input) {
{ included_grant_scopes: "true", access_type: "offline" },
input.config.authorizationEndpointQueryParams
);
if (input.config.validateAccessToken === undefined) {
input.config.validateAccessToken = ({ accessTokenPayload, clientConfig }) =>
__awaiter(this, void 0, void 0, function* () {
if (accessTokenPayload.aud !== clientConfig.clientId) {
throw Error("accessTokenPayload.aud does not match clientId");
}
});
}
const oOverride = input.override;
input.override = function (originalImplementation) {
const oGetConfig = originalImplementation.getConfigForClientType;
Expand Down
8 changes: 8 additions & 0 deletions lib/ts/recipe/thirdparty/providers/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export default function Google(input: ProviderInput): TypeProvider {
...input.config.authorizationEndpointQueryParams,
};

if (input.config.validateAccessToken === undefined) {
input.config.validateAccessToken = async ({ accessTokenPayload, clientConfig }) => {
if (accessTokenPayload.aud !== clientConfig.clientId) {
throw Error("accessTokenPayload.aud does not match clientId");
}
};
}

const oOverride = input.override;

input.override = function (originalImplementation) {
Expand Down

0 comments on commit a6c0dea

Please sign in to comment.