Esempio n. 1
0
 def get(self):
     # jti is JWT ID
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return {
         'message': 'Successfully logged out'
     }, 200
Esempio n. 2
0
    def post(self):
        # Big idea is to blacklist the unique id of a user's access token so that he can't use the same
        # token to log back in since it'll be in the blacklist
        jti = get_raw_jwt()['jti']
        BLACKLIST.add(jti)

        return "Successfully logged out.", 200
 def post(self):
     # 'logout' == 'invoke' == 'blacklist (only) token (not user_id)'
     # Note: each token has unique id of token call JWT_ID (jti)
     # All we have to do is blacklist jti
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return {'msg': 'Logout successfully.'}
 def post(self):
     jti = get_raw_jwt()["jti"]
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {
         "message": "User <id={}> successfully logged out.".format(user_id)
     }, 200
Esempio n. 5
0
 def post(self):
     # jti = 'JWT Id', a unique identifier for a JWT.
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return {
         'message': 'Successfully logged out!'
     }, 200
Esempio n. 6
0
    def post(cls):
        jti = get_raw_jwt()[
            "jti"]  # jti is "JWT ID", a unique identifier for a JWT.
        user_id = get_jwt_identity()

        BLACKLIST.add(jti)
        return max_res(USER_LOGGED_OUT.format(user_id=user_id))
Esempio n. 7
0
 def post(self):
     # This uses the get_raw_jwt(), function of Flask-JWT-Extended.
     # It gives us a dictionary of the various properties stored inside the decoded JWT.
     jti = get_raw_jwt()[
         'jti']  # jti is a unique id for a JWT(not for the user!)
     BLACKLIST.add(jti)
     return {'message': 'Successfully logged out.'}, 200
 def post(self):
     jti = get_raw_jwt()[
         'jti']  #jti is 'JW IDD' , a unique identifier for a JWT.
     BLACKLIST.add(
         jti
     )  #blackliste ekleyerek çıkış yapıltıkdan sonra bu jwt yi artık geçersiz sayıyoruz
     return {'message': 'Successfully logged out.'}, 200
Esempio n. 9
0
 def post(self):
     # Every time a user logs in an unique 'JWT ID' is created.
     # In order to logout the user we need to blacklist this id and not the
     # 'USER ID', otherwise they wouldn't be able to login again.
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return {'message': 'Successfully logged out.'}, 200
 def post(cls):
     """
     User Logout blacklist's the "jti" which restricts the access.
     """
     jti = get_raw_jwt()["jti"]
     BLACKLIST.add(jti)
     return {"msg": USER_LOGGED_OUT}, 200
Esempio n. 11
0
 def post(cls):
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     user = UserModel.find_by_id(get_jwt_identity())
     return {
         'message': gettext("user_logged_out").format(user.username)
     }, 200
Esempio n. 12
0
    def post(self):
        """Logout and expired token
        @@@

        #### input(Add Authorization to header)
        ```
        {
        "username":"******",
        "password":"******"
        }

        ```

        #### output:
        ```
        {
            "message": "Successfully logged out"
        }
        ```
        @@@
        """
        jti = get_raw_jwt()[
            'jti']  # jti stands fro 'JWT ID' a unique identifier for a JWT
        BLACKLIST.add(jti)
        return {'message': 'Successfully logged out'}, 200
Esempio n. 13
0
 def post(self):
     # blacklist current token, and force user to get a new token by logining-in
     # every token has a unique ID == jti
     jti = get_raw_jwt()[
         'jti']  # jti is "JWT ID", a unique identifier for a JWT.
     BLACKLIST.add(jti)
     return {"message": "Succesfully logged out."}, 200
Esempio n. 14
0
 def post(cls):
     jti = get_raw_jwt()[
         "jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {
         "message": MESSAGES['USER_LOGGED_OUT'].format(user_id=user_id)
     }, 200
Esempio n. 15
0
 def post(cls):
     try:
         jwt_id = get_raw_jwt()["jti"]
         user_id = get_jwt_identity()
         BLACKLIST.add(jwt_id)
         return {"message": gettext("user_logged_out")}, 200
     except:
         return {"message": gettext("user_error_logging_out")}, 500
Esempio n. 16
0
 def get(self):
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return make_response(
         jsonify({
             'message':
             'Logged out (Refresh token revoked) successfully!'
         }), 200)
Esempio n. 17
0
 def post(self):
     jti = get_jwt()[
         "jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {
         "message": "User <id={}> successfully logged out.".format(user_id)
     }, 200
Esempio n. 18
0
    def get(self):
        user_id = get_jwt_identity()
        #print(user_id)
        jti = get_raw_jwt()['jti']
        # jti is "JWT ID", a unique identyfier for a JWT
        BLACKLIST.add(jti)

        return redirect('/')
Esempio n. 19
0
 def post(cls):
     jti = get_raw_jwt()[
         "jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {
         "message": f"User <id={user_id}> successfully logged out."
     }, 200
    def post(self) -> tuple:
        """
        Logouts the user from app.
        """
        jti = get_raw_jwt()['jti']
        BLACKLIST.add(jti)

        return {'message': 'Successfully logged out.'}, 200
Esempio n. 21
0
 def post(cls):
     jti = get_raw_jwt()[
         "jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     resp = make_response(redirect(f"/logout/{user_id}", code=200))
     unset_jwt_cookies(resp)
     return resp
Esempio n. 22
0
 def post(cls):
     jti = get_raw_jwt()[
         "jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {
         "success": True,
         "message": USER_LOGGED_OUT.format(user_id)
     }, 200
Esempio n. 23
0
 def delete(cls):
     jwt_id = get_jwt_identity()
     user = UserModel.find_by_id(jwt_id)
     if not user:
         return {"message": gettext("user_not_found")}, 404
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     user.delete_from_db()
     return {"message": gettext("user_deleted").format(user.username)}, 200
Esempio n. 24
0
 def post(
     self
 ):  # to logout you just blacklist their login jwt_token making it non usable again,to get a new token they have to login,essentially logging out
     jti = get_raw_jwt(
     )['jti']  # blacklist the id for the token, which is unique for each token i.e the jti(JWT ID)
     BLACKLIST.add(jti)
     return {
         'message': "Successfully logged out. Login for continued services"
     }, 200
Esempio n. 25
0
    def post(self):
        # this will later change to accommodate multiple users simultaneously from one enterprise account
        current_user_id = get_jwt_identity()
        if unload_databook(current_user_id, "all"):
            del loaded_databooks[current_user_id]

        jti = get_raw_jwt()["jti"]
        BLACKLIST.add(jti)
        return {"login": False}, 200
Esempio n. 26
0
 def get(self):
     """ User Logout """
     # JWT ID will be blacklisted once user logout
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return make_response(
         jsonify(
             {'message':
              'Logged out (Access token revoked) successfully!'}), 200)
Esempio n. 27
0
    def post(self):
        """
        Realizar Logout para revogar Token de acesso.
        """

        jwt_id = get_raw_jwt()["jti"]
        BLACKLIST.add(jwt_id)

        return jsonify({"message": "Logout realizado com sucesso!"}), 200
Esempio n. 28
0
 def post(cls):
     jti = get_raw_jwt()['jti']
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {
         "message":
         _USER_LOGGED_OUT.format(
             UserModel.find_by_id(user_id).get_full_name())
     }, 200
Esempio n. 29
0
    def post(self):
        # Want to blacklist the jwt that the user has sent us

        # Get unique identifier for the access token, which
        # they all have (nothing to do with the particular user)
        # jti = jwt identifier
        jti = get_raw_jwt()['jti']
        BLACKLIST.add(jti)
        return {'message': 'Successfully logged out.'}, 200
Esempio n. 30
0
 def delete(cls):
     user = UserModel.find_by_id(get_jwt_identity())
     logger.info(user)
     if not user:
         return {"message": "User not found."}, constant.CODE_NOT_FOUND
     user.delete_from_db()
     jti = get_raw_jwt()["jti"]
     BLACKLIST.add(jti)
     return {"message": "User deleted successfully."}, constant.CODE_OK
 def post(self):
     jti = get_raw_jwt()['jti']  # jti is "JWT ID", a unique identifier for a JWT.
     BLACKLIST.add(jti)
     return {"message": "Successfully logged out"}, 200
Esempio n. 32
0
 def post(self):
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return {"message": "Successfully logged out"}, 200