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.

API support for multiple secrets?

See original GitHub issue

We’ve considered using a JWT as a relatively long-lived server-to-server API key (for a handful of first and second-party servers) that specifies permitted endpoints/restrictions/etc, on which we’d use blacklisting. We’ve also considered various short-lived client authorization uses where we don’t really need to worry about blacklisting.

I’m not sure how much it would matter in reality, but I would be a little more comfortable using JWTs for both purposes if it was trivial to specify separate secrets for each use case. This would:

  • reduce the number (probably by at least a few orders of magnitude) of tokens floating around that could be used to attempt brute-force recovery of the secret used to sign the API-key tokens
  • enable us to rotate more heavily-used auth secrets without having to temporarily break integrations and redistribute API-keys

One approach might be using the existing config vars when the decorators are used normally, and adding support for explicitly passing one or more secrets to the decorator. I think this could be reasonably intuitive:

API_KEY_SECRET = os.getenv("API_KEY_SECRET")
AUTH_SECRET = os.getenv("AUTH_SECRET")

@jwt_required(API_KEY_SECRET)
@route("/partner_api")
def partners(self):
   ...

@jwt_required(AUTH_SECRET)
@route("/account")
def account(self):
   ...

A more robust version might be for the decorators to accept your config objects, along with a factory that’ll generate a config object as you do currently (with defaults from app.config), but override any user-supplied values.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (14 by maintainers)

github_iconTop GitHub Comments

5reactions
vimalloccommented, Sep 16, 2018

This has now been released in v3.13.0. Check out the documentation for the custom decode key and the custom encode key

Cheers! 👍

2reactions
steinitzucommented, Sep 10, 2018

Implemented decode key callback in https://github.com/vimalloc/flask-jwt-extended/pull/191

Not sure if encode key callback can be done without breakage, I think signatures of encode methods here would have to change at least https://github.com/vimalloc/flask-jwt-extended/blob/master/flask_jwt_extended/tokens.py#L35

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Multiple Secrets - External Secrets Operator
In such cases, it is possible that an user might need to sync multiple secrets from an external provider into a single Kubernetes...
Read more >
AWS Secrets Manager quotas
Name Default Adju... Combined rate of RestoreSecret API requests Each supported Region: 50 per second No Rate of CreateSecret API requests Each supported Region: 50...
Read more >
Requesting 2 secrets from AWS Secrets Manager in One API ...
Unfortunately, the Secrets Manager API does not support passing multiple SecretId's in a single GetSecretValue call.
Read more >
API Web Services for Secret Server | Supports REST and SOAP
Make Secret Server part of your application ecosystem wherever privileged passwords are needed by using simple APIs. What's the challenge? Many applications ...
Read more >
Secret Manager API - Google Cloud
It is used to build client libraries, IDE plugins, and other tools that interact with Google APIs. One service may provide multiple discovery ......
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