aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
447 stars 194 forks source link

Amplify.API.get() returns HTTP 403 error if queryParameters is present on request object #2542

Closed ermi-ltd closed 1 year ago

ermi-ltd commented 1 year ago

Describe the bug

When calling a Amplify.API.get(), the presence of query parameters on the request object triggers a 403 HTTP Error.

Steps To Reproduce

This works:


    let request = RESTRequest(path: "/jobs")
    let data = try await Amplify.API.get(request: request)

This triggers a 403 Error:

    var queryParameters = ["deviceId": (UIDevice.current.identifierForVendor?.uuidString  ?? "unknown")]
    let request = RESTRequest(path: "/jobs", queryParameters: queryParameters)
    let data = try await Amplify.API.get(request: request)

Expected behavior

Presence of query parameters should not impact authorisation.

Amplify Framework Version

10.4.0

Amplify Categories

API

Dependency manager

Swift PM

Swift version

5.7.1

CLI version

10.4.0

Xcode version

14.1 (14B47b)

Relevant log output

n/a

Is this a regression?

Yes

Regression additional context

This worked before the swap to v2.

Device

All Devices

iOS Version

iOS

Specific to simulators

No response

Additional context

No response

ChristianTrummer99 commented 1 year ago

Same

ermi-ltd commented 1 year ago

Hi @chrisbonifacio

Thanks for triaging this issue. It’s currently blocking our development so I was wondering if there’s a timeline for getting this resolved?

We’re looking at work arounds (such as passing days with POST) but this has considerable development costs as the API to work with amplify v2 would be incompatible with the API for the amplfiy v1 which is deployed to users.

If you could share an indication of a timeline for when this might be fixed it would be very helpful. Even knowing it won’t be fixed in the next few weeks would be useful as we can then move forward with work arounds

I hope that makes some senses. Feel free to email me or DM me if I can support in anyway.

atierian commented 1 year ago

Hey @ermi-ltd, thanks for your patience. We've identified a fix and are working on getting it in our next release. We'll update you here.

KrishanMadushanka commented 1 year ago

Facing this issue.Waiting for the fix.

atierian commented 1 year ago

We have a fix in https://github.com/aws-amplify/amplify-swift/pull/2666 and working towards releasing it. In the meantime, you can test the fix on the fix/rest-api-query-encoding branch. We'll update here once a release is complete.

atierian commented 1 year ago

@ermi-ltd @KrishanMadushanka Amplify Swift v2.3.1 has been released containing the fix mentioned above. Please try it out and let us know if it resolves your issue. Thanks!

KrishanMadushanka commented 1 year ago

@atierian Thanks for the quick response and fix. Amplify Swift v2.3.1 resolves the issue.

Thanks!

ermi-ltd commented 1 year ago

@atierian Thanks for the update. Due to this issue we no longer use Amplify in our API layer so I won't be able to provide feedback on the fix.

atierian commented 1 year ago

Thanks for letting us know.