Add OAuth Refresh token when openid
scope is used
#5497
Closed
+9
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
OSM
access_token
don't have expiry butid_token
which is generated whenopenid
scope is enabled has expiry of 2 minutes. Makingid_token
to also never expiry seems to me more problematic than no expiry foraccess_token
becauseid_token
can not be revoked, hence it is important to have short expiry. But with short expiry it makesid_token
not very useful and it would complicate authentication against 3rd party services. Instead I think it is better to enable refresh token on OSM whenopenid
scope is enabled for app which allows apps to refreshid_token
by calling/oauth/token
using refresh token. This way app can refreshid_token
at any time and send it to 3rd party service which can authenticate user.How has this been tested?
Added unit tests, and manually on my machine, also verified that calling
/oauth/token
with refresh token works and produces freshid_token
.More details
My main goal on how to use this is following. Mobile app such as EveryDoor, StreetComplete... Can add
openid
to their OAuth Application scopes. That will result in gettingid_token
property in JSON of osm.org/oauth/token that can be passed to Panoramax asAuthorization Bearer jwt_token_that_osm.org/oauth/token_returned_in_id_token_field
when uploading photos. This will allow Panoramax API to use https://www.openstreetmap.org/oauth2/discovery/keys which has public key stored that can be used to verify theid_token
and authenticate user. So from user perspective no additional logins or anything else needs to be done against Panoramax service. Another nice thing about sending OpenConnect ID token is that even if Panoramax service is compromised, this token is only useful to confirm this user did action, it does not give Panoramax any authorization to do anything against osm.org API.With this PR, mobile app will be able to fetch fresh
id_token
at any time and send it to Panoramax service which can authenticate user as long as whole operation takes less than 2 minutes which should be plenty.Without this PR there would be 3 options IMO:
id_token
access_token
from Panoramax, which would complicate work for Mobile app and Panoramax, since both would need to maintain tokens between them. Biggest problem with this is unnecessary connections to Panoramax, just in case user decides to upload something in future, which might never happen.