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

make cryptography dep required #7692

Merged
merged 2 commits into from
Jan 7, 2021
Merged

make cryptography dep required #7692

merged 2 commits into from
Jan 7, 2021

Conversation

wochinge
Copy link
Contributor

@wochinge wochinge commented Jan 7, 2021

Proposed changes:

  • cryptography wasn't part of our Docker images which caused the validation of JWT tokens to fail
  • upgrading PyJWT to it's latest version
  • fixes this error when using Rasa X
2021-01-07T14:41:05.1125275Z �[36mrasa-x_1            |�[0m [2021-01-07 14:41:05 +0000] - (sanic.access)[INFO][172.18.0.12:55370]: GET http://rasa-x:5002/api/version  200 616
2021-01-07T14:41:05.2506098Z �[35;1mrasa-production_1   |�[0m 2021-01-07 14:41:05 ERROR    rasa.core.channels.rasa_chat  - Failed to decode bearer token.
2021-01-07T14:41:05.2509294Z �[35;1mrasa-production_1   |�[0m Traceback (most recent call last):
2021-01-07T14:41:05.2510788Z �[35;1mrasa-production_1   |�[0m   File "/opt/venv/lib/python3.7/site-packages/jwt/api_jws.py", line 219, in _verify_signature
2021-01-07T14:41:05.2512030Z �[35;1mrasa-production_1   |�[0m     alg_obj = self._algorithms[alg]
2021-01-07T14:41:05.2513002Z �[35;1mrasa-production_1   |�[0m KeyError: 'RS256'
2021-01-07T14:41:05.2513856Z �[35;1mrasa-production_1   |�[0m 
2021-01-07T14:41:05.2514948Z �[35;1mrasa-production_1   |�[0m During handling of the above exception, another exception occurred:
2021-01-07T14:41:05.2516000Z �[35;1mrasa-production_1   |�[0m 
2021-01-07T14:41:05.2517064Z �[35;1mrasa-production_1   |�[0m Traceback (most recent call last):
2021-01-07T14:41:05.2518399Z �[35;1mrasa-production_1   |�[0m   File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/rasa_chat.py", line 87, in _decode_bearer_token
2021-01-07T14:41:05.2527537Z �[35;1mrasa-production_1   |�[0m     return self._decode_jwt(bearer_token)
2021-01-07T14:41:05.2529501Z �[35;1mrasa-production_1   |�[0m   File "/opt/venv/lib/python3.7/site-packages/rasa/core/channels/rasa_chat.py", line 78, in _decode_jwt
2021-01-07T14:41:05.2530977Z �[35;1mrasa-production_1   |�[0m     authorization_header_value, self.jwt_key, algorithms=self.jwt_algorithm
2021-01-07T14:41:05.2532364Z �[35;1mrasa-production_1   |�[0m   File "/opt/venv/lib/python3.7/site-packages/jwt/api_jwt.py", line 92, in decode
2021-01-07T14:41:05.2534033Z �[35;1mrasa-production_1   |�[0m     jwt, key=key, algorithms=algorithms, options=options, **kwargs
2021-01-07T14:41:05.2535302Z �[35;1mrasa-production_1   |�[0m   File "/opt/venv/lib/python3.7/site-packages/jwt/api_jws.py", line 156, in decode
2021-01-07T14:41:05.2536294Z �[35;1mrasa-production_1   |�[0m     key, algorithms)
2021-01-07T14:41:05.2537604Z �[35;1mrasa-production_1   |�[0m   File "/opt/venv/lib/python3.7/site-packages/jwt/api_jws.py", line 226, in _verify_signature
2021-01-07T14:41:05.2538855Z �[35;1mrasa-production_1   |�[0m     raise InvalidAlgorithmError('Algorithm not supported')
2021-01-07T14:41:05.2540206Z �[35;1mrasa-production_1   |�[0m jwt.exceptions.InvalidAlgorithmError: Algorithm not supported

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@wochinge wochinge mentioned this pull request Jan 7, 2021
4 tasks
@wochinge wochinge requested review from alwx and mprazz January 7, 2021 17:56
@wochinge wochinge merged commit e377d53 into 2.2.x Jan 7, 2021
@wochinge wochinge deleted the make-cryptography-required branch January 7, 2021 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants