From d2fa019d78e105f225e023bb12055e1761c56f77 Mon Sep 17 00:00:00 2001 From: Lokeswaran Aruljothi <74011196+lokeswaran-aj@users.noreply.github.com> Date: Wed, 15 Mar 2023 15:01:15 +0530 Subject: [PATCH] Auth: Show user sync external Authentication status (#62721) * Fix #56189 add auth source for users synced via external authentication * update change role display logic based on user authentication method * fix display for licensed ac --------- Co-authored-by: Lokeswaran Aruljothi <74011196+a-loke@users.noreply.github.com> --- public/app/features/admin/UserOrgs.tsx | 87 ++++++++++++++++---------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/public/app/features/admin/UserOrgs.tsx b/public/app/features/admin/UserOrgs.tsx index b83ef014960..3a97685c318 100644 --- a/public/app/features/admin/UserOrgs.tsx +++ b/public/app/features/admin/UserOrgs.tsx @@ -183,11 +183,13 @@ class UnThemedOrgRow extends PureComponent { render() { const { user, org, isExternalUser, theme } = this.props; + const authSource = user?.authLabels?.length && user?.authLabels[0]; + const lockMessage = authSource ? `Synced via ${authSource}` : ''; const { currentRole, isChangingRole } = this.state; const styles = getOrgRowStyles(theme); const labelClass = cx('width-16', styles.label); const canChangeRole = contextSrv.hasPermission(AccessControlAction.OrgUsersWrite); - const canRemoveFromOrg = contextSrv.hasPermission(AccessControlAction.OrgUsersRemove); + const canRemoveFromOrg = contextSrv.hasPermission(AccessControlAction.OrgUsersRemove) && !isExternalUser; const rolePickerDisabled = isExternalUser || !canChangeRole; const inputId = `${org.name}-input`; @@ -209,7 +211,7 @@ class UnThemedOrgRow extends PureComponent { basicRoleDisabled={rolePickerDisabled} /> - {isExternalUser && } + {isExternalUser && } ) : ( @@ -225,6 +227,7 @@ class UnThemedOrgRow extends PureComponent {
{canChangeRole && ( void; onCancelClick: () => void; @@ -417,9 +421,15 @@ const getChangeOrgButtonTheme = (theme: GrafanaTheme2) => ({ tooltipItemLink: css` color: ${theme.v1.palette.blue95}; `, + lockMessageClass: css` + font-style: italic; + margin-left: 1.8rem; + margin-right: 0.6rem; + `, }); export function ChangeOrgButton({ + lockMessage, onChangeRoleClick, isExternalUser, onOrgRoleSave, @@ -428,46 +438,54 @@ export function ChangeOrgButton({ const styles = useStyles2(getChangeOrgButtonTheme); return (
- - Change role - - {isExternalUser && ( - - This user's role is not editable because it is synchronized from your auth provider. Refer to - the  - - Grafana authentication docs - -  for details. -
- } + {isExternalUser ? ( + <> + {lockMessage} + + This user's role is not editable because it is synchronized from your auth provider. Refer to + the  + + Grafana authentication docs + +  for details. +
+ } + > + + + + ) : ( + - - + Change role + )} ); } +interface ExternalUserTooltipProps { + lockMessage?: string; +} -const ExternalUserTooltip = () => { +const ExternalUserTooltip = ({ lockMessage }: ExternalUserTooltipProps) => { const styles = useStyles2(getTooltipStyles); return (
+ {lockMessage} ({ tooltipItemLink: css` color: ${theme.v1.palette.blue95}; `, + lockMessageClass: css` + font-style: italic; + margin-left: 1.8rem; + margin-right: 0.6rem; + `, });