hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen Wittenauer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-12333) UserGroupInformation method to log in and relogin with password
Date Thu, 20 Aug 2015 15:06:45 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-12333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14705078#comment-14705078
] 

Allen Wittenauer commented on HADOOP-12333:
-------------------------------------------

bq. Thanks, I didn't know that. 

NP.

bq.  Does that work with Active Directory as well (generated by ktpass)

it should.

bq.  Is the "app" part "all Hadoop" or do I need one for HDFS, YARN, Hive, HBase, etc separately?


Should be all hadoop since it's effectively a Kerberos-level trick.  There's a lot of power
in the auth_to_local rules that people not steeped in Kerberos mythology don't realize is
there.  This is one of them.  Since Hadoop (and many others, including outside the Hadoop
ecosystem) have the ability to specify custom auth_to_local rules, you can even do it *per
application*.  So if you want user/slider to only map to user when it's launched into Hadoop
but not for HBase or anything else to trust it, only configure it in Hadoop but not anywhere
else (including /etc/krb5.conf)

> UserGroupInformation method to log in and relogin with password
> ---------------------------------------------------------------
>
>                 Key: HADOOP-12333
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12333
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: security
>    Affects Versions: 2.6.0
>         Environment: all
>            Reporter: john lilley
>
> UserGroupInformation lacks a simple method to login using a password, and also makes
an important method private.  While many people seem to believe that kinit should be used
for passwords, it is unworkable in many cases (such as when software is running as a service).
> Currently to workaround we must do all of this:
>     // create a dynamic configuration for the LoginContext
>     Map<String,String> krbOptions = new HashMap<String,String>();
>     krbOptions.put("doNotPrompt", "false");
>     krbOptions.put("useTicketCache", "false");
>     krbOptions.put("useKeyTab", "false");
>     krbOptions.put("renewTGT", "false");
>     AppConfigurationEntry ace = new AppConfigurationEntry(
>         KerberosUtil.getKrb5LoginModuleName(), LoginModuleControlFlag.REQUIRED,
>         krbOptions);
>     DynamicConfiguration dynConf = new DynamicConfiguration(
>         new AppConfigurationEntry[] {ace});
>     // create LoginContext with login callback handler
>     LoginContext loginContext = newLoginContext(USER_PASSWORD_LOGIN_KERBEROS_CONFIG_NAME,

>       null, new LoginHandler(userPrincipal, password), dynConf);
>     loginContext.login();
>     // get Subject and Principal for logged in user
>     Subject loginSubject = loginContext.getSubject();
>     Set<Principal> loginPrincipals = loginSubject.getPrincipals();
>     if (loginPrincipals.isEmpty()) {
>       throw new LoginException("No login principals in loginSubject: " + loginSubject);
>     }
>     String username = loginPrincipals.iterator().next().getName();
>     Principal ugiUser = newUser(username, AuthenticationMethod.KERBEROS, loginContext);
>     // update Hadoop security details
>     loginSubject.getPrincipals().add(ugiUser);
>     UserGroupInformation loginUser = newUserGroupInformation(loginSubject);
>     UserGroupInformation.setLoginUser(loginUser);
>     setUGILogin(loginUser, loginContext); // do loginUser.setLogin(loginContext)
>     loginUser.setAuthenticationMethod(AuthenticationMethod.KERBEROS);
> Note the method setUGILogin() uses reflection to overcome private method that we need:
> private static void setUGILogin(UserGroupInformation loginUser, LoginContext loginContext)

>     	      throws SecurityException, NoSuchMethodException, IllegalArgumentException,

>     	      IllegalAccessException, InvocationTargetException 
>   {
>     Class<UserGroupInformation> cls = UserGroupInformation.class;
>     Method mtd = cls.getDeclaredMethod("setLogin", LoginContext.class);
>     mtd.setAccessible(true);
>     mtd.invoke(loginUser, loginContext);
>   }
>   
> Finally there is no method reloginFromPassword().  While we can use reflection to access
the private methods needed for this, it should simply be supported.  
> PS: I really hope I've just missed something obvious and you can just call me an idiot
;-)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message