- πΊπΈUnited States paul121 Spokane, WA
This issue still exists in v6. Attaching a patch with same solution as above. Also have a MR ready once the Drupal gitlab instance is back up.
- πΏπ¦South Africa rudolfbyker South Africa
I'm also running into this issue. Thanks for the patches.
I think two more things are needed here:
- Unit tests, so that this does not regress again.
- A way to clear the secret in the UI when editing the consumer. Currently, if you leave the field empty, it just means "don't update".
- Status changed to Needs work
about 1 year ago 8:02am 29 November 2023 - π³π±Netherlands kingdutch
Marking as needs work per #9
I would also want test coverage to ensure that in case the client secret is set to empty the client can not authenticate with a non-empty secret (something I think the current code allows if I look at it). In the case a client provides a secret but is configured not to use one, they're still using an incorrect secret and should be denied.
- πΊπΈUnited States paul121 Spokane, WA
In reviewing this issue again I believe there is another issue regarding
client_credentials
grant with public clients.A "confidential" consumer with a field value
consumer.confidential === TRUE
that is configured *without* a secret (or an empty secret string) is not validated and could be authenticated. This is a problem. The spec says "the client credentials grant type MUST only be used by confidential clients" - the spec does not care nor know about the concept of aconsumer.confidential
field, solely that if a client secret is not configured (or has an empty string, per the spec) thenclient_credentials
grant cannot be used.I've refactored the logic in this validate function to explicitly check for this case with a "public" client +
client_credentials
grant. I think this makes things simpler and easier to follow. I've added a kernel test to cover this case. Using the Gitlab CI "test only changes" you can see this test fails on current code: https://git.drupalcode.org/issue/simple_oauth-3322325/-/jobs/1539305#L110I would also want test coverage to ensure that in case the client secret is set to empty the client can not authenticate with a non-empty secret (something I think the current code allows if I look at it). In the case a client provides a secret but is configured not to use one, they're still using an incorrect secret and should be denied.
Good catch @kingdutch. These changes should cover this case as well. With my changes we only return TRUE in one place for a fully correct public client w/o any client secret provided. The final check does a password check only when the stored and provided client secret exist, else returns FALSE.
Unit tests, so that this does not regress again.
Agreed @rudolfbyker, this ClientRepository::validateClient logic would best be covered in a unit test. Unfortunately I don't have much experience writing unit tests and don't have time at the moment.
A way to clear the secret in the UI when editing the consumer. Currently, if you leave the field empty, it just means "don't update".
Agreed this is needed as well. I'm not sure the best approach to do this from the UI. Perhaps we could discuss and agree on an approach before starting work? Personally I'd like to see the UI changes happen in a separate issue. We've been dealing with this issue and patching in FarmOS for a while and would love to just get the validateClient logic in place.
- Status changed to Needs review
7 months ago 5:09am 8 May 2024 - πΊπΈUnited States paul121 Spokane, WA
Marking Needs Review since I have refactored some of the logic here, would love a review of this. Acknowledge that we could still use tests
- πΊπΈUnited States paul121 Spokane, WA
Including patch with latest changes for 6.0.0-beta6
- Status changed to Needs work
7 months ago 3:15pm 23 May 2024 - Merge request !156Update validateClient logic for public client credentials grant β (Open) created by paul121
- πΊπΈUnited States paul121 Spokane, WA
Sorry for the above noise. I made a new MR 156 and pushed a few times to get tests passing. This is a slightly different approach at the validation logic so that it checks both the
confidential
boolean and thesecret
value. Previously this only checked thesecret
value.