You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ambari.apache.org by "Hudson (JIRA)" <ji...@apache.org> on 2016/06/10 08:25:21 UTC
[jira] [Commented] (AMBARI-17158) Wrong username being returned in
from ViewContextImpl.getUsername() and ViewContextImpl.getLoggedinUser()
[ https://issues.apache.org/jira/browse/AMBARI-17158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15324065#comment-15324065 ]
Hudson commented on AMBARI-17158:
---------------------------------
FAILURE: Integrated in Ambari-trunk-Commit #5049 (See [https://builds.apache.org/job/Ambari-trunk-Commit/5049/])
AMBARI-17158. Wrong username being returned in from (mpapyrkovskyy: [http://git-wip-us.apache.org/repos/asf?p=ambari.git&a=commit&h=d169d8c5cbf3bfbd1ce9a9ab068548a3097974cb])
* ambari-server/src/test/java/org/apache/ambari/server/security/SecurityHelperImplTest.java
* ambari-server/src/main/java/org/apache/ambari/server/security/SecurityHelperImpl.java
> Wrong username being returned in from ViewContextImpl.getUsername() and ViewContextImpl.getLoggedinUser()
> ---------------------------------------------------------------------------------------------------------
>
> Key: AMBARI-17158
> URL: https://issues.apache.org/jira/browse/AMBARI-17158
> Project: Ambari
> Issue Type: Bug
> Components: ambari-server
> Affects Versions: 2.4.0
> Reporter: Myroslav Papirkovskyi
> Assignee: Myroslav Papirkovskyi
> Priority: Blocker
> Fix For: 2.4.0
>
> Attachments: AMBARI-17158.patch
>
>
> Recently in 2.4.0.0 builds we are seeing that ViewContextImpl.getUsername() and ViewContextImpl.getLoggedinUser() are returning username as {noformat}[LOCAL]admin{noformat} when the user is admin.
>
> I traced a bit and checked that in SecurityHelperImpl#getCurrentUserName()
>
> {code:java}
> @Override
> public String getCurrentUserName() {
> SecurityContext ctx = SecurityContextHolder.getContext();
> Authentication authentication = ctx == null ? null : ctx.getAuthentication();
> Object principal = authentication == null ? null : authentication.getPrincipal();
> String username;
> if (principal instanceof UserDetails) {
> username = ((UserDetails) principal).getUsername();
> } else {
> username = principal == null ? "" : principal.toString();
> }
> return username;
> }
> {code}
> The principal object is coming as org.apache.ambari.server.security.authorization.User and hence condition in the if statement is returning false and thus the username is returned as {noformat}[[LOCAL]]admin{noformat}.
>
> org.apache.ambari.server.security.authorization.User#toString()
> {code:java}
> @Override
> public String toString() {
> return "[" + getUserType() + "]" + userName;
> }
> {code}
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)