コード例 #1
0
    def construct_config(self, qiss, qtag):
        if not qtag:
            raise Exception('Missing "tag" value')

        _conf = json.loads(
            open('{}/common.json'.format(self.entinfo), 'r').read())

        try:
            typ, _econf = self.read_conf(qiss, qtag)
        except NoSuchFile:
            raise

        if _econf is None:
            raise Exception('No configuration for {}:{}'.format(qiss, qtag))

        if do_registration(_econf['tool']['profile']):
            reg_info = json.loads(
                open('{}/registration_info.json'.format(self.entinfo),
                     'r').read())
            _conf['client']['registration_info'] = reg_info[
                'registration_info']
        else:
            for typ in ['provider_info', 'registration_response']:
                try:
                    _conf['client'][typ] = _econf[typ]
                except KeyError:
                    pass

        _conf['tool'] = _econf['tool']
        return _conf
コード例 #2
0
    def basic_entity_configuration(self, io):
        q = parse_qs(io.environ.get('QUERY_STRING'))

        # construct profile
        profile = to_profile(q)
        _ent_conf = create_model(profile, ent_info_path=self.ent_info)
        state = {}

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = q['iss'][0]

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.assigned_ports.register_port(q['iss'][0], q['tag'][0])
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '{}:{}/authz_cb'.format(
                    self.test_tool_base[:-1], _port)

        _ent_conf['tool']['tag'] = q['tag'][0]
        _ent_conf['tool']['issuer'] = q['iss'][0]
        _ent_conf['tool']['profile'] = profile

        _qiss = quote_plus(q['iss'][0])
        _qtag = quote_plus(q['tag'][0])
        io.rest.write(_qiss, _qtag, _ent_conf)
        return '{}form/update/{}/{}'.format(self.baseurl, _qiss, _qtag)
コード例 #3
0
ファイル: app_conf.py プロジェクト: rohe/oidctest
    def basic_entity_configuration(self, io):
        q = parse_qs(io.environ.get('QUERY_STRING'))

        # construct profile
        profile = to_profile(q)
        _ent_conf = create_model(profile, ent_info_path=self.ent_info)
        state = {}

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = q['iss'][0]

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.assigned_ports.register_port(q['iss'][0], q['tag'][0])
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '{}:{}/authz_cb'.format(
                self.test_tool_base[:-1], _port)

        _ent_conf['tool']['tag'] = q['tag'][0]
        _ent_conf['tool']['issuer'] = q['iss'][0]
        _ent_conf['tool']['profile'] = profile

        _qiss = quote_plus(q['iss'][0])
        _qtag = quote_plus(q['tag'][0])
        io.rest.write(_qiss, _qtag, _ent_conf)
        return '{}form/update/{}/{}'.format(self.baseurl, _qiss, _qtag)
コード例 #4
0
def create_model(profile, tag='default', ent_info_path='entity_info'):
    """

    :param profile:  test instance profile
    :param tag:  test instance tag
    :return:  json document that can be used as a model for creating a
        test instance configuration
    """
    res = {}
    _tool = json.load(open('{}/tool.json'.format(ent_info_path), 'r'))

    res['tool'] = _tool['tool']
    res['tool']['profile'] = profile
    res['tool']['issuer'] = 'Your OPs issuer id goes here'

    res['tool']['tag'] = tag
    if not do_discovery(profile):
        econf = empty_conf(ProviderConfigurationResponse)
        try:
            res['client']['provider_info'] = econf
        except KeyError:
            res['client'] = {'provider_info': econf}

    if not do_registration(profile):
        econf = empty_conf(RegistrationResponse)
        try:
            res['client']['registration_response'] = econf
        except KeyError:
            res['client'] = {'registration_response': econf}

    return res
コード例 #5
0
ファイル: app_conf.py プロジェクト: rohe/oidctest
    def construct_config(self, qiss, qtag):
        if not qtag:
            raise Exception('Missing "tag" value')

        _conf = json.loads(
            open('{}/common.json'.format(self.entinfo), 'r').read())

        try:
            typ, _econf = self.read_conf(qiss, qtag)
        except NoSuchFile:
            raise

        if _econf is None:
            raise Exception('No configuration for {}:{}'.format(qiss, qtag))

        if do_registration(_econf['tool']['profile']):
            reg_info = json.loads(
                open('{}/registration_info.json'.format(
                    self.entinfo), 'r').read())
            _conf['client']['registration_info'] = reg_info['registration_info']
        else:
            for typ in ['provider_info', 'registration_response']:
                try:
                    _conf['client'][typ] = _econf[typ]
                except KeyError:
                    pass

        _conf['tool'] = _econf['tool']
        return _conf
コード例 #6
0
ファイル: app_conf.py プロジェクト: rohe/oidctest
def create_model(profile, tag='default', ent_info_path='entity_info'):
    """

    :param profile:  test instance profile
    :param tag:  test instance tag
    :return:  json document that can be used as a model for creating a
        test instance configuration
    """
    res = {}
    _tool = json.load(open('{}/tool.json'.format(ent_info_path), 'r'))

    res['tool'] = _tool['tool']
    res['tool']['profile'] = profile
    res['tool']['issuer'] = 'Your OPs issuer id goes here'

    res['tool']['tag'] = tag
    if not do_discovery(profile):
        econf = empty_conf(ProviderConfigurationResponse)
        try:
            res['client']['provider_info'] = econf
        except KeyError:
            res['client'] = {'provider_info': econf}

    if not do_registration(profile):
        econf = empty_conf(RegistrationResponse)
        try:
            res['client']['registration_response'] = econf
        except KeyError:
            res['client'] = {'registration_response': econf}

    return res
コード例 #7
0
ファイル: action.py プロジェクト: deanraspa/oidctest
    def create(self, **kwargs):
        logging.info('create test tool configuration')
        # construct profile
        profile = to_profile(kwargs)
        _ent_conf = create_model(profile, ent_info_path=self.ent_info_path)
        state = {}

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = kwargs['iss']

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.app.assigned_ports.register_port(
                kwargs['iss'], kwargs['tag'])
            if self.app.test_tool_base.endswith('/'):
                _base = self.app.test_tool_base[:-1]
            else:
                _base = self.app.test_tool_base
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '{}:{}/authz_cb'.format(_base, _port)

        uqp, qp = unquote_quote(kwargs['iss'], kwargs['tag'])
        _ent_conf['tool']['issuer'] = uqp[0]
        _ent_conf['tool']['tag'] = uqp[1]
        _ent_conf['tool']['profile'] = profile

        _ent_conf.update(from_profile(profile))
        logging.info("Test tool config: {}".format(_ent_conf))

        self.rest.write(qp[0], qp[1], _ent_conf)
        # Do a redirect
        raise cherrypy.HTTPRedirect('/action/update?iss={}&tag={}'.format(
            qp[0], qp[1]))
コード例 #8
0
ファイル: rest.py プロジェクト: Rezegmushtaha/oidctest
    def construct_config(self, qiss, qtag):
        uqp, qp = unquote_quote(qiss, qtag)

        logger.info('construct config iss="{}", tag="{}"'.format(*uqp))
        if not qtag:
            raise Exception('Missing "tag" value')

        _conf = json.loads(
            open('{}/common.json'.format(self.entinfo), 'r').read())

        typ, _econf = self.read_conf(*qp)

        if _econf is None:
            raise Exception('No configuration for {}:{}'.format(*uqp))

        if do_registration(_econf['tool']['profile']):
            reg_info = json.loads(
                open('{}/registration_info.json'.format(self.entinfo),
                     'r').read())
            _conf['client']['registration_info'] = reg_info[
                'registration_info']
        else:
            try:
                _conf['client']['registration_response'] = _econf['client'][
                    'registration_response']
            except KeyError:
                _conf['client']['registration_response'] = _econf[
                    'registration_response']

        if not do_discovery(_econf['tool']['profile']):
            _conf['client']['provider_info'] = _econf['provider_info']

        _conf['tool'] = _econf['tool']
        logger.info("Constructed config: {}".format(_conf))
        return _conf
コード例 #9
0
ファイル: action.py プロジェクト: Rezegmushtaha/oidctest
    def create(self, **kwargs):
        logger.info('create test tool configuration: {} {}'.format(
            kwargs['iss'], kwargs['tag']))

        uqp, qp = unquote_quote(kwargs['iss'], kwargs['tag'])
        if not uqp[0].startswith('https://') and not uqp[0].startswith(
                'http://'):
            err = 'issuer value must start with "https://" or "http://"'
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        # construct profile
        try:
            profile = to_profile(kwargs)
        except KeyError as err:
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        _ent_conf = create_model(profile, ent_info_path=self.ent_info_path)

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = kwargs['iss']

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.app.assigned_ports.register_port(
                kwargs['iss'], kwargs['tag'])
            if self.app.test_tool_base.endswith('/'):
                _base = self.app.test_tool_base[:-1]
            else:
                _base = self.app.test_tool_base
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '[ "{}:{}/authz_cb", "{}:{}/authz_post" ]'.format(
                    _base, _port, _base, _port)

        _ent_conf['tool']['issuer'] = uqp[0]
        _ent_conf['tool']['tag'] = uqp[1]
        _ent_conf['tool']['profile'] = profile

        _ent_conf.update(from_profile(profile))
        logger.info("Test tool config: {}".format(_ent_conf))

        self.rest.write(qp[0], qp[1], _ent_conf)
        # Do a redirect
        raise cherrypy.HTTPRedirect('/action/update?iss={}&tag={}'.format(
            qp[0], qp[1]))
コード例 #10
0
ファイル: action.py プロジェクト: rohe/oidctest
    def create(self, **kwargs):
        logger.info(
            'create test tool configuration: {} {}'.format(kwargs['iss'],
                                                           kwargs['tag']))

        uqp, qp = unquote_quote(kwargs['iss'], kwargs['tag'])
        if not uqp[0].startswith('https://') and not uqp[0].startswith('http://'):
            err = 'issuer value must start with "https://" or "http://"'
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        # construct profile
        try:
            profile = to_profile(kwargs)
        except KeyError as err:
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        _ent_conf = create_model(profile, ent_info_path=self.ent_info_path)

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = kwargs['iss']

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.app.assigned_ports.register_port(kwargs['iss'],
                                                          kwargs['tag'])
            if self.app.test_tool_base.endswith('/'):
                _base = self.app.test_tool_base[:-1]
            else:
                _base = self.app.test_tool_base
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '[ "{}:{}/authz_cb", "{}:{}/authz_post" ]'.format(_base, _port, _base, _port)

        _ent_conf['tool']['issuer'] = uqp[0]
        _ent_conf['tool']['tag'] = uqp[1]
        _ent_conf['tool']['profile'] = profile

        _ent_conf.update(from_profile(profile))
        logger.info("Test tool config: {}".format(_ent_conf))

        self.rest.write(qp[0], qp[1], _ent_conf)
        # Do a redirect
        raise cherrypy.HTTPRedirect(
            '/action/update?iss={}&tag={}'.format(qp[0], qp[1]))