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

Change to method of providing URL path appears required #5

Open
crspybits opened this issue Feb 5, 2019 · 2 comments
Open

Change to method of providing URL path appears required #5

crspybits opened this issue Feb 5, 2019 · 2 comments

Comments

@crspybits
Copy link

It seems like there's a conceptual problem with needing to provide the complete URL path as part of the URLRequest for the sign method. I ran across this implementing the AWS SNS Publish method. A URL parameter required there is in JSON format. It seems that in order for the URLRequest(url: url) to work, I have to URL encode the URL for the JSON. However, within SwiftAWSSignatureV4 there is a second URL encode step, which then later causes the signature re-generation on the AWS side to fail. Thus, it seems necessary to pass the URL or the query args at least separately into the sign method in this case. Not a huge change to the code, but a definite conceptual issue. I'm going add this to my existing PR.

@crspybits
Copy link
Author

crspybits commented Feb 5, 2019

Actually, upon deeper looking into this, I think this is a bigger problem. I had thought I could modify the url of the URLRequest inside of the signing method to deal with passing in a URL query arg separately. However, this doesn't seem possible. URLRequest is a struct and self.url is cannot be changed inside of the extension. I see two ways of dealing with this:

  1. Return the URL encoded query arg from the signing method and require the caller to update the URLRequest with this returned value.

  2. Change the way the signing works. Don't have it operate on a URLRequest. This could either be an alternative interface in this library, or a replacement for the existing sign method. In some ways this approach seems preferable to the current approach, given that not all users of such a class will actually use a URLRequest. E.g., I'm using the Kitura HTTP client.

@crspybits
Copy link
Author

Ah. My bad. I see if the method is mutating, you can change url :).

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

No branches or pull requests

1 participant