Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible pyjwt #960

Closed
mssalvatore opened this issue Feb 4, 2021 · 4 comments
Closed

Incompatible pyjwt #960

mssalvatore opened this issue Feb 4, 2021 · 4 comments
Labels
Beginner friendly New to the project? This issue is good for you! Bug An error, flaw, misbehavior or failure in the Monkey or Monkey Island. Complexity: Low Help wanted Impact: Medium

Comments

@mssalvatore
Copy link
Collaborator

Describe the bug

Monkey Island is not compatible with the latest version of pyjwt. monkey/monkey_island/requirements.txt specifies pyjwt>=1.5.1. When a pyjwt > 1.7 is installed, the following error occurrs:

2021-01-19 18:17:32,559 - app.py:1892 - log_exception() - ERROR - Exception on /api/auth [POST]
Traceback (most recent call last):
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/msalvatore/save.infection_monkey/monkey/monkey_island/cc/resources/auth/auth.py", line 49, in post
    access_token = flask_jwt_extended.create_access_token(identity=user_store.UserStore.username_table[username].id)
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask_jwt_extended/utils.py", line 173, in create_access_token
    headers=headers)
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask_jwt_extended/jwt_manager.py", line 522, in _create_access_token
    headers=headers
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask_jwt_extended/tokens.py", line 77, in encode_access_token
    json_encoder=json_encoder, headers=headers)
  File "/home/msalvatore/.local/lib/python3.7/site-packages/flask_jwt_extended/tokens.py", line 30, in _encode_jwt
    json_encoder=json_encoder, headers=headers).decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

To Reproduce

Steps to reproduce the behavior:

  1. Use the deployment scripts to deploy Monkey Island in a fresh environment
  2. Start Monkey island

Expected behavior

I expect Monkey Island not to raise exceptions

Possible Solutions

  1. Update all code that uses pyjwt to be compatible with the latest version, update requirements.txt accordingly (PREFERRED)
  2. Pin pyjwt to version 1.7 in requirements.txt (DISCOURAGED)

Machine version (please complete the following information):

  • OS: Linux
@mssalvatore mssalvatore added Bug An error, flaw, misbehavior or failure in the Monkey or Monkey Island. Help wanted Beginner friendly New to the project? This issue is good for you! Impact: Medium Complexity: Low labels Feb 4, 2021
@VakarisZ
Copy link
Contributor

What solved it for me was updating Flask-JWT-Extended to the latest. Sanity tests passed.

@mssalvatore
Copy link
Collaborator Author

4.0.2?

@VakarisZ
Copy link
Contributor

Yes

@mssalvatore
Copy link
Collaborator Author

resolved by ed589bd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Beginner friendly New to the project? This issue is good for you! Bug An error, flaw, misbehavior or failure in the Monkey or Monkey Island. Complexity: Low Help wanted Impact: Medium
Projects
None yet
Development

No branches or pull requests

2 participants