Skip to content

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented May 20, 2025

Description

Users can simplify the web UI login experience and remove unwanted login methods by choosing a default auth method (and optional backup methods). These settings can be inherited by child namespaces.

Frontend compliment to https://github.com/hashicorp/vault-enterprise/pull/8097. Closes 9076.

To encourage best practices, creating custom login rules not supported as a form in the web ui and must happen via the API or CLI.


listing_visibility

The resulting login views vary slightly depending on whether or not the selected default (or backup) auth method has any mounts tuned with listing_visibility="unauth". If mount data is returned by the unauthenticated request to sys/internal/ui/mounts, then the web UI uses that path to log in and hides the path <input>.
If no data is returned, the web UI assumes the default login path (which is the same as the method name, i.e. ldap), but the custom input is available.


⚙️ Configuration options:

The login form either renders a dropdown or tabs depending on specific configuration combinations.
In some scenarios, the component supports toggling between a default view and an alternate view. Users can use a direct link to override any login settings or default behavior.

📋 Dropdown (default view)
▸ All supported auth methods show in a dropdown.
▸ No alternate view.

🗂️ Visible mount tabs (visible (unauth) mount tabs)
▸ Groups visible mounts (listing_visibility="unauth") by type and displays as tabs.
▸ Alternate view: full dropdown of all methods.

🔗 Direct link (via ?with= query param)
▸ If the param references a visible mount, that method renders by default and the mount path is assumed.
↳ Alternate view: full dropdown.
▸ If the param references a method type (legacy behavior), the method is preselected in the dropdown or its tab is selected.
↳ Alternate view: if other methods have visible mounts, the form can toggle between tabs and dropdown. The initial view depends on whether the chosen type is a tab.

🏢 Enterprise-only login settings
▸ A namespace can define a default method and/or preferred methods (i.e. "backups") and enable child namespaces to inherit these preferences.
✎ Both set:
▸ Default method shown initially.
▸ Alternate view: preferred methods in tab layout.
✎ Only one set:
▸ No alternate view.

🛠️ Advanced settings toggle reveals the custom path input:
🚫 No visible mounts:
▸ UI defaults to method type as path.
▸ "Advanced settings" shows a path input.
1️⃣ One visible mount:
▸ Path is assumed and hidden.
🔀 Multiple visible mounts:
▸ Path dropdown is shown.

📸 Screenshots

Default + Backup methods set with mount data

  • Advanced settings toggle is hidden because method has mount data available
  • Clicking "Sign in to view other methods" toggles to view backup methods
    Advanced settings hides/shows for each tab depending on mount visibility
Screenshot 1 Screenshot 2

Default + Backup methods set with no mount data

  • UI assumes default login path for method and Advanced settings renders
Screenshot 3

Default only

  • Default method is set without backups so it is the only option. "Sign in with other methods" does not render
Screenshot 4

Direct links

  • ?with= query param refers to an auth method type it is preselected in the dropdown (backward compatibility)
Screenshot 2025-05-20 at 5 44 42 PM - `?with=` query param refers to a visible mount path Screenshot 2025-05-20 at 5 40 46 PM

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@hellobontempo hellobontempo added this to the 1.20.0-rc milestone May 20, 2025
@hellobontempo hellobontempo requested a review from a team as a code owner May 20, 2025 23:17
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label May 20, 2025
@hellobontempo hellobontempo requested a review from a team as a code owner May 20, 2025 23:18
@hellobontempo hellobontempo requested a review from erikapierr May 20, 2025 23:18
Copy link

github-actions bot commented May 20, 2025

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented May 20, 2025

Build Results:
All builds succeeded! ✅

@hellobontempo hellobontempo removed the request for review from erikapierr May 20, 2025 23:48
@@ -3,105 +3,103 @@
SPDX-License-Identifier: BUSL-1.1
}}

<div {{did-insert this.initializeState}}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved initialization to the parent, so no more need for did-insert 🎉 . I recommend reviewing with ✅ Hide whitespace

}

private constructViews(view: FormView, tabData: UnauthMountsByType | null) {
return { view, tabData };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view is actually never used anywhere and only included it to make the form view logic easier to navigate. Without it, the dropdown view has to be deduced whether or not tabData exists. So for state that has an alternate view, but no tabs it would be alternateView = { tabData: null }. It felt strange to rely on an object of that shape for a truthy value. Alternatively, I could add a key like hasAlternateView but at that point it just seemed like I might as well say what said alternate view is to ease navigating these chaotic logic combinations 😅

*/
getMountOrTypeData(authMount, visibleAuthMounts) {
if (visibleAuthMounts?.[authMount]) {
return { path: authMount, ...visibleAuthMounts[authMount], isVisibleMount: true };
const sanitizedParam = sanitizePath(authMount); // strip leading/trailing slashes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test here for this update

@@ -180,37 +155,14 @@ module('Integration | Component | auth | form template', function (hooks) {
assert.dom(AUTH_FORM.advancedSettings).doesNotExist();
});

test('it renders the mount description', async function (assert) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved these tests to auth/tabs-test component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless otherwise noted, tests deleted here migrated to auth/page-test.js

@hellobontempo
Copy link
Contributor Author

Screenshot 2025-05-20 at 6 46 56 PM

@hellobontempo hellobontempo requested a review from meirish May 21, 2025 17:42
@hellobontempo
Copy link
Contributor Author

Enterprise tests ✅

lane-wetmore
lane-wetmore previously approved these changes May 22, 2025
Monkeychip
Monkeychip previously approved these changes May 22, 2025
@hellobontempo hellobontempo dismissed stale reviews from Monkeychip and lane-wetmore via b028ffa May 22, 2025 19:43
@@ -15,35 +15,52 @@

{{#if @loginRules}}
{{#each @loginRules as |rule|}}
<div class="list-item-row linked-block-item is-no-underline">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes the list item clickable

@hellobontempo
Copy link
Contributor Author

Screenshot 2025-05-22 at 3 12 38 PM

@hellobontempo hellobontempo merged commit 45fee5c into main May 22, 2025
33 checks passed
@hellobontempo hellobontempo deleted the VAULT-35204/login-customization-feature-2 branch May 22, 2025 22:13
miagilepner pushed a commit that referenced this pull request May 23, 2025
* add request for custom login settings to auth route

* add tests to page integration before updating logic

* make tab component tests

* move form state logic to parent page component

* test updates for sanitizing query param in auth route

* add custom login feature

* add test for fetching login settings on ent only

* add changelog

* reword changelog

* rename variable from showOtherMethods to showAlternateView

* cleanup store

* cleanup comments per PR feedback

* abc

* VAULT-34672 render line breaks in description

* update endpoints after testing with live api

* add test coverage

* word

* remove backup types from test-ns for testing

* change to manually log in

* add error handling for no login settings

* add inheritance badge and make list item linkable
erentantekin pushed a commit that referenced this pull request May 23, 2025
* add request for custom login settings to auth route

* add tests to page integration before updating logic

* make tab component tests

* move form state logic to parent page component

* test updates for sanitizing query param in auth route

* add custom login feature

* add test for fetching login settings on ent only

* add changelog

* reword changelog

* rename variable from showOtherMethods to showAlternateView

* cleanup store

* cleanup comments per PR feedback

* abc

* VAULT-34672 render line breaks in description

* update endpoints after testing with live api

* add test coverage

* word

* remove backup types from test-ns for testing

* change to manually log in

* add error handling for no login settings

* add inheritance badge and make list item linkable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vault UI Feature Request: Don't Show all login methods in Vault UI Login Page
4 participants