Repository: hashicorp/vault
File: ui/app/models/auth-method.js (JavaScript)

Code before:
      type: 'containsWhiteSpace',
      message: WHITESPACE_WARNING('path'),
      level: 'warn',
    },
  ],
};

@withModelValidations(validations)
export default class AuthMethodModel extends Model {
  @service store;

  @belongsTo('mount-config', { async: false, inverse: null }) config; // one-to-none that replaces former fragment
  @hasMany('auth-config', { polymorphic: true, inverse: 'backend', async: false }) authConfigs;
  @attr('string') path;
  @attr('string') accessor;
  @attr('string') name;
  @attr('string') type;
  // namespaces introduced types with a `ns_` prefix for built-in engines
  // so we need to strip that to normalize the type
  get methodType() {
    return this.type.replace(/^ns_/, '');
  }
  get icon() {
    const authMethods = ALL_ENGINES.find((backend) => backend.type === this.methodType);

    return authMethods?.glyph || 'users';
  }
  @attr('string', {
    editType: 'textarea',
  })
  description;
  @attr('boolean', {
    helpText:
      'When Replication is enabled, a local mount will not be replicated across clusters. This can only be specified at mount time.',
  })
  local;
  @attr('boolean', {
    helpText:
      'When enabled - if a seal supporting seal wrapping is specified in the configuration, all critical security parameters (CSPs) in this backend will be seal wrapped. (For KV mounts, all values will be seal wrapped.) This can only be specified at mount time.',
  })
  sealWrap;

  // used when the `auth` prefix is important,
  // currently only when setting perf mount filtering
  get apiPath() {
    return `auth/${this.path}`;
  }
  get localDisplay() {
    return this.local ? 'local' : 'replicated';
  }


Review comment (security):
Previously, we were iterating over auth engines, and now we're iterating over both auth and secret. I realize `get icon()` realistically won't pass in a secret engine, but we should either call that out, or to keep behavior consistent and only iterate over auth methods here as well.


```suggestion
get icon() {
 // methodType refers to the backend type (e.g., "aws", "azure") and is set on a getter.
 // mountType indicates whether the engine is for "auth" or "secret".
  const authMethods = ALL_ENGINES.find((backend) => {
    return (
      backend.type === this.methodType &&
      backend.mountType?.includes('auth')
    );
  });

  return authMethods?.glyph || 'users';
}
    const allMethods = ALL_ENGINES.find((backend) => backend.type === this.methodType);
```

Code after:
      type: 'containsWhiteSpace',
      message: WHITESPACE_WARNING('path'),
      level: 'warn',
    },
  ],
};

@withModelValidations(validations)
export default class AuthMethodModel extends Model {
  @service store;

  @belongsTo('mount-config', { async: false, inverse: null }) config; // one-to-none that replaces former fragment
  @hasMany('auth-config', { polymorphic: true, inverse: 'backend', async: false }) authConfigs;
  @attr('string') path;
  @attr('string') accessor;
  @attr('string') name;
  @attr('string') type;
  // namespaces introduced types with a `ns_` prefix for built-in engines
  // so we need to strip that to normalize the type
  get methodType() {
    return this.type.replace(/^ns_/, '');
  }
  get icon() {
    // methodType refers to the backend type (e.g., "aws", "azure") and is set on a getter.
    const authMethods = engineDisplayData(this.methodType);
    return authMethods?.glyph || 'users';
  }
  @attr('string', {
    editType: 'textarea',
  })
  description;
  @attr('boolean', {
    helpText:
      'When Replication is enabled, a local mount will not be replicated across clusters. This can only be specified at mount time.',
  })
  local;
  @attr('boolean', {
    helpText:
      'When enabled - if a seal supporting seal wrapping is specified in the configuration, all critical security parameters (CSPs) in this backend will be seal wrapped. (For KV mounts, all values will be seal wrapped.) This can only be specified at mount time.',
  })
  sealWrap;

  // used when the `auth` prefix is important,
  // currently only when setting perf mount filtering
  get apiPath() {
    return `auth/${this.path}`;
  }
  get localDisplay() {
    return this.local ? 'local' : 'replicated';
  }