You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ambari.apache.org by "Myroslav Papirkovskyi (JIRA)" <ji...@apache.org> on 2016/06/10 06:06:21 UTC
[jira] [Created] (AMBARI-17158) Wrong username being returned in
from ViewContextImpl.getUsername() and ViewContextImpl.getLoggedinUser()
Myroslav Papirkovskyi created AMBARI-17158:
----------------------------------------------
Summary: 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
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)