PR: Set autocomplete="off" for new auth fields (#30444)

* set autocomplete to off

* add comment

* update test
This commit is contained in:
claire bontempo 2025-04-29 12:36:48 -07:00 committed by GitHub
parent 138e805cb0
commit ba3f7363ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 17 deletions

View File

@ -6,7 +6,8 @@
{{#each @loginFields as |field|}}
{{#let field.name field.label field.helperText as |name label helperText|}}
<Hds::Form::TextInput::Field
autocomplete={{this.setAutocomplete name}}
{{! For security, we do not support autocomplete at this time }}
autocomplete="off"
@type={{this.setInputType name}}
name={{name}}
class="has-bottom-margin-m"

View File

@ -3,8 +3,6 @@
* SPDX-License-Identifier: BUSL-1.1
*/
// TODO pending feedback from the security team, we may keep autocomplete="off" for login fields
import Component from '@glimmer/component';
interface Args {
@ -20,15 +18,4 @@ interface Field {
export default class AuthFields extends Component<Args> {
// token or password should render as "password" types, otherwise render text inputs
setInputType = (field: string) => (['token', 'password'].includes(field) ? 'password' : 'text');
setAutocomplete = (fieldName: string) => {
switch (fieldName) {
case 'password':
return 'current-password';
case 'token':
return 'off';
default:
return fieldName;
}
};
}

View File

@ -72,10 +72,10 @@ module('Integration | Component | auth | fields', function (hooks) {
test('it renders expected autocomplete values', async function (assert) {
await this.renderComponent();
const expectedValues = {
username: 'username',
role: 'role',
username: 'off',
role: 'off',
token: 'off',
password: 'current-password',
password: 'off',
};
for (const field of this.loginFields) {