italia / spid-testenv2

New test Identity Provider for SPID
GNU Affero General Public License v3.0
35 stars 38 forks source link

Pulire e migliorare il log #110

Open alranel opened 6 years ago

alranel commented 6 years ago

Dovremmo pulire un po' il log. Propongo di usare livelli distinti:

Quello che segue, ad esempio, è ciò che compare alla ricezione e al successivo processamento di una LogoutRequest. Ci sono alcune cose che potrebbero confondere l'utente che legge questo log:

127.0.0.1 - - [06/Aug/2018 23:18:17] "GET /favicon.ico HTTP/1.1" 404 -
[2018-08-06 23:18:17,784] DEBUG in spid-testenv: req: '<Request 'http://localhost:8088/slo?SAMLRequest=nZJdSyMxFIbv%2FRVD7ttJ5jMJ7YBQhYK7i1ZW1htJkzM1OE3qnMxW%2F73ph8v6gRdCOBcv73vy5ORMUK27bCMv%2FMoP4QoeB8CQzGKxTgXr3ZTch7CRadp5rbp7j0FyynmKnSfJb%2Bhx78nGlCTz2ZTcFZXQQixzENTwmjLIqWZiWWSaGVowFW2IA8wdBuVCTFLGRzSe6jpjknHJ6luSPK07h%2FLANiVD76RXaFE6tQaUQcvF6Y8LGW%2BVm94Hr333JvN1RCFCv3sbaSZ7u9wj9cm579cqfB3eKdaM2r1Vggs2PJPkZ1QvB9XZ1kJ%2FGBnGmW2323EE%2FKvGNqSk%2BVSepP8zvBLtGs5n3yAKvXJoI9enUB%2F%2BkTRVVgJTS1OUojC15qZluhKt0aIuqhqgNIrlLVSlycqcsRoYX%2BaVULTgma5z%2Bsp%2FID7yb%2BQCcLcac2fgqYl41cPNnzNYDOLm7PLh1wrbY%2B6d85%2F6ZiGbkxc%3D&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=K8cxDUY0pNVvi9eAPyWUFyYT%2FZj7qt3ymHeYtnOzrThrUrKisp7HfkoM4k0yOWoZ2avnEX2MgH8SsemylSV2yk3sOjnglSseJ8impap4fSrzqPXUIPZb0hrJSpiP6H8lpjVjkX6k56IpNdEHN0OItg1lHoLLsPGAhEVsNvy199rqgbDF0W7wKZ7HfbBTmZo4hqHpQpQrFKyWRSfmJhmgky5ulEgoLdnFAIH5Oj3rKctc66NJ8HWG%2F6BeSFJqQtx9RSi7O2TjgIv89XQ1ds8lXScqh5qT7pmMihjs4LcJb09DtaPjXcNTA3OMsY3OBsyFh0NH4XueCJJnvxBpmyn4Wg%3D%3D' [GET]>'
[2018-08-06 23:18:17,790] DEBUG in spid-testenv: LogoutRequest:
<ns0:LogoutRequest xmlns:ns0="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:ns1="urn:oasis:names:tc:SAML:2.0:assertion" Destination="http://localhost:8088/slo" ID="_469c99b3e90d8701e30c19b42c1d041a" IssueInstant="2018-08-06T21:18:17Z" Version="2.0">
  <ns1:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" NameQualifier="https://www.prova.it/">https://www.prova.it/</ns1:Issuer>
  <ns1:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" NameQualifier="http://localhost:8088">625e1abd4594d7c8df1c69fdc97467ee5da13fe65d253117e18b369a0482c730</ns1:NameID>
  <ns0:SessionIndex>id-6kWYEeSu9WEQkOgsf</ns0:SessionIndex>
</ns0:LogoutRequest>

[2018-08-06 23:18:17,791] DEBUG in spid-testenv: parsed authn_request: {'attrs': {'ID': {'value': '_469c99b3e90d8701e30c19b42c1d041a', 'errors': {}}, 'Version': {'value': '2.0', 'errors': {}}, 'IssueInstant': {'value': '2018-08-06T21:18:17Z', 'errors': {}}, 'Destination': {'value': 'http://localhost:8088/slo', 'errors': {}}}, 'children': {'issuer': {'attrs': {'Format': {'value': 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity', 'errors': {}}, 'NameQualifier': {'value': 'https://www.prova.it/', 'errors': {}}}, 'children': {}, 'errors': {}}, 'name_id': {'attrs': {'NameQualifier': {'value': 'http://localhost:8088', 'errors': {}}, 'Format': {'value': 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient', 'errors': {}}}, 'children': {}, 'errors': {}}, 'session_index': {'attrs': {}, 'children': {}, 'errors': {}}}, 'errors': {}}
[2018-08-06 23:18:17,791] DEBUG in spid-testenv: Messaggio SAML firmato.
[2018-08-06 23:18:17,791] DEBUG in spid-testenv: security backend: RSACrypto
[2018-08-06 23:18:17,793] DEBUG in spid-testenv: Response binding:
urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST
[2018-08-06 23:18:17,793] DEBUG in spid-testenv: Signature inside response:
True
[2018-08-06 23:18:17,826] DEBUG in spid-testenv: Response:
<?xml version="1.0"?>
<ns0:LogoutResponse xmlns:ns0="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:ns1="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" Destination="http://localhost:3000/spid-slo" ID="id-LFUMYR1XFPf5BSGny" InResponseTo="_469c99b3e90d8701e30c19b42c1d041a" IssueInstant="2018-08-06T21:18:17Z" Version="2.0"><ns1:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">http://localhost:8088</ns1:Issuer><ns2:Signature Id="Signature1"><ns2:SignedInfo><ns2:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ns2:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/><ns2:Reference URI="#id-LFUMYR1XFPf5BSGny"><ns2:Transforms><ns2:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ns2:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ns2:Transforms><ns2:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/><ns2:DigestValue>HIAfjjqR9Np6HGNxenfH7hIb+UigYBt/ombst4kPtadqMJ2mQtcTMF0ZLmtNIbvM
x+5p2jbDVP0Qw1FAUwZ6kQ==</ns2:DigestValue></ns2:Reference></ns2:SignedInfo><ns2:SignatureValue>BT500Jx0jP5hPhFkK8xJW+neHkYYYxYnpBYPbfRrIIdRlvryOW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ZUtEBnpXDAhAFFDyAACfxAQy+/5u1u5dI0189AFk2EcqcSuA9pQWbzhswlQaSQFBU1nabIU2SwDPfHMwLFVrJdH09RuMSKM4IBNzCiLj5KgqepdFO3+8e0ewiwo8imhTYaTDR3ZXQaTNQt99fhT/LOMUcCR4hH14Cn72X7xTPK7hTz4p1D3uXfKT/o1qiql2PAjfl8</ns2:X509Certificate></ns2:X509Data></ns2:KeyInfo></ns2:Signature><ns0:Status><ns0:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/></ns0:Status></ns0:LogoutResponse>

[2018-08-06 23:18:17,828] DEBUG in spid-testenv: Destination http://localhost:3000/spid-slo
[2018-08-06 23:18:17,828] DEBUG in spid-testenv: Form post <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
    </head>
    <body onload="document.forms[0].submit()">
        <noscript>
            <p>
                <strong>Note:</strong> Since your browser does not support JavaScript,
                you must press the Continue button once to proceed.
            </p>
        </noscript>

        <form action="http://localhost:3000/spid-slo" method="post">
            <div>
                <input type="hidden" name="RelayState" value=""/>

                <input type="hidden" name="SAMLResponse" value="PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxuczA6TG9nb3V0UmVzcG9uc2UgeG1sbnM6bnMwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOm5zMT0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmFzc2VydGlvbiIgeG1sbnM6bnMyPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjIiBEZXN0aW5hdGlvbj0iaHR0cDovL2xvY2FsaG9zdDozMDAwL3NwaWQtc2xvIiBJRD0iaWQtTEZVTVlSMVhGUGY1QlNHbnkiIEluUmVzcG9uc2VUbz0iXzQ2OWM5OWIzZTkwZDg3MDFlMzBjMTliNDJjMWQwNDFhIiBJc3N1ZUluc3RhbnQ9IjIwMTgtMDgtMDZUMjE6MTg6MTdaIiBWZ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kvckx1Q29Ua0JpaEg0UUdBMGJrZzhoZTU2QlNhM3NBUG55TzNWTGF2bFl2M3lZQ1FEcVIrcjJVTTFmOGdOUFRsRTVVSVF6T1lQWHYxdy9ZcnJGaEV4N3hVWVBoMUoyZTRKNnhSUmJacXp2Qjc0UUYwdDBBMFh1ZUNJVFhMdVZRNWVRMXJJV0ZBTDFud01xV3ZlcCszSHZEcHEwSzhuekdGam51dDZFbGZ5eWhQcDgrL0gwekJPa1FJREFRQUJNQTBHQ1NxR1NJYjNEUUVCQ3dVQUE0SUJBUUJ3NG1mSCtXdFIvZXRUVldLMUp5OURYV3hBYXpGVmlRY1ZCdWFsVHVsZVJTSFpqQ3Yvbnl2NFlieUZsVE5hckRJK0xGK2lHMnJDQUJ4Z1k0MEw2RnBOOUduc2E1d2lqdUtzMEU2WkF2Si9yWWZyWWtFOHdkMHk4WjIzVmVvWEQvbThPaHdjeXNNdHlNMTBHeFpVdEVCbnBYREFoQUZGRHlBQUNmeEFReSsvNXUxdTVkSTAxODlBRmsyRWNxY1N1QTlwUVdiemhzd2xRYVNRRkJVMW5hYklVMlN3RFBmSE13TEZWckpkSDA5UnVNU0tNNElCTnpDaUxqNUtncWVwZEZPMys4ZTBld2l3bzhpbWhUWWFURFIzWlhRYVROUXQ5OWZoVC9MT01VY0NSNGhIMTRDbjcyWDd4VFBLN2hUejRwMUQzdVhmS1QvbzFxaXFsMlBBamZsODwvbnMyOlg1MDlDZXJ0aWZpY2F0ZT48L25zMjpYNTA5RGF0YT48L25zMjpLZXlJbmZvPjwvbnMyOlNpZ25hdHVyZT48bnMwOlN0YXR1cz48bnMwOlN0YXR1c0NvZGUgVmFsdWU9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpzdGF0dXM6U3VjY2VzcyIvPjwvbnMwOlN0YXR1cz48L25zMDpMb2dvdXRSZXNwb25zZT4K"/>
            </div>
            <noscript>
                <div>
                    <input type="submit" value="Continue"/>
                </div>
            </noscript>
        </form>
            </body>
</html>
127.0.0.1 - - [06/Aug/2018 23:18:17] "GET /slo?SAMLRequest=nZJdSyMxFIbv%2FRVD7ttJ5jMJ7YBQhYK7i1ZW1htJkzM1OE3qnMxW%2F73ph8v6gRdCOBcv73vy5ORMUK27bCMv%2FMoP4QoeB8CQzGKxTgXr3ZTch7CRadp5rbp7j0FyynmKnSfJb%2Bhx78nGlCTz2ZTcFZXQQixzENTwmjLIqWZiWWSaGVowFW2IA8wdBuVCTFLGRzSe6jpjknHJ6luSPK07h%2FLANiVD76RXaFE6tQaUQcvF6Y8LGW%2BVm94Hr333JvN1RCFCv3sbaSZ7u9wj9cm579cqfB3eKdaM2r1Vggs2PJPkZ1QvB9XZ1kJ%2FGBnGmW2323EE%2FKvGNqSk%2BVSepP8zvBLtGs5n3yAKvXJoI9enUB%2F%2BkTRVVgJTS1OUojC15qZluhKt0aIuqhqgNIrlLVSlycqcsRoYX%2BaVULTgma5z%2Bsp%2FID7yb%2BQCcLcac2fgqYl41cPNnzNYDOLm7PLh1wrbY%2B6d85%2F6ZiGbkxc%3D&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=K8cxDUY0pNVvi9eAPyWUFyYT%2FZj7qt3ymHeYtnOzrThrUrKisp7HfkoM4k0yOWoZ2avnEX2MgH8SsemylSV2yk3sOjnglSseJ8impap4fSrzqPXUIPZb0hrJSpiP6H8lpjVjkX6k56IpNdEHN0OItg1lHoLLsPGAhEVsNvy199rqgbDF0W7wKZ7HfbBTmZo4hqHpQpQrFKyWRSfmJhmgky5ulEgoLdnFAIH5Oj3rKctc66NJ8HWG%2F6BeSFJqQtx9RSi7O2TjgIv89XQ1ds8lXScqh5qT7pmMihjs4LcJb09DtaPjXcNTA3OMsY3OBsyFh0NH4XueCJJnvxBpmyn4Wg%3D%3D HTTP/1.1" 200 -
alranel commented 6 years ago

Inoltre bisognerebbe scrivere nel log i messaggi entranti prima ancora che ne inizi il parsing. Ad esempio nel caso di #146 nel log non c'è il messaggio XML in questione perché l'errore è generato prima

alranel commented 5 years ago

Credo che ci sia ancora da lavorare su questa issue, ma comunque per adesso ho fatto il merge della PR #201 in modo da non lasciarla indietro.