diff --git a/src/core/components/auth/oauth2.jsx b/src/core/components/auth/oauth2.jsx index 7fec252f..a83340b8 100644 --- a/src/core/components/auth/oauth2.jsx +++ b/src/core/components/auth/oauth2.jsx @@ -130,7 +130,11 @@ export default class Oauth2 extends React.Component { const AUTH_FLOW_ACCESS_CODE = isOAS3() ? (oidcUrl ? "authorization_code" : "authorizationCode") : "accessCode" const AUTH_FLOW_APPLICATION = isOAS3() ? (oidcUrl ? "client_credentials" : "clientCredentials") : "application" + let authConfigs = authSelectors.getConfigs() + let isPkceCodeGrant = authConfigs.usePkceWithAuthorizationCodeGrant === "true" || authConfigs.usePkceWithAuthorizationCodeGrant === true + let flow = schema.get("flow") + let flowToDisplay = flow === AUTH_FLOW_ACCESS_CODE && isPkceCodeGrant ? flow + " with PKCE" : flow let scopes = schema.get("allowedScopes") || schema.get("scopes") let authorizedAuth = authSelectors.authorized().get(name) let isAuthorized = !!authorizedAuth @@ -140,7 +144,7 @@ export default class Oauth2 extends React.Component { return (
OpenID Connect URL: { oidcUrl }
Authorization URL: { schema.get("authorizationUrl") }
Token URL: { schema.get("tokenUrl") }
Flow: { schema.get("flow") }
Flow: { flowToDisplay }
******
diff --git a/test/e2e-cypress/static/documents/features/auth-code-flow-pkce-without-secret.yaml b/test/e2e-cypress/static/documents/features/auth-code-flow-pkce-without-secret.yaml
new file mode 100644
index 00000000..dcc0b44c
--- /dev/null
+++ b/test/e2e-cypress/static/documents/features/auth-code-flow-pkce-without-secret.yaml
@@ -0,0 +1,25 @@
+openapi: 3.0.0
+
+info:
+ version: "1.0"
+ title: PKCE Flow
+
+paths:
+ /:
+ get:
+ summary: dummy operation
+ responses:
+ "200":
+ description: OK
+
+components:
+ securitySchemes:
+ testAuthCodeFlow:
+ type: oauth2
+ flows:
+ authorizationCode:
+ authorizationUrl: /oauth/authorize
+ tokenUrl: /oauth/token
+ scopes:
+ read: read whatever you want
+ write: write whatever you want
diff --git a/test/e2e-cypress/tests/features/auth-code-flow-pkce-without-secret.js b/test/e2e-cypress/tests/features/auth-code-flow-pkce-without-secret.js
new file mode 100644
index 00000000..7d14bb9c
--- /dev/null
+++ b/test/e2e-cypress/tests/features/auth-code-flow-pkce-without-secret.js
@@ -0,0 +1,47 @@
+describe("Check client_secret for OAuth2 Authorization Code flow with and without PKCE (#6290)", () => {
+ it("should not display client_secret field for authorization code flow with PKCE", () => {
+ cy.visit(
+ "/?url=/documents/features/auth-code-flow-pkce-without-secret.yaml"
+ )
+ .window()
+ .then(win => {
+ // set auth config to use PKCE
+ let authConfigs = win.ui.authSelectors.getConfigs()
+ win.ui.authActions.configureAuth({
+ ...authConfigs,
+ usePkceWithAuthorizationCodeGrant: true,
+ })
+ })
+ .get("button.authorize")
+ .click()
+ .get("h4")
+ .contains("authorizationCode with PKCE")
+ .get(".flow")
+ .contains("authorizationCode with PKCE")
+ .get("#client_secret")
+ .should("not.exist")
+ })
+
+ it("should display client_secret field for authorization code flow without PKCE", () => {
+ cy.visit(
+ "/?url=/documents/features/auth-code-flow-pkce-without-secret.yaml"
+ )
+ .window()
+ .then(win => {
+ // set auth config to not use PKCE
+ let authConfigs = win.ui.authSelectors.getConfigs()
+ win.ui.authActions.configureAuth({
+ ...authConfigs,
+ usePkceWithAuthorizationCodeGrant: false,
+ })
+ })
+ .get("button.authorize")
+ .click()
+ .get("h4")
+ .contains("authorizationCode")
+ .get(".flow")
+ .contains("authorizationCode")
+ .get("#client_secret")
+ .should("exist")
+ })
+})