Esempio n. 1
0
def logout():
    # Remove the user information from the session
    app.logger.info("Logout requested")

    url = '/'

    if current_user.authentication_type == 'id_porten':

        if MOCK_IDPORTEN:
            logout_user()
            return redirect('/')

        logout_request = LogoutRequest(name_id=current_user.misc["name_id"],
                                       session_index=current_user.misc["session_index"],
                                       **app.idporten_settings)
        app.logger.info("logout_request.raw_xml=%s", logout_request.raw_xml)
        url = logout_request.get_signed_url(app.idporten_settings["private_key_file"])
        app.logger.info("Logging out: url=%s", url)

    elif current_user.authentication_type == 'active_directory':

        if MOCK_ADFS:
            logout_user()
            return redirect('/')

        # Note: We never really log out from adfs, it is SSO in TK and we only want
        # to log out from our system
        logout_user()

        # Redirect to logout path on adfs idp
        url = app.adfs_settings['logout_target_url'] + '?wa=wsignout1.0'
        app.logger.info("Logging out: url=%s", url)

    return redirect(url)
def logout():
    print "Logout requested"
    logout_request = LogoutRequest(name_id=user_info["name_id"],
                                   session_index=user_info["session_index"],
                                   **settings)
    print "Logout xml", logout_request.raw_xml
    url = logout_request.get_signed_url(settings["private_key_file"])
    print "OUTGOING LOGOUT URL: ", url
    return redirect(url)
def logout():
    print "Logout requested"
    logout_request = LogoutRequest(name_id=user_info["name_id"],
                                   session_index=user_info["session_index"],
                                   **settings)
    print "Logout xml", logout_request.raw_xml
    url = logout_request.get_signed_url(settings["private_key_file"])
    print "OUTGOING LOGOUT URL: ", url
    return redirect(url)
Esempio n. 4
0
def logout():
    # Remove the user information from the session
    app.logger.info("Logout requested")
    user = authentication.get_current_user()
    logout_request = LogoutRequest(name_id=user["misc"]["name_id"],
                                   session_index=user["misc"]["session_index"],
                                   **settings)
    app.logger.info("logout_request.raw_xml=%s", logout_request.raw_xml)
    url = logout_request.get_signed_url(settings["private_key_file"])
    app.logger.info("Logging out: url=%s", url)
    return redirect(url)
    def test_create(self):
        fake_uuid_func = fudge.Fake('uuid', callable=True)
        fake_uuid_func.with_arg_count(0)
        fake_uuid = fudge.Fake('foo_uuid')
        fake_uuid.has_attr(hex='hex_uuid')
        fake_uuid = fake_uuid_func.returns(fake_uuid)

        def fake_clock():
            return datetime(2013, 9, 23, 15, 55, 43)

        logout_target_url = "https://example.com/logout_destination"
        issuer = "the_issuer"
        name_id = "the_name_id"
        session_index = "the_session_index"

        expected_xml = """<?xml version="1.0\" encoding="UTF-8"?><saml2p:LogoutRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" Destination="https://example.com/logout_destination" ID="hex_uuid" IssueInstant="2013-09-23T15:55:43.000Z" Version="2.0"><saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">the_issuer</saml2:Issuer><saml2:NameID xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">the_name_id</saml2:NameID><saml2p:SessionIndex>the_session_index</saml2p:SessionIndex></saml2p:LogoutRequest>"""

        logout_request = LogoutRequest(_clock=fake_clock,
                                       _uuid=fake_uuid_func,
                                       logout_target_url=logout_target_url,
                                       issuer=issuer,
                                       name_id=name_id,
                                       session_index=session_index)

        from xml.dom import minidom
        reparsed = minidom.parseString(logout_request.raw_xml)
        parsed_expected = minidom.parseString(expected_xml)

        print reparsed.toprettyxml()
        print parsed_expected.toprettyxml()

        eq(reparsed.toprettyxml(), parsed_expected.toprettyxml())