diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index a3dd9f9ce61..1fd4cd347e7 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -139,6 +139,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro "appSubUrl": setting.AppSubUrl, "allowOrgCreate": (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin, "authProxyEnabled": setting.AuthProxyEnabled, + "ldapEnabled": setting.LdapEnabled, "buildInfo": map[string]interface{}{ "version": setting.BuildVersion, "commit": setting.BuildCommit, diff --git a/pkg/api/user.go b/pkg/api/user.go index c3e354f5095..a22ad028288 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -30,6 +30,14 @@ func getUserUserProfile(userId int64) Response { // POST /api/user func UpdateSignedInUser(c *middleware.Context, cmd m.UpdateUserCommand) Response { + if setting.AuthProxyEnabled { + if setting.AuthProxyHeaderProperty == "email" && cmd.Email != c.Email { + return ApiError(400, "Not allowed to change email when auth proxy is using email property", nil) + } + if setting.AuthProxyHeaderProperty == "username" && cmd.Login != c.Login { + return ApiError(400, "Not allowed to change username when auth proxy is using username property", nil) + } + } cmd.UserId = c.UserId return handleUpdateUser(cmd) } @@ -146,6 +154,10 @@ func ChangeActiveOrgAndRedirectToHome(c *middleware.Context) { } func ChangeUserPassword(c *middleware.Context, cmd m.ChangeUserPasswordCommand) Response { + if setting.LdapEnabled || setting.AuthProxyEnabled { + return ApiError(400, "Not allowed to change password when LDAP or Auth Proxy is enabled", nil) + } + userQuery := m.GetUserByIdQuery{Id: c.UserId} if err := bus.Dispatch(&userQuery); err != nil { diff --git a/public/app/features/org/change_password_ctrl.js b/public/app/features/org/change_password_ctrl.js index 69db0bfe06f..6e9826275ad 100644 --- a/public/app/features/org/change_password_ctrl.js +++ b/public/app/features/org/change_password_ctrl.js @@ -2,7 +2,7 @@ define([ 'angular', 'app/core/config', ], -function (angular) { +function (angular, config) { 'use strict'; var module = angular.module('grafana.controllers'); @@ -10,6 +10,8 @@ function (angular) { module.controller('ChangePasswordCtrl', function($scope, backendSrv, $location) { $scope.command = {}; + $scope.authProxyEnabled = config.authProxyEnabled; + $scope.ldapEnabled = config.ldapEnabled; $scope.changePassword = function() { if (!$scope.userForm.$valid) { return; } diff --git a/public/app/features/org/partials/change_password.html b/public/app/features/org/partials/change_password.html index 84af3c8c922..647817b4faa 100644 --- a/public/app/features/org/partials/change_password.html +++ b/public/app/features/org/partials/change_password.html @@ -6,7 +6,14 @@

Change password

-
+
+ You cannot change password when ldap or auth proxy authentication is enabled. +
+
+ Back to profile +
+ +
Old Password