Reputation: 7507
Our application exposes REST APIs which are currently used by our UI only. The UI currently authenticates users using the OIDC Authorization Code flow, which requires user interaction with the authorization server, in this case, AWS Cognito.
We need to provide customers with a way to authenticate with our application and call our APIs with their own integrated client applications, other than our UI, in a "M2M"-friendly manner. Meaning, we want them to be able to call our APIs from a python script they've developed, for example, or POST data to our API from their application.
The solution proposed by Engineering:
We are told that using API keys like this is insecure, and, instead, we should implement the OAuth2 Client Credential flow (using the Private Key JWT method).
My questions:
Upvotes: 0
Views: 123
Reputation: 29291
The customer should route requests to your APIs via their own APIs. It is a little unclear from your question whether your data has a relationship with the customer's users. Eg do you store resources mapped to particular users?
OAUTH FLOWS
The benefits of using an OAuth flow like client credentials include these:
tenant_id
claim and scopes, to reduce privileges and the impact of stolen tokensIn your API keys solution, an attacker might be able to replay a stolen credential for a long time, regardless of whether it is hashed and salted. Also, a server breach might reveal the API keys of all customers, since an attacker could hash and salt stolen values and resend them.
USER AUTHENTICATION
When a user is present, you run a code flow and always authenticate the user. How this works is left to the implementation of the authorization server (and how you configure it) in the OAuth and OIDC standards. If you clarify the relationship of customer users to your APIs I will expand on this. It might be that the code flow is the correct flow rather than the client credentials flow.
PROVIDERS
You should spend some time to identify the standardised flows and security behaviours that OAuth enables for your use case. The solution you choose might also depend on data sensitivity, threat mitigations and your time to market.
If you choose OAuth then clarify your requirements and do a proof of concept before committing to a provider. An OAuth solution should keep your your code simple, while you use security vetted by many experts.
Upvotes: 1