Authenticate a user by the key passed in load.
        Return the effective user id (name) if it's different from the specified one (for sudo).
        If the effective user id is the same as the passed one, return True on success or False on
        failure.

def authenticate_key(self, load, key):
        '''
        Authenticate a user by the key passed in load.
        Return the effective user id (name) if it's different from the specified one (for sudo).
        If the effective user id is the same as the passed one, return True on success or False on
        failure.
        '''
        error_msg = 'Authentication failure of type "user" occurred.'
        auth_key = load.pop('key', None)
        if auth_key is None:
            log.warning(error_msg)
            return False

        if 'user' in load:
            auth_user = AuthUser(load['user'])
            if auth_user.is_sudo():
                # If someone sudos check to make sure there is no ACL's around their username
                if auth_key != key[self.opts.get('user', 'root')]:
                    log.warning(error_msg)
                    return False
                return auth_user.sudo_name()
            elif load['user'] == self.opts.get('user', 'root') or load['user'] == 'root':
                if auth_key != key[self.opts.get('user', 'root')]:
                    log.warning(error_msg)
                    return False
            elif auth_user.is_running_user():
                if auth_key != key.get(load['user']):
                    log.warning(error_msg)
                    return False
            elif auth_key == key.get('root'):
                pass
            else:
                if load['user'] in key:
                    # User is authorised, check key and check perms
                    if auth_key != key[load['user']]:
                        log.warning(error_msg)
                        return False
                    return load['user']
                else:
                    log.warning(error_msg)
                    return False
        else:
            if auth_key != key[salt.utils.user.get_user()]:
                log.warning(error_msg)
                return False
        return True