Parse user identity out of init_config

        To guarantee a uniquely identifiable user, expects
        {"user": {"name": "my_username", "password": "my_password",
                  "domain": {"id": "my_domain_id"}
                  }
        }
356692
def _get_user_identity(user):
        
        if not (
            user and user.get('name') and user.get('password') and user.get("domain") and user.get("domain").get("id")
        ):
            raise IncompleteIdentity()

        identity = {"methods": ['password'], "password": {"user": user}}
        return identity
935313
def id(opts):
    '''
    
    '''
    r = salt.utils.http.query(opts['proxy']['url']+'id', decode_type='json', decode=True)
    return r['dict']['id'].encode('ascii', 'ignore')
195006
def user_parse(data):
        """"""
        user_ = data.get('user', {})
        yield 'id', data.get('user_nsid') or user_.get('id')
        yield 'username', user_.get('username', {}).get('_content')
        first_name, _, last_name = data.get(
            'fullname', {}).get('_content', '').partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
153905
def get_user_info(self, request):
        """"""
        if not current_user.is_authenticated:
            return {}

        user_info = {
            'id': current_user.get_id(),
        }

        if 'SENTRY_USER_ATTRS' in current_app.config:
            for attr in current_app.config['SENTRY_USER_ATTRS']:
                if hasattr(current_user, attr):
                    user_info[attr] = getattr(current_user, attr)

        return user_info
63795
def get_identity(user):
    
    identity = Identity(user.id)

    if hasattr(user, 'id'):
        identity.provides.add(UserNeed(user.id))

    for role in getattr(user, 'roles', []):
        identity.provides.add(RoleNeed(role.name))

    identity.user = user
    return identity
1206367
def _verify_config_dict(self, valid, config, dev_os, key_path=None):
        '''
        
        '''
        if not key_path:
            key_path = []
        for key, value in valid.items():
            self._verify_config_key(key, value, valid, config, dev_os, key_path)
91825
def _populate_input_for_name_id(self, config, record, context, data):
        
        user_id = ""
        user_id_from_attrs = config['user_id_from_attrs']
        for attr in user_id_from_attrs:
            if attr in record["attributes"]:
                value = record["attributes"][attr]
                if isinstance(value, list):
                    # Use a default sort to ensure some predictability since the
                    # LDAP directory server may return multi-valued attributes
                    # in any order.
                    value.sort()
                    user_id += "".join(value)
                    satosa_logging(
                        logger,
                        logging.DEBUG,
                        "Added attribute {} with values {} to input for NameID".format(attr, value),
                        context.state
                        )
                else:
                    user_id += value
                    satosa_logging(
                        logger,
                        logging.DEBUG,
                        "Added attribute {} with value {} to input for NameID".format(attr, value),
                        context.state
                        )
        if not user_id:
            satosa_logging(
                logger,
                logging.WARNING,
                "Input for NameID is empty so not overriding default",
                context.state
                )
        else:
            data.subject_id = user_id
            satosa_logging(
                logger,
                logging.DEBUG,
                "Input for NameID is {}".format(data.subject_id),
                context.state
                )
661151
def __init(self):
        """"""
        res = self._get(url=self._url,
                           param_dict={"f": "json"},
                           securityHandler=self._securityHandler,
                           proxy_url=self._proxy_url,
                           proxy_port=self._proxy_port)
        self._json_dict = res
        self._json_string = json.dumps(self._json_dict)
        for k,v in self._json_dict.items():
            setattr(self, k, v)
1065969
def to_dict(self):
        ''''''
        d = {'id': self.id}
        data = []
        for c in self._config_data:
            data.append(c.to_dict())
        if data:
            d['configurationData'] = data
        return d
552408
private void parseUserIdentity(CloudTrailEventData eventData) throws IOException {
        JsonToken nextToken = jsonParser.nextToken();
        if (nextToken == JsonToken.VALUE_NULL) {
            eventData.add(CloudTrailEventField.userIdentity.name(), null);
            return;
        }

        if (nextToken != JsonToken.START_OBJECT) {
            throw new JsonParseException("Not a UserIdentity object", jsonParser.getCurrentLocation());
        }

        UserIdentity userIdentity = new UserIdentity();

        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String key = jsonParser.getCurrentName();

            switch (key) {
            case "type":
                userIdentity.add(CloudTrailEventField.type.name(), jsonParser.nextTextValue());
                break;
            case "principalId":
                userIdentity.add(CloudTrailEventField.principalId.name(), jsonParser.nextTextValue());
                break;
            case "arn":
                userIdentity.add(CloudTrailEventField.arn.name(), jsonParser.nextTextValue());
                break;
            case "accountId":
                userIdentity.add(CloudTrailEventField.accountId.name(), jsonParser.nextTextValue());
                break;
            case "accessKeyId":
                userIdentity.add(CloudTrailEventField.accessKeyId.name(), jsonParser.nextTextValue());
                break;
            case "userName":
                userIdentity.add(CloudTrailEventField.userName.name(), jsonParser.nextTextValue());
                break;
            case "sessionContext":
                this.parseSessionContext(userIdentity);
                break;
            case "invokedBy":
                userIdentity.add(CloudTrailEventField.invokedBy.name(), jsonParser.nextTextValue());
                break;
            case "identityProvider":
                userIdentity.add(CloudTrailEventField.identityProvider.name(), jsonParser.nextTextValue());
                break;
            default:
                userIdentity.add(key, parseDefaultValue(key));
                break;
            }
        }
        eventData.add(CloudTrailEventField.userIdentity.name(), userIdentity);
    }
1327021
def _get_auth_from_keyring(self):
        """"""
        if not keyring:
            return None

        # Take user from URL if available, else the OS login name
        password = self._get_password_from_keyring(self.user or getpass.getuser())
        if password is not None:
            self.user = self.user or getpass.getuser()
            self.password = password

        return 'keyring'
1313935
def _verify_dict(self, conf):
        
        if not conf:
            raise SATOSAConfigurationError("Missing configuration or unknown format")

        for key in SATOSAConfig.mandatory_dict_keys:
            if key not in conf:
                raise SATOSAConfigurationError("Missing key '%s' in config" % key)

        for key in SATOSAConfig.sensitive_dict_keys:
            if key not in conf and "SATOSA_{key}".format(key=key) not in os.environ:
                raise SATOSAConfigurationError("Missing key '%s' from config and ENVIRONMENT" % key)
50558
def get_comment_init(request, obj):
    
    if request.user.is_authenticated():
        init = {'obj': obj, 'username': request.user.username, 'email': request.user.email}
    else:
        init = {'obj': obj}
    return init
1001568
def create_authentication_from_json(values):
        """"""
        key_id = values.get('publicKey')
        authentication_type = values.get('type')
        if not key_id:
            raise ValueError(
                f'Invalid authentication definition, "publicKey" is missing: {values}')

        authentication = {'type': authentication_type, 'publicKey': key_id}

        return authentication
643066
def authentication(self):
        '''
        
        '''
        url = '%s/authentication' % (self.domain)
        res = self.session.get(url)
        self._check_response(res)
        return res.json()
643759
def load_identity(config = Config()):
    
    return Identity(name = config.get('user', 'name'),
                    email_ = config.get('user', 'email'),
                    **config.get_section('smtp'))
943300
def get_username(details, backend, response, *args, **kwargs):
    

    user = details.get('user')
    if not user:
        user_uuid = kwargs.get('uid')
        if not user_uuid:
            return

        username = uuid_to_username(user_uuid)
    else:
        username = user.username

    return {
        'username': username
    }