8000 Display the roles of the logged-in user in the Web Debug Toolbar by NicoHaase · Pull Request #42800 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Display the roles of the logged-in user in the Web Debug Toolbar #42800

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

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

NicoHaase
Copy link
Contributor
Q A
Branch? 5.4 for features
Bug fix? no
New feature? yes
Deprecations? yes/no
Tickets Fix #42763
License MIT
Doc PR -

This PR adds the roles of the logged-in user to the WDT

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@@ -41,6 +41,11 @@
<span class="sf-toolbar-status sf-toolbar-status-{{ is_authenticated ? 'green' : 'yellow' }}">{{ is_authenticated ? 'Yes' : 'No' }}</span>
</div>

<div class="sf-toolbar-info-piece">
<b>Roles</b>
<span>{{ collector.roles|join(', ') }}</span>
Copy link
Member

Choose a reason for hiding this comment

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

Should we limit the output here? I'm afraid we break the toolbar for apps with many roles. 🙈

Copy link
Contributor

Choose a reason for hiding this comment

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

was checking 😬 i have 200+ roles :}

Copy link
Member

Choose a reason for hiding this comment

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

😱

Copy link
Contributor

Choose a reason for hiding this comment

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

yes. It's a symptom of permissions-as-roles. In that sense ive no idea what a reasonable no. of roles is, nor about an average role name length. I do agree the current toolbar has limited UI to display many data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point - limiting would be a good idea. Do you have any preference about this. I would see the following options:

  • showing the first m roles, and something like "and n more"
  • having something like a modal that could be opened if there are more than m roles

Copy link
Contributor

Choose a reason for hiding this comment

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

this should not only contain the number of assigned roles

hence i suggested to use a title attribute and avoid this discussion :)

Copy link
Member

Choose a reason for hiding this comment

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

I like @ro0NL's suggestion of using the title attribute:

image

I think 1 role is a good threshold value 😄 . In this example screenshot, the user only has 4 roles and it already wouldn't fit the normal modal.
Also, I always recommend people to limit the number of roles a user has as close to 1 as possible. Maybe complex applications need 3+ roles, but generally you should be able to manage 1 or 2 roles if you split roles from permissions.

Copy link
Contributor
@ro0NL ro0NL Sep 5, 2021

Choose a reason for hiding this comment

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

i agree the dashed underline is likely enough to trigger a user hover, and go from there.

i'd opt out from a random number to display roles for

we could spare out "Logged in as" in favor of the "user icon" as in the toolbar itself, if it's not redundant already :}

we could spare out "Authenticated: yes" in favor of the negative edge case (eg. "Not authenticated" as a single badge)

"Action" looks redundant :) could be some "logout icon" too

last but not least, IIUC the title attribute is limited to 512 chars. Perhaps we should invent some CSS only tooltip util.

Copy link
Member

Choose a reason for hiding this comment

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

Please keep this discussion focussed and discuss cleaning up other things in another issue/pr :)

I'm 100% in favor of keeping this as simple as possible. Let's not increase difficulty with CSS/js tooltips. The longest role I've seen is Symfony's own ROLE_PREVIOUS_ADMIN, which is 19 characters long (meaning a user can have 24 roles before the title attribute overflows).

Copy link
Contributor
@ro0NL ro0NL Sep 5, 2021

Choose a reason for hiding this comment

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

I never implied "JS". We have a hard limit on title attributes.

edit: the 512 limit is IE only it seems. Max-width is default on title attributes ... let's do that 👍

@NicoHaase
Copy link
Contributor Author

So, I'm having a new shot after all that feedback - thank you guys for commenting!

Bildschirmfoto von 2021-09-06 07-59-54

@NicoHaase NicoHaase force-pushed the feature/list-roles-in-toolbar-42763 branch from ec98d71 to 1460732 Compare September 6, 2021 06:03
@derrabus
Copy link
Member
derrabus commented Sep 6, 2021

@ro0NL Can you test this PR with your 200+ roles app? 🙃

Copy link
Member
@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

Looks great :)

@fabpot
Copy link
Member
fabpot commented Sep 6, 2021

Thank you @NicoHaase.

@fabpot fabpot merged commit 47385e5 into symfony:5.4 Sep 6, 2021
@NicoHaase NicoHaase deleted the feature/list-roles-in-toolbar-42763 branch September 6, 2021 09:12
derrabus added a commit that referenced this pull request Sep 13, 2021
… Toolbar -- bugfix for two roles (NicoHaase)

This PR was merged into the 5.4 branch.

Discussion
----------

Display the roles of the logged-in user in the Web Debug Toolbar -- bugfix for two roles

| Q             | A
| ------------- | ---
| Branch?       | 5.4 for features
| Bug fix?      | yes
| New feature?  | yes
| Deprecations? | no
| Tickets       | Additional fix for #42763
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

The first commit from #42800 did not work properly if there are exactly two roles assigned to the logged in user (as then, the first would be shown, but not the "and n more" span). This PR fixes this issue

Commits
-------

895df9f Display the roles of the logged-in user in the Web Debug Toolbar -- bugfix
This was referenced Nov 5, 2021
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.

Show user roles in web developer toolbar security widget
7 participants
0