コード例 #1
0
ファイル: server.py プロジェクト: simudream/s2sproxy
def incomming(info, instance, environ, start_response, relay_state):
    """
    An Authentication request has been requested, this is the second step
    in the sequence

    :param info: Information about the authentication request
    :param instance: IDP instance that received the Authentication request
    :param environ: WSGI environment
    :param start_response: WSGI start_response
    :param relay_state:

    :return: response
    """

    # If I know which IdP to authenticate at return a redirect to it
    if EntityID:
        inst = SamlSP(environ, start_response, CONFIG["SP"], CACHE, outgoing)
        state_key = inst.store_state(info["authn_req"], relay_state,
                                     info["req_args"])
        return inst.authn_request(EntityID, state_key)
    else:
        # start the process by finding out which IdP to authenticate at
        return instance.disco_query(info["authn_request"], relay_state,
                                    info["req_args"])
コード例 #2
0
def incomming(info, instance, environ, start_response, relay_state):
    """
    An Authentication request has been requested, this is the second step
    in the sequence

    :param info: Information about the authentication request
    :param instance: IDP instance that received the Authentication request
    :param environ: WSGI environment
    :param start_response: WSGI start_response
    :param relay_state:

    :return: response
    """

    # If I know which IdP to authenticate at return a redirect to it
    if EntityID:
        inst = SamlSP(environ, start_response, CONFIG["SP"], CACHE, outgoing)
        state_key = inst.store_state(info["authn_req"], relay_state,
                                     info["req_args"])
        return inst.authn_request(EntityID, state_key)
    else:
        # start the process by finding out which IdP to authenticate at
        return instance.disco_query(info["authn_request"], relay_state,
                                    info["req_args"])
コード例 #3
0
def run(spec, environ, start_response):
    """
    Picks entity and method to run by that entity.

    :param spec: a tuple (entity_type, response_type, binding)
    :param environ: WSGI environ
    :param start_response: WSGI start_response
    :return:
    """

    if isinstance(spec, tuple):
        if spec[0] == "SP":
            inst = SamlSP(environ, start_response, CONFIG["SP"], CACHE,
                          outgoing, **SP_ARGS)
        else:
            inst = SamlIDP(environ, start_response, CONFIG["IDP"], CACHE,
                           incomming)

        func = getattr(inst, spec[1])
        return func(*spec[2:])
    else:
        return spec()
コード例 #4
0
ファイル: server.py プロジェクト: simudream/s2sproxy
    _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}

    CACHE = {}
    sp = SamlSP(None, None, CONFIG["SP"], CACHE)
    URLS.extend(sp.register_endpoints())

    idp = SamlIDP(None, None, CONFIG["IDP"], CACHE, None)
    URLS.extend(idp.register_endpoints())

    # ============== Web server ===============

    SRV = wsgiserver.CherryPyWSGIServer((Config.HOST, Config.PORT), application)

    if Config.HTTPS:
        SRV.ssl_adapter = ssl_pyopenssl.pyOpenSSLAdapter(
            Config.SERVER_CERT, Config.SERVER_KEY, Config.CERT_CHAIN)

    LOGGER.info("Server starting")
    if Config.HTTPS:
コード例 #5
0
    _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}

    CACHE = {}
    sp = SamlSP(None, None, CONFIG["SP"], CACHE)
    URLS.extend(sp.register_endpoints())

    idp = SamlIDP(None, None, CONFIG["IDP"], CACHE, None)
    URLS.extend(idp.register_endpoints())

    # ============== Web server ===============

    SRV = wsgiserver.CherryPyWSGIServer((Config.HOST, Config.PORT),
                                        application)

    if Config.HTTPS:
        SRV.ssl_adapter = ssl_pyopenssl.pyOpenSSLAdapter(
            Config.SERVER_CERT, Config.SERVER_KEY, Config.CERT_CHAIN)

    LOGGER.info("Server starting")