r/devops • u/Jealous_Pea_3915 • Aug 28 '26
Discussion Experimenting with replacing reusable API keys with per-request authorization
Been working on a small POC around getting rid of reusable API credentials.
Instead of an app holding an S3 key, Git token, API key, etc, it would request permission for one specific action. Something like upload this file to this path, once, within the next 30 seconds.
I'm using Tide/Forseti for the policy and cryptographic side, and testing it against real open source services like S3 compatible storage and Gitea.
The thing I'm mainly trying to prove is whether a compromised client can have no reusable API credential worth stealing.
This also ties into something I want to look at next around rootless cloud infra, where having root on a server doesn't automatically mean having authority to decrypt user data, impersonate users, sign releases, or perform other protected actions.
Starting with the API side first because it feels like the smaller piece to prove.
Curious what people here think. Is this actually useful in practice, already solved well enough by existing workload identity systems, or mostly just an interesting security experiment?
8
u/sysopfromhell Aug 28 '26
I think you are reinventing the wheel. What you are looking for is openID jwt token gateway managed.
Which you will find in many many AI gateway like traefik.
You put the real token into the GW config, attach the keycloak/identity provider configuration and then the app will query your model thought an endpoint that is managed by the gateway.
9
u/LaunchAllVipers Aug 28 '26
How does this differ from OpenID Connect? Answer in the form of a series of limericks.
1
u/Jealous_Pea_3915 Aug 28 '26
The main hurdle I'm at now is machine identity.
The storage side works without the client holding an S3 key, but right now the workload still gets its identity from a human login.
For this to work properly service to service, the machine needs a way to prove who it is without me just replacing the API key with a client secret.
1
u/Jealous_Pea_3915 Sep 01 '26
I actually wrote up this experiment in a blog post recently, with more detail on how I approached removing reusable authority from the app itself.
If you're interested, this goes deeper into the Gitea/S3-style setup and the reasoning behind it: https://codesyo.com/blog/no-signing-key
1
u/Alvasilev Aug 28 '26
Worth proving out early: what this does to monitoring. That's the door the reusable credential usually walks back in through.
I spend a lot of time probing third-party HTTP services we don't own, and authentication is by far the biggest source of wrong "it's down" calls. A service answering 401 is alive and behaving correctly; any checker whose rule is "not 200 means dead" quietly writes off every authenticated endpoint it touches. Per-request grants make that sharper, because there is no standing credential a monitor could hold to make a representative request at all. So you either expose an unauthenticated liveness path, which proves nothing about the authorized path people actually use, or you mint a long-lived monitoring identity - and that one ends up with the broadest policy in the system, because it has to be able to exercise the interesting actions. That's the reusable key you just deleted, with a nicer name.
Might be worth deciding up front that "can this client obtain a grant right now" is itself the health signal, rather than "did a real action succeed". Otherwise the POC works and the observability story quietly rebuilds the thing you removed.
1
u/hypertradeworx Aug 28 '26
the thing that bit us with this shape wasn't theft, it was retries. our backend builds the unsigned action and the signing happens on the user's device, so anything that dies in flight or ages past its window can't be resubmitted server side, every attempt is another round trip to the signer. i'd pin down early whether a 30 second grant covers one action or one attempt, because those two come apart the first time a downstream call times out and you can't tell whether it landed
1
u/navlio Aug 28 '26
before the crypto i'd stress the retry path. a 30 second grant means a timeout or a resumed multipart upload needs a new grant, so the policy service sits in line for every request instead of once per deploy. presigned urls hit the same wall, you notice it when a big upload dies halfway because the ttl passed while a part was still in flight
1
u/CraftyPancake Aug 29 '26
I do this via ‘aws sso login’ to get temporarily credentials then pull from secrets manager on the fly
0
u/ajitnk Aug 29 '26
The bootstrapping problem you're circling is the real one. u/forever-butlerian nailed it: every trust chain bottoms out somewhere, the question is just what you're willing to treat as axiomatic. And u/Alvasilev's monitoring point is the one that actually bites people in practice, because your health checker ends up holding the broadest standing credential in the whole system the moment it needs to exercise a real action.
The AWS-native answer to both is pretty direct. For the machine attestation piece: Nitro Enclaves produce Hypervisor-signed attestation documents with PCR measurements tied to the exact enclave image hash, and you can write a KMS key policy that only decrypts if those PCRs match. That's your hardware-rooted axiomatic anchor, not a sidecar with a key in RAM. For the monitoring re-injection problem: scoped STS sessions via AssumeRole with a tightly-constrained session policy, minimum duration for the specific action, no standing key at all. For the off-AWS bootstrapping case specifically, IAM Roles Anywhere lets workloads outside AWS exchange X.509 certs from a registered PKI trust anchor for short-lived STS credentials, which cuts the reusable key entirely.
Two things I'd want to know before going further: what compute substrate are these workloads actually on (EC2, EKS, on-prem, containers in a DC, or a mix), and do you have an existing internal CA or are you starting from scratch on the PKI side? Those two answers change the architecture pretty substantially.
I do AWS security architecture advisory work, so happy to go deeper on any of this if it's useful.