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

Authorization Flow w/PKCE asks for Client Secret #6290

Closed
FizzBuzz791 opened this issue Aug 7, 2020 · 7 comments · Fixed by #7438
Closed

Authorization Flow w/PKCE asks for Client Secret #6290

FizzBuzz791 opened this issue Aug 7, 2020 · 7 comments · Fixed by #7438

Comments

@FizzBuzz791
Copy link

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Chrome
  • Version: 84
  • Method of installation: Swashbuckle
  • Swagger-UI version: 3.26
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0

Content & configuration

Any API with Authorization Flow and PKCE enabled.

I'm using DotNet Core and Swashbuckle, so it's a little hard to provide anything here.

Describe the bug you're encountering

The Authorize UI still prompts for the Client Secret even though it's not required for the PKCE flow.

To reproduce...

Steps to reproduce the behavior:

  1. Click on 'Authorize'
  2. See 'client_secret' field is shown (empty)
    a. Passing any value (valid or not) in that field and clicking 'Authorize' will cause an error.
    b. Leaving the field blank, will cause the auth flow to work correctly.

Expected behavior

When 'UsePKCE' flag is enabled, Client Secret field is not shown.

Screenshots

image

@FinHorsley
Copy link

+1 for this. It would be ideal if the client_secret input field was hidden in this case with Authorisation Code Flow + PKCE

@airen29
Copy link

airen29 commented Mar 15, 2021

+1 also. If you have Auth flow + PKCE you can basically put everything in the client_secret field now and it will be override so what is the purpose to have that field there anyway?

@fmartinez5
Copy link

+1 as well. Would be less confusing as client_secret is not needed and having it hidden or at least disabled would be optimal.

@ch-egli
Copy link
Contributor

ch-egli commented Jul 16, 2021

+1 as well.

@ch-egli
Copy link
Contributor

ch-egli commented Jul 20, 2021

May I address this issue with a small pull-request that omits the client_secret field from the OAuth2 dialog when the parameter usePkceWithAuthorizationCodeGrant is set to true? Or do you first need a further analysis of the issue?

ch-egli added a commit to ch-egli/swagger-ui that referenced this issue Jul 28, 2021
ilozano2 pushed a commit to ilozano2/swagger-ui that referenced this issue Sep 14, 2021
char0n pushed a commit that referenced this issue Jan 26, 2022
)

Co-authored-by: Ignacio Lozano <nacholozano@gmail.com>
Co-authored-by: Vladimir Gorej <vladimir.gorej@gmail.com>

Refs #6290
@artur-ciesielski-steelseries

Hi there,

I've just encountered this issue and I don't know what to think.

OAuth2 still recommends using both the client secret and PKCE in conjunction for confidential clients, as using a secret does not prevent the same class of vulnerabilities as PKCE.

A lot of top Google search results for OAuth2 and PKCE mention that those two are not replacements for each other:

https://oauth.net/2/pkce/
https://www.oauth.com/oauth2-servers/pkce/

Why have those been treated as mutually exclusive when they are not?

Phoosha added a commit to Phoosha/swagger-ui that referenced this issue Oct 31, 2022
PKCE and Client Secrets are allowed to coexist and neither is designed
as a replacement for the other. [1] It is wrong to assume that a client
secret must not or cannot be used in combination with PKCE. Quite the
opposite, when possible both PKCE and client secret should be used. [2]
So the premises of swagger-api#6290 and swagger-api#8146 are not correct.

Admittedly, for users of the PKCE mechanism WITHOUT a client secret it
might be a minor nuisance to see the client secret input in the Swagger
UI. But they can just leave it empty. On the other hand, for users of
the PKCE mechanism WITH a client secret it is more than just a nuisance
if the client secret input is not shown. The Swagger UI becomes unusable
for them (unless they've set a default value for the client secret,
which will be used hiddenly without being shown to the user).

Therefore the right course of action for now would be to revert swagger-api#7438 to
show the client secret input always regardless of PKCE. In the future a
new flag could be introduced to hide the client secret input regardless
of the PKCE flag.

[1] https://oauth.net/2/pkce/
[2] https://www.oauth.com/oauth2-servers/pkce/
Phoosha added a commit to Phoosha/swagger-ui that referenced this issue Nov 2, 2022
PKCE and Client Secrets are allowed to coexist and neither is designed
as a replacement for the other. [1] It is wrong to assume that a client
secret must not or cannot be used in combination with PKCE. Quite the
opposite, when possible both PKCE and client secret should be used. [2]
So the premises of swagger-api#6290 and swagger-api#8146 are not correct.

Admittedly, for users of the PKCE mechanism WITHOUT a client secret it
might be a minor nuisance to see the client secret input in the Swagger
UI. But they can just leave it empty. On the other hand, for users of
the PKCE mechanism WITH a client secret it is more than just a nuisance
if the client secret input is not shown. The Swagger UI becomes unusable
for them (unless they've set a default value for the client secret,
which will be used hiddenly without being shown to the user).

Therefore the right course of action for now would be to revert swagger-api#7438 to
show the client secret input always regardless of PKCE. In the future a
new flag could be introduced to hide the client secret input regardless
of the PKCE flag.

[1] https://oauth.net/2/pkce/
[2] https://www.oauth.com/oauth2-servers/pkce/
tim-lai pushed a commit that referenced this issue Nov 4, 2022
* fix: show client secret input for PKCE auth code flow

PKCE and Client Secrets are allowed to coexist and neither is designed
as a replacement for the other. [1] It is wrong to assume that a client
secret must not or cannot be used in combination with PKCE. Quite the
opposite, when possible both PKCE and client secret should be used. [2]
So the premises of #6290 and #8146 are not correct.

Admittedly, for users of the PKCE mechanism WITHOUT a client secret it
might be a minor nuisance to see the client secret input in the Swagger
UI. But they can just leave it empty. On the other hand, for users of
the PKCE mechanism WITH a client secret it is more than just a nuisance
if the client secret input is not shown. The Swagger UI becomes unusable
for them (unless they've set a default value for the client secret,
which will be used hiddenly without being shown to the user).

Therefore the right course of action for now would be to revert #7438 to
show the client secret input always regardless of PKCE. In the future a
new flag could be introduced to hide the client secret input regardless
of the PKCE flag.

[1] https://oauth.net/2/pkce/
[2] https://www.oauth.com/oauth2-servers/pkce/

* docs: explain why client secret input is shown despite PKCE
@OFark
Copy link

OFark commented Apr 5, 2023

I am shocked by this, Confidential clients use both PKCE and ClientSecret, PKCE is not a replacement for a client_secret, a white list of redirect URLs is. I still need an input for Client Secret, Swagger is useless to me without it. Have the option to toggle it, sure, and have it change behaviour when it's empty sure. But to reduce the security of an API because 6 people find having the box shown mildly irritating seems ridiculous.

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