ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject ambari git commit: AMBARI-13997. Ambari force-writing usernames to be lowercase in DB. (mpapirkovskyy)
Date Sat, 21 Nov 2015 01:43:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1.2 bbc331af0 -> 8e731ab24


AMBARI-13997. Ambari force-writing usernames to be lowercase in DB. (mpapirkovskyy)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8e731ab2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8e731ab2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8e731ab2

Branch: refs/heads/branch-2.1.2
Commit: 8e731ab241c8254a0f4614bc0e8c8982e33716f1
Parents: bbc331a
Author: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Authored: Fri Nov 20 21:47:55 2015 +0200
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Fri Nov 20 15:50:31 2015 -0800

----------------------------------------------------------------------
 .../org/apache/ambari/server/api/services/UserService.java     | 1 +
 .../java/org/apache/ambari/server/controller/AmbariServer.java | 2 ++
 .../main/java/org/apache/ambari/server/orm/dao/UserDAO.java    | 6 +++---
 .../security/authorization/AmbariLocalUserDetailsService.java  | 4 +++-
 ambari-web/app/router.js                                       | 2 +-
 5 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8e731ab2/ambari-server/src/main/java/org/apache/ambari/server/api/services/UserService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/UserService.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/UserService.java
index 05ee6b1..76a6a08 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/UserService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/UserService.java
@@ -31,6 +31,7 @@ import javax.ws.rs.core.UriInfo;
 
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.commons.lang.StringUtils;
 
 import java.util.Collections;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e731ab2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index e7d8a3a..3f7fe50 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -81,6 +81,8 @@ import org.apache.ambari.server.orm.entities.MetainfoEntity;
 import org.apache.ambari.server.resources.ResourceManager;
 import org.apache.ambari.server.resources.api.rest.GetResource;
 import org.apache.ambari.server.scheduler.ExecutionScheduleManager;
+import org.apache.ambari.server.security.AmbariEntryPoint;
+import org.apache.ambari.server.security.AmbariServerSecurityHeaderFilter;
 import org.apache.ambari.server.security.CertificateManager;
 import org.apache.ambari.server.security.SecurityFilter;
 import org.apache.ambari.server.security.authorization.AmbariAuthorizationFilter;

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e731ab2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UserDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UserDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UserDAO.java
index 12f975e..7f9d146 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UserDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/UserDAO.java
@@ -131,21 +131,21 @@ public class UserDAO {
   @Transactional
   public void create(Set<UserEntity> users) {
     for (UserEntity user: users) {
-      user.setUserName(user.getUserName().toLowerCase());
+//      user.setUserName(user.getUserName().toLowerCase());
       entityManagerProvider.get().persist(user);
     }
   }
 
   @Transactional
   public UserEntity merge(UserEntity user) {
-    user.setUserName(user.getUserName().toLowerCase());
+//    user.setUserName(user.getUserName().toLowerCase());
     return entityManagerProvider.get().merge(user);
   }
 
   @Transactional
   public void merge(Set<UserEntity> users) {
     for (UserEntity user: users) {
-      user.setUserName(user.getUserName().toLowerCase());
+//      user.setUserName(user.getUserName().toLowerCase());
       entityManagerProvider.get().merge(user);
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e731ab2/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
index 2aae8a0..5607cc5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
@@ -27,6 +27,7 @@ import org.apache.ambari.server.orm.entities.MemberEntity;
 import org.apache.ambari.server.orm.entities.PrincipalEntity;
 import org.apache.ambari.server.orm.entities.PrivilegeEntity;
 import org.apache.ambari.server.orm.entities.UserEntity;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.security.core.userdetails.User;
@@ -73,7 +74,8 @@ public class AmbariLocalUserDetailsService implements UserDetailsService
{
 
     UserEntity user = userDAO.findLocalUserByName(username);
 
-    if (user == null) {
+    if (user == null || !StringUtils.equals(user.getUserName(), username)) {
+      //TODO case insensitive name comparison is a temporary solution, until users API will
change to use id as PK
       log.info("user not found ");
       throw new UsernameNotFoundException("Username " + username + " not found");
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e731ab2/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index 9c248f1..ed09653 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -236,7 +236,7 @@ App.Router = Em.Router.extend({
 
   login: function () {
     var controller = this.get('loginController');
-    var loginName = controller.get('loginName').toLowerCase();
+    var loginName = controller.get('loginName');
     controller.set('loginName', loginName);
     var hash = misc.utf8ToB64(loginName + ":" + controller.get('password'));
     var usr = '';


Mime
View raw message