question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support HMAC authorization schemes

See original GitHub issue

Hi RTK Team. First off, I’m a big fan of rtk, and excited for the direction this project is heading in. Thank you for your efforts!

Currently, prepareHeaders has this signature1:

;(
  headers: Headers,
  api: {
    getState: () => unknown
    extra: unknown
    endpoint: string
    type: 'query' | 'mutation'
    forced: boolean | undefined
  }
) => Headers

Problem:

HMAC authorization schemes typically involve hashing the request method, path, query params, and body (among others) and adding the hash result as an authorization header2.

Ideally, the mentioned values would be available to consumers within the prepareHeaders function

Proposal:

Add params to prepareHeaders at call time

Issues

There isn’t an HMAC ‘spec’ that I’m aware of, so different implementations end up wanting different parts of the request details hashed. I think the above proposal covers the common implementation areas but its likely not 100%

References:

  1. https://redux-toolkit.js.org/rtk-query/api/fetchBaseQuery
  2. https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
phryneascommented, Jul 22, 2022

@vanities args.headers = { ...args.headers, FooBarHeader: "fooBar!" }

0reactions
markeriksoncommented, Jul 26, 2022

Sounds like this has been addressed, so I’ll close this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide on implementing HMAC scheme to protect API requests
In this guide you'll learn about an important authentication scheme called HMAC - what is it, its advantages, things to consider while ...
Read more >
What is HMAC Authentication and why is it useful?
Hash-based message authentication code (HMAC) is a mechanism for calculating a message authentication code involving a hash function in ...
Read more >
Azure App Configuration REST API - HMAC authentication
You can authenticate HTTP requests by using the HMAC-SHA256 authentication scheme. (HMAC refers to hash-based message authentication code.) ...
Read more >
HMAC Authentication in Web API - Dot Net Tutorials
The HMAC stands for Hash-based Message Authentication Code. From the full form of HMAC, we need to understand two things one is Message...
Read more >
Specifying HMAC-based authentication in the spec #344
The current spec (v2.0) defines three valid security schemes: basic HTTP authentication, authentication using an API key, and Oauth2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found