예제 #1
0
    def test_encrypt_decrypt(self):
        session = SessionStore()
        session['test'] = 'in-test'
        session.save()

        eid = sessionrefcipher.encrypt(session)
        sess = sessionrefcipher.decrypt(eid)
        self.assertEqual(sess.get('test'), 'in-test')
예제 #2
0
    def test_encrypt_decrypt(self):
        session = SessionStore()
        session['test'] = 'in-test'
        session.save()

        eid = sessionrefcipher.encrypt(session)
        sess = sessionrefcipher.decrypt(eid)
        self.assertEqual(sess.get('test'), 'in-test')
예제 #3
0
    def test_unique_encrypted_are_generated_after_revocation(self):
        session = SessionStore()
        session['test'] = 'in-test'
        session.save()

        eid1 = sessionrefcipher.encrypt(session)
        session = sessionrefcipher.decrypt(eid1)
        eid2 = sessionrefcipher.encrypt(session)
        self.assertNotEqual(eid1, eid2)
예제 #4
0
    def test_unique_encrypted_are_generated_after_revocation(self):
        session = SessionStore()
        session['test'] = 'in-test'
        session.save()

        eid1 = sessionrefcipher.encrypt(session)
        session = sessionrefcipher.decrypt(eid1)
        eid2 = sessionrefcipher.encrypt(session)
        self.assertNotEqual(eid1, eid2)
예제 #5
0
    def test_revoked_encrypted_id_raises_valueerror(self):
        session = SessionStore()
        session['test'] = 'in-test'
        session.save()

        eid1 = sessionrefcipher.encrypt(session)
        session = sessionrefcipher.decrypt(eid1)
        eid2 = sessionrefcipher.encrypt(session)
        if eid1 == eid2:
            raise SkipTest('Non-unique encrypted IDs generated')
        self.assertRaises(ValueError, sessionrefcipher.decrypt, eid1)
예제 #6
0
    def test_revoked_encrypted_id_raises_valueerror(self):
        session = SessionStore()
        session['test'] = 'in-test'
        session.save()

        eid1 = sessionrefcipher.encrypt(session)
        session = sessionrefcipher.decrypt(eid1)
        eid2 = sessionrefcipher.encrypt(session)
        if eid1 == eid2:
            raise SkipTest('Non-unique encrypted IDs generated')
        self.assertRaises(ValueError, sessionrefcipher.decrypt, eid1)
예제 #7
0
def auth(session_id, key):
    try:
        session = sessionrefcipher.decrypt(session_id)
    except ValueError:
        return None

    request = set_request('/')

    user = authenticate(ssh_key=key)
    if user and user.is_active:
        login(request, user)
        init_otp(request)
        session.update(request.session)
        session.save()
        return 'Authenticated.'
    return None
예제 #8
0
def auth(session_id, key):
    try:
        session = sessionrefcipher.decrypt(session_id)
    except ValueError:
        return None

    request = set_request('/')

    user = authenticate(ssh_key=key)
    if user and user.is_active:
        login(request, user)
        init_otp(request)
        session.update(request.session)
        session.save()
        return 'Authenticated.'
    return None
예제 #9
0
 def clean_session(self):
     try:
         return sessionrefcipher.decrypt(self.cleaned_data['session'])
     except ValueError:
         raise forms.ValidationError('Invalid session id')
예제 #10
0
 def clean_session(self):
     try:
         return sessionrefcipher.decrypt(
             self.cleaned_data['session'])
     except ValueError:
         raise forms.ValidationError('Invalid session id')