Skip to content
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

Missing required parameter client_id returning invalid_client #44

Closed
StefRoo opened this issue Apr 29, 2022 · 7 comments
Closed

Missing required parameter client_id returning invalid_client #44

StefRoo opened this issue Apr 29, 2022 · 7 comments

Comments

@StefRoo
Copy link

StefRoo commented Apr 29, 2022

Which version of Duende IdentityServer are you using?
v4.

Which version of .NET are you using?
.NET 6

Describe the bug
A third party pointed out to us that upon sending us a request on our token endpoint in the flow described in the OAuth2.0 specifications in chapter 4.1, the Authorization Code Grant, without a client_id configured, we return an error-response with the error-code set to 'invalid_client'. We have seen in the codebase of IdentityServer that this is default behaviour, as can be seen in the ClientSecretValidator:

if (parsedSecret == null)
        {
            await RaiseFailureEventAsync("unknown", "No client id found");

            _logger.LogError("No client identifier found");
            return fail;
        }

And in the TokenEndpoint:

if (clientResult.Client == null)
       {
           return Error(OidcConstants.TokenErrors.InvalidClient);
       }

To Reproduce
Send a request to the TokenEndpoint with no client_id configured.

Expected behavior
In our use case, section 4.1 of the OAuth2.0 specification, the client_id is a required parameter. As RFC 6749 section 5.2 states, if a required parameter is missing in a request, an error-response with the error-code set to 'invalid_request' should be returned. We would therefore expect the default TokenEndpoint implementation to return an 'invalid_request' instead of an 'invalid_client' when the entire parameter is missing, and an 'invalid_client' when the content of the parameter is missing or empty.

We would like to hear your thoughts on this issue.

@brockallen
Copy link
Member

We'll have a look, thanks.

@user1336
Copy link

@brockallen if you agree to this issue we can create a PR.

@brockallen
Copy link
Member

brockallen commented Jun 24, 2022

@leastprivilege to review. the issue here is that our abstraction over validating client credentials doesn't indicate this specific missing param as a special case.

@brockallen
Copy link
Member

@StefRoo, i understand the desire to be as spec compliant as possible, but is there a real/practical reason that the error code being invalid_request vs. invalid_client really matters? I'm thinking that in either case, a client would know there's an error and need to consult the logs to determine the real issue. I can't see how the distinction matters in a real runtime environment (but that's why I'm asking).

@brockallen brockallen closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2022
@user1336
Copy link

@brockallen @StefRoo , It might be very semantic but the client could interpret invalid_request as that they should probably alter a parameter in the request. On the other hand they could interpret invalid_client as authentication fails so that they will investigate the authentication process.
Either way, the client would still be denied authorization.

The reason why we insist for this change is that the third party audits our product for compliancy to the OAuth specification and at this point we have a non-conformity. To mitigate this non-conformity we had to override the whole Token endpoint, so extensibility was quite unpractical. Even if we don't want to make a change to the validation of the client credentials perhaps we could provide for better extensibility.

@brockallen
Copy link
Member

Ok, I looked again and there is a fairly small change to accommodate that specific error condition. PR is submitted.

@user1336
Copy link

@brockallen Amazing, looks good! Thanks :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants