本文整理汇总了Python中saml2.config.config_factory函数的典型用法代码示例。如果您正苦于以下问题:Python config_factory函数的具体用法?Python config_factory怎么用?Python config_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_factory函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: config_factory
parser = argparse.ArgumentParser()
parser.add_argument('-d', dest='debug', action='store_true')
parser.add_argument('-e', dest="entityid")
parser.add_argument(dest="config")
args = parser.parse_args()
# read the configuration file
sys.path.insert(0, ".")
Config = importlib.import_module(args.config)
# deal with metadata only once
_metadata_conf = Config.CONFIG["metadata"]
Config.CONFIG["metadata"] = {}
CONFIG = {
"SP": config_factory("sp", args.config),
"IDP": config_factory("idp", args.config)}
_spc = CONFIG["SP"]
mds = _spc.load_metadata(_metadata_conf)
CONFIG["SP"].metadata = mds
CONFIG["IDP"].metadata = mds
# If entityID is set it means this is a proxy in front of one IdP
if args.entityid:
EntityID = args.entityid
SP_ARGS = {}
else:
EntityID = None
SP_ARGS = {"discosrv": Config.DISCO_SRV}
开发者ID:simudream,项目名称:s2sproxy,代码行数:31,代码来源:server.py
示例17: __init__
def __init__(
self,
config=None,
debug=0,
identity_cache=None,
state_cache=None,
virtual_organization=None,
config_file="",
logger=None,
):
"""
:param config: A saml2.config.Config instance
:param debug: Whether debugging should be done even if the
configuration says otherwise
: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
self.sec = None
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
if not debug and self.config:
self.debug = self.config.debug
else:
self.debug = 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 "verify_signatures" in self.config:
self.verify_signatures = self.config.verify_signatures
else:
self.verify_signatures = True
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:natebeacham,项目名称:saml2,代码行数:74,代码来源:client.py
示例18: register_endpoints
def register_endpoints(self):
"""
Given the configuration, return a set of URL to function mappings.
"""
url_map = []
sp_endpoints = self.sp.config.getattr("endpoints", "sp")
for endp, binding in sp_endpoints["assertion_consumer_service"]:
p = urlparse(endp)
url_map.append(("^%s?(.*)$" % p.path[1:], ("SP", "authn_response",
BINDING_MAP[binding])))
url_map.append(("^%s$" % p.path[1:], ("SP", "authn_response",
BINDING_MAP[binding])))
if self.discosrv:
for endp, binding in sp_endpoints["discovery_response"]:
p = urlparse(endp)
url_map.append(("^%s$" % p.path[1:], ("SP", "disco_response",
BINDING_MAP[binding])))
return url_map
if __name__ == "__main__":
import sys
from saml2.config import config_factory
_config = config_factory("sp", sys.argv[1])
sp = SamlSP(None, None, _config)
maps = sp.register_endpoints()
print(maps)
开发者ID:ibrsp,项目名称:s2sproxy,代码行数:30,代码来源:back.py
示例19: __init__
def __init__(self, args, base_dir):
self.idp_server = None
sys.path.insert(0, os.getcwd())
server_conf = importlib.import_module(args.server_config)
e_alg = None
if "e_alg" in args:
e_alg = args.e_alg
key = None
if "key" in args:
key = args.key
h_alg = None
if "h_alg" in args:
h_alg = args.h_alg
iv = None
if "iv" in args:
iv = args.iv
self.tid_handler = TargetIdHandler(e_alg=e_alg, key=key, h_alg=h_alg, iv=iv)
self.cache = {}
self.urls = [(r'.+\.css$', WsgiApplication.css), ]
self.sp_args = None
self.base_dir = base_dir
if os.path.isdir(self.base_dir + "/static"):
self.static_dir = self.base_dir
else:
self.static_dir = "/opt/pefimproxy/"
self.logger = WsgiApplication.create_logger(server_conf.LOG_FILE, self.base_dir)
# read the configuration file
config = importlib.import_module(args.config)
# deal with metadata only once
_metadata_conf = config.CONFIG["metadata"]
_spc = config_factory("sp", args.config)
mds = _spc.load_metadata(_metadata_conf)
idp_conf, sp_confs = get_configurations(args.config, metadata_construction=False, metadata=mds,
cache=self.cache)
self.config = {
"SP": sp_confs,
"IDP": idp_conf}
# If entityID is set it means this is a proxy in front of one IdP
if args.entityid:
self.entity_id = args.entityid
self.sp_args = {}
else:
self.entity_id = None
self.sp_args = {"discosrv": config.DISCO_SRV}
sp = SamlSP(None, None, self.config["SP"], self.cache)
self.urls.extend(sp.register_endpoints())
try:
self.tid1_to_tid2 = server_conf.TID1_TO_TID2
except:
self.tid1_to_tid2 = None
try:
self.tid2_to_tid1 = server_conf.TID2_TO_TID1
except:
self.tid2_to_tid1 = None
try:
self.encmsg_to_iv = server_conf.ENCMSG_TO_IV
except:
self.encmsg_to_iv = None
try:
self.force_persistant_nameid = server_conf.FORCE_PRESISTENT_NAMEID
except:
self.force_persistant_nameid = False
try:
self.force_no_userid_subject_cacheing = server_conf.FORCE_NO_USERID_SUBJECT_CACHEING
except:
self.force_no_userid_subject_cacheing = False
samlidp = self.create_SamlIDP(None, None, None)
self.urls.extend(samlidp.register_endpoints())
self.issuer = server_conf.ISSUER
开发者ID:rhoerbe,项目名称:pefim-proxy,代码行数:75,代码来源:server.py
注:本文中的saml2.config.config_factory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论