Skip to content

Conversation

lisbet-alvarez
Copy link
Collaborator

@lisbet-alvarez lisbet-alvarez commented Jul 15, 2025

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17231

Description

Use account_id (retrieved from authenticated data) to query authenticated account in order to display correct username for any authentication method. As a result, OIDC authentications should show proper username.

Screenshots (if appropriate)

OIDC + Password Auth in Admin UI:

Screen.Recording.2025-09-24.at.4.25.39.PM.mov

OIDC + Password Auth in Desktop UI:

Screen.Recording.2025-09-24.at.4.23.31.PM.mov

How to Test

  1. Have OIDC auth method available
  2. Validate username is displayed correctly after login.
  3. Test in both admin and desktop UI

Checklist

  • I have added before and after screenshots for UI changes
  • I have added JSON response output for API changes
  • I have added steps to reproduce and test for bug fixes in the description
  • I have commented on my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've documented the impact of any changes to security controls.
    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

Copy link

vercel bot commented Jul 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
boundary-ui Ready Ready Preview Comment Oct 15, 2025 11:35pm
boundary-ui-desktop Ready Ready Preview Comment Oct 15, 2025 11:35pm

Copy link
Collaborator

@hashicc hashicc left a comment

Choose a reason for hiding this comment

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

I think the fact that this all lives on the a specific user model means that we don't need to copy over and modify to the data.authenticated hash, we can probably derive it more easily from a getter that does a peekRecord, and rely on the certain points in the application flow to refresh the model as needed

account.full_name;
this.session.set('data.authenticated.username', username);
} catch (e) {
// no op
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a specific error that could happen here that should be ignored? Catch-all error handlers can hide issues, I think generally it's better to let them bubble and have a global error handler that can log them and/or show a toast

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in particular. I was thinking that for whatever reason if there was an error retrieving the account, then it shouldn't cause ui to error out. But ya thats a good point (this will be refactored either way)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I chatted about this with @lisbet-alvarez but I actually think this is a scenario where it might make sense to explicitly squelch this. We don't really have logging on admin UI and I'm not sure how useful a toast is. If it's a 403 we shouldn't display anything but even if it's a 5xx, what would a user even do with the info?

await authenticateSession();
this.server.create('scope', { id: 'global' }, 'withGlobalAuth');
const account_id = this.server.schema.accounts.first().id;
await authenticateSession({ account_id });
Copy link
Collaborator Author

@lisbet-alvarez lisbet-alvarez Oct 8, 2025

Choose a reason for hiding this comment

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

Thoughts on refactoring our test cases to use this helper in order to provide an account_id to the authenticateSession? I only pushed up changes for tests/acceptance/accounts as a POC.

Edit: We discussed this during techtime and agreed to go with this approach.

Copy link
Collaborator

@cameronperera cameronperera left a comment

Choose a reason for hiding this comment

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

Nice work Lis!

Copy link
Collaborator

@ZedLi ZedLi left a comment

Choose a reason for hiding this comment

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

Looks good, I assume the test changes you've already made are now optional (which is fine) because having a username can fail?

as |dd|
>
{{#if this.session.data.authenticated.username}}
{{#if this.session.username}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Non blocking: was this if statement and having 2 dropdowns strictly necessary? Is it not possible to have the class and content be conditional based on this.session.username and use one dropdown?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great question! This second drop down is rendered with a ToggleIcon instead of a ToggleButton. We can't do the this.session.username check inside the dropdown since on a re-render the event listeners seem to not get properly re-attached causing the dropdown to not expand (unless page is fully refreshed).

@lisbet-alvarez
Copy link
Collaborator Author

Looks good, I assume the test changes you've already made are now optional (which is fine) because having a username can fail?

Yup that is correct, the only tests that would fail without the changes would be tests validating the dropdown has correct username.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants