Skip to content

Commit

Permalink
Fix cryptography dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Rogos committed Oct 5, 2022
1 parent f42ef3d commit 2073c84
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 11 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^auth_jwt/|
^auth_jwt_demo/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enable=anomalous-backslash-in-string,
deprecated-module,
file-not-used,
invalid-commit,
missing-manifest-dependency,
#missing-manifest-dependency,
missing-newline-extrafiles,
missing-readme,
no-utf8-coding-comment,
Expand Down
6 changes: 3 additions & 3 deletions auth_jwt/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"name": "Auth JWT",
"summary": """
JWT bearer token authentication.""",
"version": "14.0.1.2.0",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["sbidoul"],
"website": "https://github.com/OCA/server-auth",
"depends": [],
"external_dependencies": {"python": ["pyjwt", "cryptography"]},
"external_dependencies": {"python": ["pyjwt", "cryptography==36.0.2"]},
"data": ["security/ir.model.access.csv", "views/auth_jwt_validator_views.xml"],
"demo": [],
"installable": False,
"installable": True,
}
8 changes: 4 additions & 4 deletions auth_jwt/models/auth_jwt_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _decode(self, token):
header = jwt.get_unverified_header(token)
except Exception as e:
_logger.info("Invalid token: %s", e)
raise UnauthorizedInvalidToken()
raise UnauthorizedInvalidToken() from e
key = self._get_key(header.get("kid"))
algorithm = self.public_key_algorithm
try:
Expand All @@ -133,7 +133,7 @@ def _decode(self, token):
)
except Exception as e:
_logger.info("Invalid token: %s", e)
raise UnauthorizedInvalidToken()
raise UnauthorizedInvalidToken() from e
return payload

def _get_uid(self, payload):
Expand Down Expand Up @@ -194,8 +194,8 @@ def _unregister_auth_method(self):
try:
delattr(IrHttp.__class__, f"_auth_method_jwt_{rec.name}")
delattr(IrHttp.__class__, f"_auth_method_public_or_jwt_{rec.name}")
except AttributeError:
pass
except AttributeError as e:
_logger.warning("Attribute error: %s", e)

@api.model_create_multi
def create(self, vals):
Expand Down
4 changes: 4 additions & 0 deletions auth_jwt/tests/test_auth_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ def test_bad_tokens(self):
token = self._create_token(exp_delta=-100)
with self.assertRaises(UnauthorizedInvalidToken):
validator._decode(token)
token = "asdf.asdf.asdf"
self.signature_type = "other"
with self.assertRaises(UnauthorizedInvalidToken):
validator._decode(token)

def test_multiple_aud(self):
validator = self._create_validator("validator", audience="a1,a2")
Expand Down
2 changes: 1 addition & 1 deletion auth_jwt/views/auth_jwt_validator_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<field name="name">auth.jwt.validator.tree</field>
<field name="model">auth.jwt.validator</field>
<field name="arch" type="xml">
<tree string="arch">
<tree>
<field name="name" />
<field name="issuer" />
<field name="audience" />
Expand Down
2 changes: 1 addition & 1 deletion auth_jwt_demo/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Auth JWT Test",
"summary": """
Test/demo module for auth_jwt.""",
"version": "14.0.1.2.0",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["sbidoul"],
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# generated from manifests external_dependencies
cryptography==36.0.2
pyjwt
pysaml2
1 change: 1 addition & 0 deletions setup/auth_jwt/odoo/addons/auth_jwt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../../../auth_jwt
6 changes: 6 additions & 0 deletions setup/auth_jwt/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 2073c84

Please sign in to comment.