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:19:21 UTC

[jira] [Updated] (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:all-tabpanel ]

Myroslav Papirkovskyi updated AMBARI-17158:
-------------------------------------------
    Attachment: AMBARI-17158.patch

Pushed to trunk and branch-2.4

> 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)