From 13b23fd5121fb0067b612497fe1335b3033b0753 Mon Sep 17 00:00:00 2001 From: Jo Date: Fri, 15 Jul 2022 07:10:20 +0000 Subject: [PATCH] Auth: Lockdown non-editables in frontend when external auth is configured (#52160) * Auth: Lockdown user profile edit if external synced * Auth: use builtin isExternal * Auth: When user is synced, orgs will be overriden on next login --- public/app/features/admin/UserOrgs.tsx | 3 ++- .../features/profile/UserProfileEditForm.tsx | 22 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/public/app/features/admin/UserOrgs.tsx b/public/app/features/admin/UserOrgs.tsx index b85247e1248..4472ea04f6e 100644 --- a/public/app/features/admin/UserOrgs.tsx +++ b/public/app/features/admin/UserOrgs.tsx @@ -60,7 +60,8 @@ export class UserOrgs extends PureComponent { const addToOrgContainerClass = css` margin-top: 0.8rem; `; - const canAddToOrg = contextSrv.hasPermission(AccessControlAction.OrgUsersAdd); + + const canAddToOrg = contextSrv.hasPermission(AccessControlAction.OrgUsersAdd) && !isExternalUser; return ( <>

Organizations

diff --git a/public/app/features/profile/UserProfileEditForm.tsx b/public/app/features/profile/UserProfileEditForm.tsx index c5748eb515f..c4a95cfdf3d 100644 --- a/public/app/features/profile/UserProfileEditForm.tsx +++ b/public/app/features/profile/UserProfileEditForm.tsx @@ -21,16 +21,22 @@ export const UserProfileEditForm: FC = ({ user, isSavingUser, updateProfi updateProfile(data); }; + // check if authLabels is longer than 0 otherwise false + const isExternalUser: boolean = (user && user.isExternal) ?? false; + const authSource = isExternalUser && user && user.authLabels ? user.authLabels[0] : ''; + const lockMessage = authSource ? ` (Synced via ${authSource})` : ''; + const disabledEdit = disableLoginForm || isExternalUser; + return (
{({ register, errors }) => { return (
Edit profile}> Name is required} - disabled={disableLoginForm} + disabled={disabledEdit} > = ({ user, isSavingUser, updateProfi Email is required} - disabled={disableLoginForm} + disabled={disabledEdit} > = ({ user, isSavingUser, updateProfi } /> @@ -72,7 +78,7 @@ export const UserProfileEditForm: FC = ({ user, isSavingUser, updateProfi