예제 #1
0
 def get_token_for(self, resource_path, username, filesize=None):
     """Generates a token with the brl_user and additional data dict if needed"""
     # By now username field will be used only for trace support. Its not necessary
     # for security, if you have a token you are already authenticated
     return JWTManager.get_token_for(self, {"resource_path": resource_path,
                                            "username": username,
                                            "filesize": filesize})
예제 #2
0
파일: jwt_test.py 프로젝트: 19317362/conan
    def jwt_manager_test(self):
        # Instance the manager to generate tokens that expires in 10 ms

        manager = JWTManager(self.secret, self.expire_time)

        # Encrypt a profile
        profile = {"hello": "world"}
        token = manager.get_token_for(profile)

        # Decrypt the profile
        decrypted_profile = manager.get_profile(token)
        self.assertEquals(profile, decrypted_profile)

        # Now wait 2 seconds and check if its valid now
        time.sleep(2)
        self.assertRaises(jwt.ExpiredSignature, manager.get_profile, token)
예제 #3
0
    def jwt_manager_test(self):
        # Instance the manager to generate tokens that expires in 10 ms

        manager = JWTManager(self.secret, self.expire_time)

        # Encrypt a profile
        profile = {"hello": "world"}
        token = manager.get_token_for(profile)

        # Decrypt the profile
        decrypted_profile = manager.get_profile(token)
        self.assertEquals(profile, decrypted_profile)

        # Now wait 2 seconds and check if its valid now
        time.sleep(2)
        self.assertRaises(jwt.ExpiredSignature, manager.get_profile, token)
예제 #4
0
 def get_token_for(self, resource_path, username, filesize=None):
     """Generates a token with the brl_user and additional data dict if needed"""
     # By now username field will be used only for trace support. Its not necessary
     # for security, if you have a token you are already authenticated
     return JWTManager.get_token_for(
         self, {
             "resource_path": resource_path,
             "username": username,
             "filesize": filesize
         })
예제 #5
0
 def get_token_for(self, brl_user):
     """Generates a token with the brl_user and additional data dict if needed"""
     return JWTManager.get_token_for(self, {"user": brl_user})
예제 #6
0
 def get_token_for(self, brl_user):
     """Generates a token with the brl_user and additional data dict if needed"""
     return JWTManager.get_token_for(self, {"user": brl_user})