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

fix(api-rest): Allow x-api-key to pass through any REST API calls. #13394

Closed
wants to merge 2 commits into from

Conversation

ashika112
Copy link
Member

@ashika112 ashika112 commented May 17, 2024

Description of changes

Allow x-api-key to pass through. We should check only custom authorization to override the IAM auth. This bring v6 in parity with v5 feature.

V5 Ref:

if (typeof params.headers['Authorization'] !== 'undefined') {

Issue #, if available

#13310
#13378

Description of how you validated changes

  • Manual testing
  • Unit tests

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ashika112 ashika112 marked this pull request as ready for review May 17, 2024 00:05
@ashika112 ashika112 requested review from a team as code owners May 17, 2024 00:05
@HuiSF HuiSF changed the title [Fix] Allow x-api-key to pass through any REST API calls. fix(api-rest): Allow x-api-key to pass through any REST API calls. May 17, 2024
@@ -168,7 +168,33 @@ describe('internal post', () => {
);
});

it('should call unauthenticatedHandler with custom x-api-key header and signingServiceInfo', async () => {
it('should call authenticatedHandler with custom x-api-key header and serviceSigningInfo', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should change any behavior on the internalPost, it will affect the GQL handler.
Instead we should only change for public APIs.

@@ -100,7 +100,7 @@ export const transferHandler = async (
const iamAuthApplicable = (
{ headers }: HttpRequest,
signingServiceInfo?: SigningServiceInfo,
) => !headers.authorization && !headers['x-api-key'] && !!signingServiceInfo;
) => !headers.authorization && !!signingServiceInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since iamAuthApplicable is also used by internalPost, we should make a bigger refactor to make the change public handlers, but do not change the internalPost behavior. Once way can be moving the iamAuthApplicable logic from shared handler.ts code path to publicApis.ts and internalPost.ts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see what u are saying. Okay let me take a look.

@ashika112
Copy link
Member Author

@AllanZhengYP OK yeah i think the refactoring iamAuthApplicable out and passing might work. Thanks for pointing graphQL bit it was not apparent. I will open a new PR for this.

@ashika112 ashika112 closed this May 17, 2024
@ashika112 ashika112 deleted the fix/rest/x-api-key branch May 17, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants