本文整理汇总了Python中saml2.metadata.create_metadata_string函数的典型用法代码示例。如果您正苦于以下问题:Python create_metadata_string函数的具体用法?Python create_metadata_string怎么用?Python create_metadata_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_metadata_string函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, config):
"""
Creates a response containing the metadata generated from the SP config.
:type config: dict[str, Any]
:param config: The SP config
"""
metadata_string = create_metadata_string(None, config, 4, None, None, None, None,
None).decode("utf-8")
resp = {"content": "text/xml"}
super(MetadataResponse, self).__init__(message=metadata_string, **resp)
示例2: metadata
def metadata(environ, start_response, _args):
path = _args.path
if path is None or len(path) == 0:
path = os.path.dirname(os.path.abspath(__file__))
if path[-1] != "/":
path += "/"
metadata = create_metadata_string(path + "sp_conf.py", None,
_args.valid, _args.cert,
_args.keyfile,
_args.id, _args.name, _args.sign)
start_response('200 OK', [('Content-Type', "text/xml")])
return metadata
示例3: _metadata_endpoint
def _metadata_endpoint(self, context):
"""
Endpoint for retrieving the backend metadata
:type context: satosa.context.Context
:rtype: satosa.response.Response
:param context: The current context
:return: response with metadata
"""
satosa_logging(logger, logging.DEBUG, "Sending metadata response", context.state)
metadata_string = create_metadata_string(None, self.idp.config, 4, None, None, None, None,
None).decode("utf-8")
return Response(metadata_string, content="text/xml")
示例4: metadata
def metadata(environ, start_response):
try:
path = args.path
if path is None or len(path) == 0:
path = os.path.dirname(os.path.abspath( __file__ ))
if path[-1] != "/":
path += "/"
metadata = create_metadata_string(path+args.config, IDP.config,
args.valid, args.cert, args.keyfile,
args.id, args.name, args.sign)
start_response('200 OK', [('Content-Type', "text/xml")])
return metadata
except Exception as ex:
logger.error("An error occured while creating metadata:" + ex.message)
return not_found(environ, start_response)
示例5: __init__
def __init__(self, sp_logger, args):
"""
Constructor for the SpHandler.
:param sp_logger: A logger.
"""
#Metadata for the SP
self.sp_metadata = create_metadata_string(args.spconf + ".py", None, args.valid, args.cert, args.keyfile,
args.id_sp, args.name_sp, args.sign)
#Log class. (see import logging)
self.logger = sp_logger
#Configurations for the SP handler. (pyOpSamlProxy.client.sp.conf)
self.sp_conf = importlib.import_module(args.spconf) #pyOpSamlProxy.client.sp.conf
#Name of the configuration file. See above.
self.sp_conf_name = self.sp_conf.WORKING_DIR + args.spconf
#SP configuration object. (See project pysaml2; saml2.client.Saml2Client)
self.sp = Saml2Client(config_file="%s" % self.sp_conf_name)
#Extra arguments for the pyOpSamlProxy.client.sp.util.SSO object.
self.args = {}
#URL to SAML discovery server.
self.args["discosrv"] = self.sp_conf.DISCOSRV
#URL to SAML WAYF server.
self.args["wayf"] = self.sp_conf.WAYF
#URL to op server authorization when the SP have been authenticated.
#TODO have to be changed when Saml to Saml is implemented.
self.authorization_url = "%s/authorization" % self.sp_conf.ISSUER
#Handles the SAML authentication for an op server.
self.authnmethod = SPAuthnMethodHandler(None, self.sp_conf.SPVERIFYBASE, self.authorization_url)
#Handles SAML authentication for an IdP server.
# Setup performed by pyOpSamlProxy.provider.idp.handler.handler.
self.sp_authentication = None
#Handles the user info response with Saml attributes.
self.userinfo = UserInfoSpHandler(self.sp_conf.OPENID2SAMLMAP, self)
#The handler for the op server. Must be set after creation
#This must be the instance of the class pyOpSamlProxy.provider.op.handler.OpHandler.
self.ophandler = None
#Contains the user cache for the SpHandler, like collected IdP attributes.
#Dictionary where userid is key and value is an instance of the class
#pyOpSamlProxy.client.sp.handler.SpHandlerCache
self.sphandlercache = self.sp_conf.CACHE
self.certificate_cache_name = "CERTIFICATE_CACHE"
self.certificate_cookie_name = sid()
self.certificate_cookie_seed = sid()
示例6: __init__
def __init__(self, args, template_lookup, sphandler, ISSUER):
idpconfig = importlib.import_module(args.idpconfig)
self.copy_sp_cert = idpconfig.COPYSPCERT
self.copy_sp_key = idpconfig.COPYSPKEY
self.passwd = idpconfig.PASSWD
self.cas_server = idpconfig.CAS_SERVER
self.yubikey_db = idpconfig.YUBIKEY_DB
self.yubikey_server = idpconfig.YUBIKEY_SERVER
self.service_url = ISSUER + "/" + self.IDP_VERIFY_URL
self.template_lookup = template_lookup
self.idp_server = self.setup_saml2_server(args.idpconfig, idpconfig, idpconfig.SYM_KEY)
self.authn_broker = self.setup_authn_broker(ISSUER, sphandler, idpconfig.AUTHORIZATION)
self.auth_cookie = None
self.non_authn_urls = [
(r'%s?(.*)$' % self.IDP_VERIFY_URL, self.do_verify),
(r'sso/ecp$', (SSO, "ecp")),
]
self.sphandler = sphandler
self.idp_metadata = create_metadata_string(args.idpconfig + ".py", self.idp_server.config, args.valid,
args.cert,
args.keyfile, args.id_idp, args.name_idp, args.sign)
示例7: metadata
def metadata(environ, start_response):
try:
path = _args.path
if path is None or len(path) == 0:
path = os.path.dirname(os.path.abspath(__file__))
if path[-1] != "/":
path += "/"
metadata = create_metadata_string(
path + "sp_conf.py",
None,
_args.valid,
_args.cert,
_args.keyfile,
_args.id,
_args.name,
_args.sign,
)
start_response("200 OK", [("Content-Type", "text/xml")])
return [metadata]
except Exception as ex:
logger.error("An error occured while creating metadata: %s", ex.message)
return not_found(environ, start_response)
示例8: create_logger
help="A file with a key to sign the metadata with")
parser.add_argument('-n', dest='name')
parser.add_argument('-s', dest='sign', action='store_true',
help="sign the metadata")
parser.add_argument('-sp', dest='sp_conf', default='sp_conf',
help="sp configuration file")
parser.add_argument(dest="config")
args = parser.parse_args()
global config
config = importlib.import_module(args.config)
sp_config = importlib.import_module(args.sp_conf)
global logger
logger = create_logger(config.LOG_FILE)
metadata = create_metadata_string("sp_conf.py", None, args.valid, args.cert, args.keyfile, args.id, args.name,
args.sign)
global sphandler
sphandler = SpHandler(logger, metadata, os.path.dirname(os.path.abspath( __file__ )), args.sp_conf+".py", sp_config)
global srv
srv = wsgiserver.CherryPyWSGIServer(('0.0.0.0', config.PORT), SessionMiddleware(application, config.SESSION_OPTS))
srv.stats['Enabled'] = True
if config.HTTPS:
srv.ssl_adapter = ssl_pyopenssl.pyOpenSSLAdapter(config.SERVER_CERT, config.SERVER_KEY, config.CERT_CHAIN)
srv.ssl_adapter.context = srv.ssl_adapter.get_context()
srv.ssl_adapter.context.set_options(SSL.OP_NO_SSLv3)
srv.ssl_adapter.context.set_cipher_list('EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA')
logger.info("Server starting")