Backport of UI: LDAP Hierarchical roles into release/1.18.x #28841
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #28824 to be assessed for backporting due to the inclusion of the label backport/1.18.x.
🚨
The person who merged in the original PR is:
@hellobontempo
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.
The below text is copied from the body of the original PR.
Description
This PR adds hierarchical role navigation to the UI for LDAP roles which was added to the CLI in 1.17 (Hierarchical Paths). These changes were nontrivial due to the API and GUI design, which I'll outline below for consideration during future list views and navigation with path style resources.
Screen.Recording.2024-11-04.at.12.10.31.PM.mov
Listing hierarchical roles in LDAP returns only top-level items. For example, this
ldap
engine has the dynamic role paths:admin/role1
,admin/nested/role2
,my-role
. A LIST request has to be made at each level to glean this. Roles are also dependent on:type
and so the same must be done for static roles withstatic-role
in the path instead ofrole
.Considerations
Existing list patterns
KV v2 has a similar pattern because secret paths can be nested (i.e.
nested/path/to/secret
). The route file defines separate routes,list
is for listing secrets in the engine andlist-directory
is for secret paths that end in a forward slash. The list route inherits from list-directory.js because much of the routing logic is the same. In LDAP, I chose to create a base route model class to share thelazyPaginatedQuery
method but maintain separate model hooks.The major difference here is in LDAP navigating through hierarchical roles does not update the filter input and
pageFilter
maps one to one to the filter input. I opted for this to separate concerns: url paths and navigation is unrelated to filtering the list results which is the responsibility of query params.On the top, navigating into the
admin/
subdirectory changes the URL and breadcrumbs, but the filter is not updated unless a user wants to filter within that directory. In KV v2, clicking into a subdirectory adds that path to the filter, even though the URL is not updated with the correspondingpageFilter
In both engines, filtering updates the query params, but in KV v2 only the suffix is included (which makes sense because we're inside that secret path, however it's confusing UX because the filter input does not match the URL query params)

Pagination
The original implementation of LDAP roles uses the same model
ldap/role
for both dynamic and static roles. Typically, we want model schemas to map closely to the API params (see Models docs for our expected ember data model patterns). Following this pattern,ldap/role
should have been a base class with any shared params (likename
) and for defining adapter/serializer methods as those are the same. Static and dynamic role models would inherit this class and then define type-specific fields and params (see #28829 for what this would look like).Abandoned because the list view displays both static and dynamic roles and our client-side pagination service relies on these being the same model.
SearchSelect
The API structure of LDAP roles makes components like

SearchSelect
unusable out of the box as it requires aLIST
request is made at each level. For the first iteration of the hierarchical roles implementation, we decided to filter out pathed roles, so only top-level roles are available for quickly generating credentials here:TODO only if you're a HashiCorp employee
to N, N-1, and N-2, using the
backport/ent/x.x.x+ent
labels. If this PR is in the CE repo, you should only backport to N, using thebackport/x.x.x
label, not the enterprise labels.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.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.
Overview of commits