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

Best method for AWS SigV4 signing #481

Open
willvincent opened this issue Feb 13, 2025 · 0 comments
Open

Best method for AWS SigV4 signing #481

willvincent opened this issue Feb 13, 2025 · 0 comments

Comments

@willvincent
Copy link

It appears as though only PendingRequest is available to the Authenticator interface.

Unfortunately, the AWS sdk requires the psr http-message RequestInterface to sign a request. As such it seems that the best (and perhaps only) method available to do sign requests for aws is to add the handlePsrRequest method to the connector or request class.

I'm just wondering if there's a cleaner way to do this with the authenticator interface, which seems like it'd be the better place to add the signatures, though it's not clear how I'd accomplish it.

Within the handlePsrRequest method though, it looks like I can simply do this:

use Aws\Credentials\Credentials;
use Aws\Signature\SignatureV4;

public function handlePsrRequest(RequestInterface $request, PendingRequest $pendingRequest): RequestInterface
{
    $signature = new SignatureV4('execute-api', 'us-east-1');
    $credentials = new Credentials('MY_IAM', 'MY_SECRET_KEY');

    return $signature->signRequest($request, $credentials);
}

If this can be handled through an authenticator that'd be ideal, but either way - it'd be good to get some documentation in place, I can't imagine I'm the only person to want to use Saloon with an AWS ApiGateway api.

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