We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I need to sign my requests with SignatureV4 to access some AWS_IAM secured APIs.
To sign a request I need to access target url, method, headers and the body data (see ky hook example implementation below).
I'd like to do the same with the @actions/http-client, however currently I can't access url, method and the body data in the RequestHandler.prepareRequest(options: http.RequestOptions):void hook, see https://github.com/actions/toolkit/blob/797f48fcfac3bcc50833df1ff0d35b16d7401503/packages/http-client/src/interfaces.ts#L57C1-L57C1
@actions/http-client
RequestHandler.prepareRequest(options: http.RequestOptions):void
So make url, method and body data accessible to RequestHandler.prepareRequest(options: http.RequestOptions):void as well.
hy hook example of SignatureV4 signer implementation
import {SignatureV4} from "@smithy/signature-v4"; import {HttpRequest} from "@smithy/protocol-http"; import {BeforeRequestHook} from "ky"; export function AwsRequestSigner(signer: SignatureV4): BeforeRequestHook { return async (request: Request) => { const requestUrl = new URL(request.url); const requestHeaders = Object.fromEntries(request.headers.entries()); if (requestHeaders["Authorization"]) { // preserve Authorization header requestHeaders["X-Authorization"] = requestHeaders["Authorization"]; delete requestHeaders["Authorization"]; } const canonicalRequest = new HttpRequest({ hostname: requestUrl.hostname, // port: requestUrl.port ? parseInt(requestUrl.port) : undefined, path: requestUrl.pathname, protocol: requestUrl.protocol, method: request.method, body: await request.text(), query: Object.fromEntries(requestUrl.searchParams.entries()), headers: { ...requestHeaders, "Host": requestUrl.host, }, }); const signedCanonicalRequest = await signer.sign(canonicalRequest); return new Request(request, { headers: signedCanonicalRequest.headers, body: signedCanonicalRequest.body, }) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I need to sign my requests with SignatureV4 to access some AWS_IAM secured APIs.
To sign a request I need to access target url, method, headers and the body data (see ky hook example implementation below).
I'd like to do the same with the
@actions/http-client
, however currently I can't access url, method and the body data in theRequestHandler.prepareRequest(options: http.RequestOptions):void
hook, see https://github.com/actions/toolkit/blob/797f48fcfac3bcc50833df1ff0d35b16d7401503/packages/http-client/src/interfaces.ts#L57C1-L57C1So make url, method and body data accessible to
RequestHandler.prepareRequest(options: http.RequestOptions):void
as well.hy hook example of SignatureV4 signer implementation
The text was updated successfully, but these errors were encountered: