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})
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)
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 })
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})