Skip to content

Commit 9a7c4c0

Browse files
authored
fix(auth): allow password managers to pre-fill input fields (#9390)
HTML disallows having multiple IDs with the same value. In reality this is for 1Password's feature where you can create custom fields named like input IDs and 1Password fill pre-fill that.
1 parent fc8e00c commit 9a7c4c0

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/core/components/auth/oauth2.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ export default class Oauth2 extends React.Component {
196196
{
197197
( flow === AUTH_FLOW_APPLICATION || flow === AUTH_FLOW_IMPLICIT || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_PASSWORD ) &&
198198
( !isAuthorized || isAuthorized && this.state.clientId) && <Row>
199-
<label htmlFor="client_id">client_id:</label>
199+
<label htmlFor={ `client_id_${flow}` }>client_id:</label>
200200
{
201201
isAuthorized ? <code> ****** </code>
202202
: <Col tablet={10} desktop={10}>
203-
<InitializedInput id="client_id"
203+
<InitializedInput id={`client_id_${flow}`}
204204
type="text"
205205
required={ flow === AUTH_FLOW_PASSWORD }
206206
initialValue={ this.state.clientId }
@@ -213,11 +213,11 @@ export default class Oauth2 extends React.Component {
213213

214214
{
215215
( (flow === AUTH_FLOW_APPLICATION || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_PASSWORD) && <Row>
216-
<label htmlFor="client_secret">client_secret:</label>
216+
<label htmlFor={ `client_secret_${flow}` }>client_secret:</label>
217217
{
218218
isAuthorized ? <code> ****** </code>
219219
: <Col tablet={10} desktop={10}>
220-
<InitializedInput id="client_secret"
220+
<InitializedInput id={ `client_secret_${flow}` }
221221
initialValue={ this.state.clientSecret }
222222
type="password"
223223
data-name="clientSecret"

test/e2e-cypress/e2e/features/auth-code-flow-pkce-without-secret.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Check client_secret for OAuth2 Authorization Code flow with and withou
1818
.contains("authorizationCode with PKCE")
1919
.get(".flow")
2020
.contains("authorizationCode with PKCE")
21-
.get("#client_secret")
21+
.get("#client_secret_authorizationCode")
2222
.should("exist")
2323
})
2424

@@ -41,7 +41,7 @@ describe("Check client_secret for OAuth2 Authorization Code flow with and withou
4141
.contains("authorizationCode")
4242
.get(".flow")
4343
.contains("authorizationCode")
44-
.get("#client_secret")
44+
.get("#client_secret_authorizationCode")
4545
.should("exist")
4646
})
4747
})

test/e2e-cypress/e2e/features/oauth2-flows/application.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ describe("OAuth2 Application flow", function() {
3030
.click()
3131

3232
.get("div.modal-ux-content > div:nth-child(2)").within(() => {
33-
cy.get("#client_id")
33+
cy.get("#client_id_application")
3434
.clear()
3535
.type("confidentialApplication")
3636

37-
.get("#client_secret")
37+
.get("#client_secret_application")
3838
.clear()
3939
.type("topSecret")
4040

test/e2e-cypress/e2e/features/oauth2-flows/password.cy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ describe("OAuth2 Password flow", function() {
1818
.get("#password_type")
1919
.select("basic")
2020

21-
.get("#client_id")
21+
.get("#client_id_password")
2222
.clear()
2323
.type("application")
2424

25-
.get("#client_secret")
25+
.get("#client_secret_password")
2626
.clear()
2727
.type("secret")
2828

@@ -75,11 +75,11 @@ describe("OAuth2 Password flow", function() {
7575
.get("#password_type")
7676
.select("request-body")
7777

78-
.get("#client_id")
78+
.get("#client_id_password")
7979
.clear()
8080
.type("application")
8181

82-
.get("#client_secret")
82+
.get("#client_secret_password")
8383
.clear()
8484
.type("secret")
8585

test/e2e-cypress/e2e/security/sequential-import-chaining.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("Security: CSS Sequential Import Chaining", () => {
2020
cy.visit("/?url=/documents/petstore-expanded.openapi.yaml")
2121
.get(".scheme-container > .schemes > .auth-wrapper > .btn > span")
2222
.click()
23-
.get("div > div > .wrapper > .block-tablet > #client_id")
23+
.get("div > div > .wrapper > .block-tablet > #client_id_implicit")
2424
.clear()
2525
.type("abc")
2626
.should("not.have.attr", "value", "abc")
@@ -48,7 +48,7 @@ describe("Security: CSS Sequential Import Chaining", () => {
4848
cy.visit("/?url=/documents/petstore.swagger.yaml")
4949
.get(".scheme-container > .schemes > .auth-wrapper > .btn > span")
5050
.click()
51-
.get("div > div > .wrapper > .block-tablet > #client_id")
51+
.get("div > div > .wrapper > .block-tablet > #client_id_implicit")
5252
.clear()
5353
.type("abc")
5454
.should("not.have.attr", "value", "abc")

0 commit comments

Comments
 (0)