paws icon indicating copy to clipboard operation
paws copied to clipboard

Signing a request without sending

Open samdeleu opened this issue 3 years ago • 2 comments

Hi, I am quite impressed with this library. For a project i need to send a signed request to another server that will use this request to execute the signed request. Is there a possibility to sign a request (new_request) only, without sending?

I saw there is a Signer, but it is not exported.

Thank you in advance

samdeleu avatar Feb 18 '22 13:02 samdeleu

Thanks! I would like to work on this but unfortunately don't have the time right now, sorry to say, but hopefully one of the items below may help.

A couple questions:

  1. Do you have an example of how to do this with another SDK, e.g. the Python AWS SDK?

  2. First idea: Could you send all the arguments to the other server and then have the other server call the function, e.g. store the function arguments in args and then on the other server, call do.call(my_aws_function, args)? Or does the other server not have the right credentials?

  3. Second idea: monkey patch send_request to return the signed request to you. See the example below. The internal implementation is unlikely to change any time soon so this is likely to work for the forseeable future. You'll have to monkey patch it again on the sending server to take the signed request and send it.

# Monkey patch paws to get the signed request.
# See https://dlukes.github.io/monkey-patching-in-r.html
paws.common <- getNamespace("paws.common")
unlockBinding("send_request", paws.common)
send_request <- with(paws.common, {
  function(request) {
    request <- sign(request)
    return(request)
  }
})
paws.common$send_request <- send_request
lockBinding("send_request", paws.common)

# Get the signed request.
s3 <- paws::s3()
signed_request <- s3$list_buckets()

davidkretch avatar Feb 20 '22 15:02 davidkretch

Ok, that will do for me. Thank you very much

samdeleu avatar Feb 21 '22 11:02 samdeleu