-
Notifications
You must be signed in to change notification settings - Fork 9k
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
fix: add client_id and client_secret to form when type is request-body #4213
fix: add client_id and client_secret to form when type is request-body #4213
Conversation
src/core/plugins/auth/actions.js
Outdated
if ( passwordType === "query") { | ||
if ( clientId ) { | ||
query.client_id = clientId | ||
if ( clientId && clientSecret ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic could break some of the previous cases...
We had separate conditions for clientId & clientSecret, now it forces both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a valid use case to only supply one of those values, though?
I ask only because the branch of code that was previously defaulting to putting these in the Authorization
header didn't include similar checks.
So in the case where where type was request-body
, and only a client_id
value was supplied, it previously would have set the header to Basic " + btoa("the_client_id:undefined")
, which sounds like another lurking bug.
Happy to add back in the separate conditions, but I wanted to double check that supplying one or other value (id or secret, but not both) is something we're expecting people could be doing on purpose?
On hold pending @webron ☎️ |
Why on earth is this not merged yet? |
@ThomHurks Maybe you can offer some constructive details...
|
I was the one who reported the bug, and it's a pretty serious one too. Because of this bug nobody can use the Oauth2 password grant authentication flow. So, that's a pretty big feature not to have, right? This would make swagger-ui unusable for quite a big number of people. There's a patch made, nobody got back to Scott's questions and then the patch was put on hold for 2 months, that doesn't seem like a good way to deal with this problem. |
@ThomHurks |
Hey @ThomHurks we have not heard back from you ... One of the things you mentioned:
I do not know enough about Oauth2 to give a precise answer... |
Hi @scottohara @heldersepu @ThomHurks, We're just hitting this issue now after upgrading to SwaggerUI v3 (using Swashbuckle.AspNetCore v3). Irrespective of whether the Is there any chance that this PR can be taken over the goal line? |
@Ivan-L thanks for the report, this PR has been dormant for a while. We still waiting for @ThomHurks to add some unit tests... |
b3b37a3
to
152e1c9
Compare
To help progress this old PR, I've extracted the code for setting The logic has been modified so that either field (or both) can be supplied, and only the supplied values will be set in the target object ( Hopefully this is sufficient to get this over the line. |
Thanks @scottohara - I'll take this off of ice now 😄 |
I confirmed this PR on one of my own projects, and will be using it for the time being. I needed the The steps I took to confirm:
Then, in the interface, I tried authentication using the |
thanks @scottohara! |
In an OAuth2 password flow, when the type is
request-body
, theclient_id
andclient_secret
were being passed in anAuthorization
header and not in the request body.Description
Refactored the
authorizePassword
function to properly handle therequest-body
case.Motivation and Context
Fixes #4192
How Has This Been Tested?
Screenshots (if appropriate):
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests