-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
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
core: add api key flow #234
Comments
I don't think that extending OAuth2 is smart. OAuth2 is for authorizing third party apps, web/mobile api keys are for authentication of public clients and quota checking and similar. I think it should be possible to validate these tokens using the token valid warden endpoint. Tokens can be issued by any subject that is allowed to do so by policies. The endpoint would reside in:
The key will be matched against an url (web) or namespace (ios, android). I am in the process of figuring out how to validate those tokens:
|
Regarding #234 (comment) I am not 100% sure. One thing that comes with API tokens is that users are usually allowed to update allowed hosts and ios/andorid namespaces without having to change the API token everywhere. In extension to above, API tokens are delegated authorization rights as well. They could, based on policies, allow user agents to do write requests as well (think anonymous comments). Using the existing OAuth2 infrastructure would additionally allow to leverage OAuth2 Access Token Validation as well as existing Access Token Issuance. By setting the TTL high (e.g. 50 years), they would basically never run out of validity and they could be revoked once #223 lands. API Tokens could be, for example, exchanged by ID Tokens
and modified through a new endpoint
One question to answer is if api keys can be issued with an id_token only, or if clients can issue those as well. I can currently not see any problems with allowing both, although restricting on id_token and opening up later would be the safer route. Another thing that I have not solved yet is, the token's subject. There are two things to consider:
Validating the keys could be achieved using the LocalWarden:
Alternatively, it could be achieved through policy conditions:
|
I do not think that the following statement holds:
The reason being that we want to limit the scope of an API Key, not distinguish in the resource server what to do if we encounter such a token. So instead of the things written above, API Keys should be issued to a limited set of scopes, which are always validated when looking up the token. For example: We want users to be able to issue api keys in order to
Both of these endpoints have a certain scope:
Other endpoints, like uploading images would have different scopes like I think that the distinction here is: Policy lookups are used to check if a subject is allowed to do something. An API Key is issued on behalf of a subject, it is not a subject itself. Instead, the API Key carries a subset of to the subject's capabilities. If this logic holds, it would make sense to have API Keys as an extension to OAuth2. |
This is now being formalised as https://github.com/ory-am/fosite/wiki/OAuth2-API-Key-Grant-Type-Draft |
Some initial spec:
...still have to figure out how to check domains |
@waynerobinson summed this up perfectly:
|
This can be solved much better with a proxy scenario. The proxy requests an oauth2 access and refresh token using authorize code and issues a handle, which is the API key. Then, when an API key is set in a request, it is replaced with the access token. |
@arekkas I have an ask for this, are you still interested in implementing it? |
Not really, API keys are actually for identification, not authorization so it's not really in the scope of hydra |
Hydra should support issuance of API tokens which are bound to a domain, a iOS namespace or an android namespace and targeted at services that require identification of public clients. One possibility would be to extend OAuth2 with a protocol (I could not find a spec for API tokens) or add an enpoint for it.
If OAuth2 is to be extended, the OAuth2 client will be the subject of the token. Upon request a namespace request var should be included containing a list of domans/ios/android namespaces.
API tokens are used for google maps and are used for quota checking and similar.
Here is an exemplary flow of creating such API Tokens on GCP.
1. Choose from options

2. Key created

3. Update key

4. Key overview

The text was updated successfully, but these errors were encountered: