I'm working on an application in which the OAuth secret won't be able to be secured completely; there is a group of users to whom it will be exposed by necessity. So imagine a situation like the following:
A company is developing software that it hosts for the public that relies on OAuth2 to some 3rd party for authentication. But unavoidably the OAuth secret for this application will be exposed to all employes of the company. Presumably, some bad employee could use it for nefarious purposes or share it with someone else who would.
I was initially inclined to think that such an environment should use the implicit
OAuth2 workflow which isn't predicated on a secret key remaining a secret on the server. However, the more I read about it, the more inclined I am to believe that the authorization code
workflow might actually be a better fit here, because the secret key -- while not perfectly kept secret -- is at least only exposed to a subset of "trusted" actors.
Am I correct in believing that the authorization code
workflow would only increase security in an environment in which the key cannot be kept entirely secret? Are there any threats introduced by using the authorization code
over the implicit
workflow if the secret has been compromised? If anonymous/public users would not have access to the key, is there any reason other than convenience/simplicity to use the implicit
workflow over authorization code
?
Authorization code grant is more secure than implicit even in case the client secret can leak. Such scenario is the same as using authorization code grant with a public, instead of a confidential, client.
The only benefit of the implicit grant is simplicity and performance improvement (avoiding a back-channel call between client and authorization server).
Implicit grant has at least these weaknesses which are not present in the authorization grant:
In case the secret gets leaked in authorization grant, a potential attacker will be able to:
In any case you should make sure that the authorization server registers URL of your client and validates that the redirect_uri provided during authorization code flow is valid for the client. You have to use SSL/TLS for transfer of the authorization code to the client and exchange of the authorization code for the access token.
You can find more discussion on this subject in the OAuth 2.0 threat model document (https://www.rfc-editor.org/rfc/rfc6819)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With