Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP Identity OAuth token - Should I use ValidateClientAuthentication() and Secret in mobile app flow?

I have a mobile app which talks to an ASP WebAPI on the back-end.
I've implemented the token flow authentication (with the help of Taiseer's guide).

Still there is one concept I can't grasp my mind around: CleintId and ClientSecret.

From what I understand the client secret (along with client id) is meant to block access to the end point in my API that produces tokens. This way the end point is protected from malicious users trying to poke around the API and try to gain some information by invoking it with various inputs.

Meaning, only clients which hold the secret can start an authenticaon flow. And in my case, I have only one client which is a mobile app, and it's secret is stored in a secure place (KeyChain for iOs). But I've read that those key chains can be easily dumped and dissect for the secret.

So the conclusion I came up with, is that I can get rid of the whole client secret logic, mainly leaving ValidateClientAuthentication() blank:

public async override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
{

    context.Validated();
    return;
}

And to me it dose not seem like a security hole, but just a thin layer in the flow that is gone now. Because, again, the client secret can be easily revealed by any malicious user holding a mobile device with the app installed, and once he gets it this layer of security is useless.

Are those assumptions are incorrect ?

Can I leave the ValidateClientAuthentication() method blank ?

like image 755
Yaron Levi Avatar asked Oct 20 '22 14:10

Yaron Levi


1 Answers

As you already figured out, mobile applications cannot keep their credentials private because they can be extracted from the application binaries. Not to mention that requests can be easily intercepted using a proxy server and a traffic analyzer like Fiddler or Wireshark.

With the authorization code flow (1) or the resource owner password credentials grant, client authentication is not mandatory if the client cannot safely store its credentials and thus cannot be considered as a "confidential" application (see https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3 and https://www.rfc-editor.org/rfc/rfc6749#section-4.3.2).

For non-confidential applications, it's safe to call context.Validated().

Personally, I try to avoid the resource owner password credentials grant as much as possible as it clearly defeats the purpose of OAuth2: keeping your password confidential and giving constrained authorizations. If your app is fully trusted, it shouldn't be a problem, though.


  1. In practice, using the authorization code flow without enforcing client authentication is extremely rare, as it's simpler to use the implicit flow with mobile client applications, that offers a similar security level in this case (not to mention that it avoids a second roundtrip to the token endpoint).
like image 141
Kévin Chalet Avatar answered Oct 29 '22 21:10

Kévin Chalet