当前位置: 首页>>代码示例>>Python>>正文


Python config.config_factory函数代码示例

本文整理汇总了Python中saml2.config.config_factory函数的典型用法代码示例。如果您正苦于以下问题:Python config_factory函数的具体用法?Python config_factory怎么用?Python config_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了config_factory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, config_file, entityid=None, debug=False):
        self.urls = []
        self.cache = {}
        self.debug = debug

        sp_conf = config_factory("sp", config_file)
        idp_conf = config_factory("idp", config_file)

        self.config = {
            "SP": sp_conf,
            "IDP": idp_conf
        }

        sys.path.insert(0, os.path.dirname(config_file))
        conf = importlib.import_module(os.path.basename(config_file))
        self.attribute_module = conf.ATTRIBUTE_MODULE
        # If entityID is set it means this is a proxy in front of one IdP.
        if entityid:
            self.entity_id = entityid
            self.sp_args = {}
        else:
            self.entity_id = None
            self.sp_args = {"discosrv": conf.DISCO_SRV}

        sp = SamlSP(None, None, self.config["SP"], self.cache, **self.sp_args)
        self.urls.extend(sp.register_endpoints())

        idp = SamlIDP(None, None, self.config["IDP"], self.cache, None)
        self.urls.extend(idp.register_endpoints())
开发者ID:ibrsp,项目名称:s2sproxy,代码行数:29,代码来源:server.py

示例2: setup_class

    def setup_class(self):
        server = Server("idp_conf")
        name_id = server.ident.transient_nameid(
                            "urn:mace:example.com:saml:roland:sp","id12")

        self._resp_ = server.do_response(
                    "id12",                       # in_response_to
                    "http://lingon.catalogix.se:8087/",   # consumer_url
                    "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                    {"eduPersonEntitlement":"Jeter"},
                    name_id = name_id
                )
                
        self._sign_resp_ = server.do_response(
                    "id12",                       # in_response_to
                    "http://lingon.catalogix.se:8087/",   # consumer_url
                    "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                    {"eduPersonEntitlement":"Jeter"},
                    name_id = name_id,
                    sign=True
                )

        self._resp_authn = server.do_response(
                    "id12",                       # in_response_to
                    "http://lingon.catalogix.se:8087/",   # consumer_url
                    "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                    {"eduPersonEntitlement":"Jeter"},
                    name_id = name_id,
                    authn=(saml.AUTHN_PASSWORD, "http://www.example.com/login")
                )

        self.conf = config_factory("sp", "server_conf")
        self.ar = authn_response(self.conf, "http://lingon.catalogix.se:8087/")
开发者ID:evansd,项目名称:pysaml2,代码行数:33,代码来源:test_44_authnresp.py

示例3: setup_class

    def setup_class(self):
        server = Server("idp_conf")
        name_id = server.ident.transient_nameid(
                            "urn:mace:example.com:saml:roland:sp","id12")
        policy = server.conf.getattr("policy", "idp")
        self._resp_ = server.create_response(
                    "id12",                       # in_response_to
                    "http://lingon.catalogix.se:8087/",   # consumer_url
                    "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                    IDENTITY, name_id = name_id, policy=policy)
                
        self._sign_resp_ = server.create_response(
                    "id12",                       # in_response_to
                    "http://lingon.catalogix.se:8087/",   # consumer_url
                    "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                    IDENTITY,
                    name_id = name_id, sign_assertion=True, policy=policy)

        self._resp_authn = server.create_response(
                    "id12",                       # in_response_to
                    "http://lingon.catalogix.se:8087/",   # consumer_url
                    "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                    IDENTITY,
                    name_id = name_id,
                    authn=(saml.AUTHN_PASSWORD, "http://www.example.com/login"),
                    policy=policy)

        self.conf = config_factory("sp", "server_conf")
        self.conf.only_use_keys_in_metadata = False
        self.ar = authn_response(self.conf, "http://lingon.catalogix.se:8087/")
开发者ID:paulftw,项目名称:pysaml2,代码行数:30,代码来源:test_44_authnresp.py

示例4: make_plugin

def make_plugin(remember_name=None,  # plugin for remember
                cache="",  # cache
                # Which virtual organization to support
                virtual_organization="",
                saml_conf="",
                wayf="",
                sid_store="",
                identity_cache="",
                discovery="",
                idp_query_param=""
                ):
    
    if saml_conf is "":
        raise ValueError(
            'must include saml_conf in configuration')

    if remember_name is None:
        raise ValueError('must include remember_name in configuration')

    conf = config_factory("sp", saml_conf)

    scl = Saml2Client(config=conf, identity_cache=identity_cache,
                      virtual_organization=virtual_organization)

    plugin = SAML2Plugin(remember_name, conf, scl, wayf, cache, sid_store,
                         discovery, idp_query_param)
    return plugin
开发者ID:5monkeys,项目名称:pysaml2,代码行数:27,代码来源:sp.py

示例5: setup_class

    def setup_class(self):
        with closing(Server(dotname("idp_conf"))) as server:
            name_id = server.ident.transient_nameid(
                                "urn:mace:example.com:saml:roland:sp","id12")

            self._resp_ = server.create_authn_response(
                                IDENTITY,
                                "id12",                       # in_response_to
                                "http://lingon.catalogix.se:8087/",   # consumer_url
                                "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                                name_id=name_id,
                                authn=AUTHN)

            self._sign_resp_ = server.create_authn_response(
                                IDENTITY,
                                "id12",                       # in_response_to
                                "http://lingon.catalogix.se:8087/",   # consumer_url
                                "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                                name_id=name_id, sign_assertion=True,
                                authn=AUTHN)

            self._resp_authn = server.create_authn_response(
                                IDENTITY,
                                "id12",                       # in_response_to
                                "http://lingon.catalogix.se:8087/",   # consumer_url
                                "urn:mace:example.com:saml:roland:sp", # sp_entity_id
                                name_id=name_id,
                                authn=AUTHN)

            self.conf = config_factory("sp", dotname("server_conf"))
            self.conf.only_use_keys_in_metadata = False
            self.ar = authn_response(self.conf, "http://lingon.catalogix.se:8087/")
开发者ID:Goggin,项目名称:pysaml2,代码行数:32,代码来源:test_44_authnresp.py

示例6: __init__

    def __init__(self, entity_type, config=None, config_file="",
                 virtual_organization=""):
        self.entity_type = entity_type
        self.users = None

        if config:
            self.config = config
        elif config_file:
            self.config = config_factory(entity_type, config_file)
        else:
            raise SAMLError("Missing configuration")

        for item in ["cert_file", "key_file", "ca_certs"]:
            _val = getattr(self.config, item, None)
            if not _val:
                continue

            if _val.startswith("http"):
                r = requests.request("GET", _val)
                if r.status_code == 200:
                    _, filename = make_temp(r.text, ".pem", False)
                    setattr(self.config, item, filename)
                else:
                    raise Exception(
                        "Could not fetch certificate from %s" % _val)

        try:
            self.signkey = RSA.importKey(
                open(self.config.getattr("key_file", ""), 'r').read(),
                passphrase=self.config.key_file_passphrase)
        except (KeyError, TypeError):
            self.signkey = None

        HTTPBase.__init__(self, self.config.verify_ssl_cert,
                          self.config.ca_certs, self.config.key_file,
                          self.config.cert_file)

        if self.config.vorg:
            for vo in self.config.vorg.values():
                vo.sp = self

        self.metadata = self.config.metadata
        self.config.setup_logger()
        self.debug = self.config.debug

        self.sec = security_context(self.config)

        if virtual_organization:
            if isinstance(virtual_organization, basestring):
                self.vorg = self.config.vorg[virtual_organization]
            elif isinstance(virtual_organization, VirtualOrg):
                self.vorg = virtual_organization
        else:
            self.vorg = None

        self.artifact = {}
        if self.metadata:
            self.sourceid = self.metadata.construct_source_id()
        else:
            self.sourceid = {}
开发者ID:18600597055,项目名称:hue,代码行数:60,代码来源:entity.py

示例7: make_plugin

def make_plugin(rememberer_name=None, # plugin for remember
                 cache= "", # cache
                 # Which virtual organization to support
                 virtual_organization="", 
                 saml_conf="",
                 wayf="",
                 sid_store="",
                 identity_cache="",
                 discovery="",
                 ):
    
    if saml_conf is "":
        raise ValueError(
            'must include saml_conf in configuration')

    if rememberer_name is None:
        raise ValueError(
             'must include rememberer_name in configuration')
    if identity_cache == "memcached":
        identity_cache = mcache.Cache(['127.0.0.1:11211'], debug=0)


    conf = config_factory("sp", saml_conf)

    scl = Saml2Client(config=conf, identity_cache=identity_cache,
                        virtual_organization=virtual_organization)

    plugin = SAML2Plugin(rememberer_name, conf, scl, wayf, cache, sid_store,
                         discovery)
    return plugin
开发者ID:kindly,项目名称:pysaml2,代码行数:30,代码来源:sp.py

示例8: __init__

    def __init__(self, config=None,
                identity_cache=None, state_cache=None, 
                virtual_organization=None, config_file="", logger=None):
        """
        :param config: A saml2.config.Config instance
        :param identity_cache: Where the class should store identity information
        :param state_cache: Where the class should keep state information
        :param virtual_organization: Which if any virtual organization this
            SP belongs to
        """

        self.users = Population(identity_cache)

        # for server state storage
        if state_cache is None:
            self.state = {} # in memory storage
        else:
            self.state = state_cache

        if config:
            self.config = config
        elif config_file:
            self.config = config_factory("sp", config_file)
        else:
            raise Exception("Missing configuration")

        self.metadata = self.config.metadata

        if logger is None:
            self.logger = self.config.setup_logger()
        else:
            self.logger = logger

        # we copy the config.debug variable in an internal
        # field for convenience and because we may need to
        # change it during the tests
        self.debug = self.config.debug

        self.sec = security_context(self.config, log=self.logger,
                                    debug=self.debug)

        if virtual_organization:
            self.vorg = VirtualOrg(self, virtual_organization)
        else:
            self.vorg = None

        if "allow_unsolicited" in self.config:
            self.allow_unsolicited = self.config.allow_unsolicited
        else:
            self.allow_unsolicited = False

        if getattr(self.config, 'authn_requests_signed', 'false') == 'true':
            self.authn_requests_signed_default = True
        else:
            self.authn_requests_signed_default = False

        if getattr(self.config, 'logout_requests_signed', 'false') == 'true':
            self.logout_requests_signed_default = True
        else:
            self.logout_requests_signed_default = False
开发者ID:Wazoku,项目名称:pysaml2,代码行数:60,代码来源:client.py

示例9: load_config

 def load_config(self, config_file, stype="idp"):
     """ Load the server configuration 
     
     :param config_file: The name of the configuration file
     :param stype: The type of Server ("idp"/"aa")
     """
     self.conf = config_factory(stype, config_file)
     if stype == "aa":
         return
     
     try:
         # subject information is stored in a database
         # default database is a shelve database which is OK in some setups
         dbspec = self.conf.getattr("subject_data", "idp")
         idb = None
         if isinstance(dbspec, basestring):
             idb = shelve.open(dbspec, writeback=True)
         else: # database spec is a a 2-tuple (type, address)
             print >> sys.stderr, "DBSPEC: %s" % dbspec
             (typ, addr) = dbspec
             if typ == "shelve":
                 idb = shelve.open(addr, writeback=True)
             elif typ == "memcached":
                 idb = memcache.Client(addr)
             elif typ == "dict": # in-memory dictionary
                 idb = addr
                 
         if idb is not None:
             self.ident = Identifier(idb, self.conf.virtual_organization)
         else:
             raise Exception("Couldn't open identity database: %s" %
                             (dbspec,))
     except AttributeError:
         self.ident = None
开发者ID:GSA,项目名称:pysaml2,代码行数:34,代码来源:server.py

示例10: __init__

    def __init__(self, config=None, identity_cache=None, state_cache=None,
                 virtual_organization="",config_file=""):
        """
        :param config: A saml2.config.Config instance
        :param identity_cache: Where the class should store identity information
        :param state_cache: Where the class should keep state information
        :param virtual_organization: A specific virtual organization
        """

        self.users = Population(identity_cache)

        # for server state storage
        if state_cache is None:
            self.state = {} # in memory storage
        else:
            self.state = state_cache

        if config:
            self.config = config
        elif config_file:
            self.config = config_factory("sp", config_file)
        else:
            raise Exception("Missing configuration")

        if self.config.vorg:
            for vo in self.config.vorg.values():
                vo.sp = self

        self.metadata = self.config.metadata
        self.config.setup_logger()

        # we copy the config.debug variable in an internal
        # field for convenience and because we may need to
        # change it during the tests
        self.debug = self.config.debug

        self.sec = security_context(self.config)

        if virtual_organization:
            if isinstance(virtual_organization, basestring):
                self.vorg = self.config.vorg[virtual_organization]
            elif isinstance(virtual_organization, VirtualOrg):
                self.vorg = virtual_organization
        else:
            self.vorg = {}

        for foo in ["allow_unsolicited", "authn_requests_signed",
                   "logout_requests_signed"]:
            if self.config.getattr("sp", foo) == 'true':
                setattr(self, foo, True)
            else:
                setattr(self, foo, False)

        # extra randomness
        self.seed = rndstr(32)
        self.logout_requests_signed_default = True
        self.allow_unsolicited = self.config.getattr("allow_unsolicited", "sp")
开发者ID:paulftw,项目名称:pysaml2,代码行数:57,代码来源:client_base.py

示例11: __init__

    def __init__(self, config_module, config=None):
        """
        :type config_module: str
        :type config: {dict}

        :param config_module: Path to a file containing the SP SAML configuration.
        :param config: SP SAML configuration.
        """
        if config is None:
            config = config_factory('sp', config_module)
        Saml2Client.__init__(self, config)
开发者ID:borgand,项目名称:SATOSA,代码行数:11,代码来源:util.py

示例12: test

def test():
    # The needed key is the private key, not for encryption but for decryption
    _key = import_rsa_key_from_file("mykey.pem")

    idp_conf = config_factory("idp", "idp_conf")

    generate_metadata = MetadataGeneration(
        idp_proxy_conf.SERVICE, _key, idp_conf,
        idp_conf.xmlsec_path)

    sps = idp_conf.metadata.service_providers()
    qs = {
        "entityId": sps[0],
        "secret": {
            "Google": {
                "key": "lingon",
                "secret": "aaaaa"},
            "Facebook": {
                "key": "hallon",
                "secret": "bbbbb"},
            "Twitter":  {
                "key": "jordgubb",
                "secret": "ccccc"}
        }
    }

    res = generate_metadata.handle_metadata_save({'wsgi.url_scheme': "https",
                                                  'HTTP_HOST': "example.com"},
                                                 None, qs)

    s = res[0].index("<mdattr:EntityAttributes")
    e = res[0].index("</mdattr:EntityAttributes>")

    snippet = res[0][s:e+len("</mdattr:EntityAttributes>")]

    entity_attributes = mdattr.entity_attributes_from_string(snippet)

    entdescr = idp_conf.metadata.metadata["./sp/sp.xml"].entity_descr

    ext = element_to_extension_element(entity_attributes)
    entdescr.spsso_descriptor[0].extensions.extension_elements.append(ext)
    print entity_attributes

    qs = {secret.CONST_BODY: json.dumps({"xml": "%s" % entdescr})}

    generate_metadata.handle_metadata_verify_json({'wsgi.url_scheme':"https",
                                                  'HTTP_HOST': "example.com"},
                                                  None, qs)
开发者ID:NORDUnet,项目名称:IdPproxy,代码行数:48,代码来源:test_metadata_generation.py

示例13: chooseIdp

def chooseIdp(environ, start_response, startText):
    query = environ.get("QUERY_STRING")
    try:
        _idp_entity_id = dict(parse_qs(query))["IdPEntityId"][0]
    except KeyError:
        conf = config_factory("sp", "sp_conf")
        idps = conf.metadata.with_descriptor("idpsso")
        if len(idps) > 1:
            response = ["<H3>You have configured multiple IdP's for this SP.</H3><br />Please choose the IdP to use and click on login.<br /><br />"]
            response.insert(0,startText)
            response.append("<form><select name='IdPEntityId'>")
            for tmp_idp_entity_id in idps.keys():
                response.append("<option value='"+tmp_idp_entity_id+"'>"+tmp_idp_entity_id+"</option>")
            response.append("</select><input type='submit' value='Login'/></form>")
            resp = Response(response)
            return resp(environ, start_response)
    return None
开发者ID:HaToHo,项目名称:pyTestSp,代码行数:17,代码来源:sp.py

示例14: __init__

    def __init__(self, entity_type, config=None, config_file="",
                 virtual_organization=""):
        self.entity_type = entity_type
        self.users = None

        if config:
            self.config = config
        elif config_file:
            self.config = config_factory(entity_type, config_file)
        else:
            raise SAMLError("Missing configuration")

        HTTPBase.__init__(self, self.config.verify_ssl_cert,
                          self.config.ca_certs, self.config.key_file,
                          self.config.cert_file)

        if self.config.vorg:
            for vo in self.config.vorg.values():
                vo.sp = self

        self.metadata = self.config.metadata
        self.config.setup_logger()
        self.debug = self.config.debug
        self.seed = rndstr(32)

        self.sec = security_context(self.config)

        if virtual_organization:
            if isinstance(virtual_organization, basestring):
                self.vorg = self.config.vorg[virtual_organization]
            elif isinstance(virtual_organization, VirtualOrg):
                self.vorg = virtual_organization
        else:
            self.vorg = None

        self.artifact = {}
        if self.metadata:
            self.sourceid = self.metadata.construct_source_id()
        else:
            self.sourceid = {}
开发者ID:gbel,项目名称:pysaml2,代码行数:40,代码来源:entity.py

示例15: __init__

 def __init__(self, config_module):
     Saml2Client.__init__(self, config_factory('sp', config_module))
开发者ID:ibrsp,项目名称:s2sproxy,代码行数:2,代码来源:test_util.py


注:本文中的saml2.config.config_factory函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。