Exemplo n.º 1
0
    def test_authenticate(self):
        resp = falcon.Response()
        AuthMiddleware.authenticate(resp)

        self.assertIsNotNone(resp._cookies)
        jwt = resp._cookies[AuthMiddleware.cookie_name]

        self.assertEqual(jwt.key, AuthMiddleware.cookie_name)
        self.assertEqual(jwt.value, self.auth_token_verified)
        self.assertEqual(jwt['path'], '/')
    def test_authenticate(self):
        resp = falcon.Response()
        AuthMiddleware.authenticate(resp)

        self.assertIsNotNone(resp._cookies)
        jwt = resp._cookies[AuthMiddleware.cookie_name]

        self.assertEqual(jwt.key, AuthMiddleware.cookie_name)
        self.assertEqual(jwt.value, self.auth_token_verified)
        self.assertEqual(jwt['path'], '/')
Exemplo n.º 3
0
 def on_post(self, req, resp):
     """
     :type req: MonitorrentRequest
     :type resp: MonitorrentResponse
     """
     body = req.json
     if body is None or 'password' not in body:
         raise falcon.HTTPBadRequest('WrongPassword', 'password is not specified')
     password = body['password']
     if password != self.settings_manager.get_password():
         raise falcon.HTTPUnauthorized('WrongPassword', 'password is not correct', None)
     AuthMiddleware.authenticate(resp)
Exemplo n.º 4
0
 def on_post(self, req, resp):
     """
     :type req: MonitorrentRequest
     :type resp: MonitorrentResponse
     """
     body = req.json
     if body is None or 'password' not in body:
         raise falcon.HTTPBadRequest('WrongPassword',
                                     'password is not specified')
     password = body['password']
     if password != self.settings_manager.get_password():
         raise falcon.HTTPUnauthorized('WrongPassword',
                                       'password is not correct', None)
     AuthMiddleware.authenticate(resp)