Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: LDAP hierarchal roles #28763

Closed
wants to merge 10 commits into from
Closed

UI: LDAP hierarchal roles #28763

wants to merge 10 commits into from

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Oct 24, 2024

Description

Hierarchical paths for roles in the LDAP secrets engine were added in 1.17 #27203. This PR updates the UI to handle listing roles at the hierarchical level. Originally we were just going to disable roles ending in a forward slash and role out the listing feature later. However, we were able to carve out some time during hackweek to get this done. We followed a similar pattern to the kv v2 secrets engine for UX.

TODO only if you're a HashiCorp employee

  • Backport Labels: If this PR is in the ENT repo and needs to be backported, backport
    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 the backport/x.x.x label, not the enterprise labels.
    • 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.

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Oct 24, 2024
Copy link

github-actions bot commented Oct 24, 2024

CI Results: failed ❌

@@ -73,12 +74,6 @@ export interface TtlEvent {
goSafeTimeString: string;
}

export interface Breadcrumb {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

duplicate


// LIST request for children of a hierarchal role
async _querySubdirectory(backend, roleAncestry) {
// path_to_role is the ancestral path
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe an example in the comment of what an ancestral path could look like? or a link to the documentation. https://developer.hashicorp.com/vault/docs/secrets/ldap#hierarchical-paths

@@ -33,8 +33,18 @@ export default class LdapRoleAdapter extends NamedPathAdapter {
}

async query(store, type, query, recordArray, options) {
const { showPartialError } = options.adapterOptions || {};
const { showPartialError, roleAncestry } = options.adapterOptions || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the name, but it's unclear if roleAncestry is a boolean, string, or an object. Without making this file typescript, maybe adding a default value would clarify.

@@ -33,8 +33,18 @@ export default class LdapRoleAdapter extends NamedPathAdapter {
}

async query(store, type, query, recordArray, options) {
const { showPartialError } = options.adapterOptions || {};
const { showPartialError, roleAncestry } = options.adapterOptions || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { showPartialError, roleAncestry } = options.adapterOptions || {};
const { showPartialError, roleAncestry={} } = options.adapterOptions || {};

linkParams = (role: LdapRoleModel) => {
const route = role.name.endsWith('/') ? 'roles.subdirectory' : 'roles.role.details';
// remove trailing forward slash from URL
const sanitizedName = sanitizePath(role.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

SanitizePath does a little more than we're needing it to here. In addition to removing a trailing forward slash it will remove a leading forward slash and whitespace. One idea, might be to create another function in the addon/utils directory to remove only the trailing forward slash so we don't have any unexpected behavior. Similar to how we've narrowed down a function to just remove the leading slash called sanitizeStart.

@@ -9,6 +9,7 @@ export default buildRoutes(function () {
this.route('overview');
this.route('roles', function () {
this.route('create');
this.route('subdirectory', { path: '/:type/subdirectory/*path_to_role' });
Copy link
Contributor

Choose a reason for hiding this comment

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

Great naming and route structure.

Maybe add the comment here similar to the one included in KV routes noting why we're using wildcard vs dynamic.

docs for easy reference

},
{ adapterOptions: { showPartialError: true } }
),
roles: this.lazyQuery({ showPartialError: true }, backendModel.id, params),
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this, creative and clean.

@hellobontempo hellobontempo added this to the 1.18.1 milestone Oct 28, 2024
@ldilalla-HC ldilalla-HC modified the milestones: 1.18.1, 1.18.2 Oct 29, 2024
@hellobontempo
Copy link
Contributor Author

closing in favor of #28824

@hellobontempo hellobontempo deleted the ui/spike-hierarchal-roles branch November 4, 2024 21:48
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants