I'm implementing OAuth2 authorization/resource server based on DotNetOpenAuth. My server is going to issue access tokens with very long life time. These tokens are going to be used from iOS devices. The flow, the way I see it, is like this, 1) a user is asked to enter their username/password on iOS device 2) an access token is requested with grant type of Resource Owner Password credentials 3) token is granted and stored on the iOS device for future use.
Now from time to time users get disabled. I would like to revoke the token at the same time. How do I do this? I suspect that I need to use ICryptoKeyStore.RemoveKey
method for that, but not sure how to find which key to remove.
Note 1: in future the server will be used by third party web applications.
Note 2: the requirement to have grant type of Resource Owner Password credentials stems from the fact that it was decided that implementing browser redirection on iOS device is not worth the time.
Update 1
Some excavations in the source code suggest that DotNetOpenAuth does not support this ability to force token expiration out of the box. Moreover in the standard implementation lifetime of the token is not even checked. As far as I can see the calss is responsible for this is StandardAccessTokenAnalyzer
and it ignores the Lifetime
and UtcCreationDate
properties. Also it does not seem that the standard ResourceServer
class has any database access coded, the token validity checked by the token content only, so it seems that if I need to add ability to expire the tokens I need to wire up the ResourseServer
to database myself. Am I missing something?
Update 2 I think I found the answer here: https://groups.google.com/forum/#!topic/dotnetopenid/aLabu1ujkt4 It's not what I was hoping for and I still have a few unclarities. For example, Andrew wrote:
Your custom class then could take an access token, then use a private HTTP request to the authorization server to verify the continued validity of the token.
It is unclear how this verification can happen, given that AccessToken
does not include Authorization Id. This can make finding the target Authorization record difficult. In theory we can try to look it up by combination of client, user and issue time, but as far as I can see there are no guarantee that these will be unique.