Esempio n. 1
0
    def test_store_db_in_file(self, tmpdir):
        consent_id = 'id1'
        consent = Consent(['attr1'], months_valid=1)
        tmp_file = os.path.join(str(tmpdir), 'db')
        db_url = 'sqlite:///' + tmp_file
        consent_db = ConsentDatasetDB('salt', 1, db_url)
        consent_db.save_consent(consent_id, consent)
        assert consent_db.get_consent(consent_id) == consent

        # make sure it was persisted to file
        consent_db = ConsentDatasetDB('salt', 1, db_url)
        assert consent_db.get_consent(consent_id) == consent
Esempio n. 2
0
    def setup(self):
        self.consent_db = ConsentDatasetDB("salt", 12)
        self.ticket_db = ConsentRequestDatasetDB("salt")
        self.max_month = 12
        self.signing_key = RSAKey(key=RSA.generate(1024), alg='RS256')

        self.cm = ConsentManager(self.consent_db, self.ticket_db,
                                 [self.signing_key], 3600, self.max_month)
Esempio n. 3
0
def init_consent_manager(app: Flask):
    consent_db = ConsentDatasetDB(app.config['CONSENT_SALT'],
                                  app.config['MAX_CONSENT_EXPIRATION_MONTH'],
                                  app.config.get('CONSENT_DATABASE_URL'))
    consent_request_db = ConsentRequestDatasetDB(
        app.config['CONSENT_SALT'],
        app.config.get('CONSENT_REQUEST_DATABASE_URL'))

    trusted_keys = [
        RSAKey(key=rsa_load(key)) for key in app.config['TRUSTED_KEYS']
    ]
    cm = ConsentManager(consent_db, consent_request_db, trusted_keys,
                        app.config['TICKET_TTL'],
                        app.config['MAX_CONSENT_EXPIRATION_MONTH'])
    return cm
Esempio n. 4
0
def consent_database():
    return ConsentDatasetDB("salt", 999)