Skip to content

Commit 2cf7b7a

Browse files
committed
- fix github linting action
- added tox for local testing - fix github linting action
1 parent cd51e4d commit 2cf7b7a

File tree

8 files changed

+200
-63
lines changed

8 files changed

+200
-63
lines changed

.github/actions/lint/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Linting"
2+
runs:
3+
using: "composite"
4+
steps:
5+
- uses: actions/[email protected]
6+
7+
- name: Set up Python 3.9
8+
uses: actions/[email protected]
9+
with:
10+
python-version: "3.9"
11+
12+
- name: pre-commit
13+
uses: pre-commit/[email protected]

.github/workflows/lint.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ on:
1010
- master
1111

1212
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out repository
17+
uses: actions/[email protected]
18+
19+
- uses: ./.github/actions/lint
20+
1321
tests:
1422
name: Python ${{ matrix.python-version }}
1523
runs-on: ubuntu-latest
@@ -24,9 +32,9 @@ jobs:
2432
- "3.13"
2533

2634
steps:
27-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v4.2.2
2836

29-
- uses: actions/setup-python@v5
37+
- uses: actions/setup-python@v5.3.0
3038
with:
3139
python-version: ${{ matrix.python-version }}
3240

django_cryptography/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def configure_salt(self, value: Any) -> bytes:
2020
return force_bytes(value)
2121

2222
def configure(self) -> Dict[str, Any]:
23-
digest = self.configured_data["DIGEST"]()
23+
digest = self.configured_data["DIGEST"]
2424
salt = self.configured_data["SALT"]
2525
# Key Derivation Function
2626
kdf = pbkdf2.PBKDF2HMAC(

django_cryptography/core/signing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ def signature(self, value: Union[bytes, str]) -> bytes:
282282
h = HMAC(
283283
force_bytes(self.key),
284284
self.hasher,
285-
backend=settings.CRYPTOGRAPHY_BACKEND, # type: ignore
286285
)
287286
h.update(force_bytes(value))
288287
return h.finalize()

django_cryptography/utils/crypto.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ def salted_hmac(
7575

7676
# We need to generate a derived key from our base key. We can do this by
7777
# passing the key_salt and our base key through a pseudo-random function.
78-
digest = hashes.Hash(hasher, backend=settings.CRYPTOGRAPHY_BACKEND)
78+
digest = hashes.Hash(hasher)
7979
digest.update(key_salt + secret)
8080
key = digest.finalize()
8181

8282
# If len(key_salt + secret) > sha_constructor().block_size, the above
8383
# line is redundant and could be replaced by key = key_salt + secret, since
8484
# the hmac module does the same thing for keys longer than the block size.
8585
# However, we need to ensure that we *always* do this.
86-
h = HMAC(key, hasher, backend=settings.CRYPTOGRAPHY_BACKEND)
86+
h = HMAC(key, hasher)
8787
h.update(force_bytes(value))
8888
return h
8989

@@ -113,7 +113,7 @@ def pbkdf2(
113113
password = force_bytes(password)
114114
salt = force_bytes(salt)
115115
kdf = PBKDF2HMAC(
116-
digest, dklen, salt, iterations, backend=settings.CRYPTOGRAPHY_BACKEND
116+
digest, dklen, salt, iterations
117117
)
118118
return kdf.derive(password)
119119

@@ -150,7 +150,6 @@ def _encrypt_from_parts(self, data: bytes, current_time: int, iv: bytes) -> byte
150150
encryptor = Cipher(
151151
algorithms.AES(force_bytes(self.key)),
152152
modes.CBC(iv),
153-
backend=settings.CRYPTOGRAPHY_BACKEND,
154153
).encryptor()
155154
ciphertext = encryptor.update(padded_data) + encryptor.finalize()
156155

@@ -164,7 +163,6 @@ def decrypt(self, data: bytes, ttl: Optional[int] = None) -> bytes:
164163
decryptor = Cipher(
165164
algorithms.AES(force_bytes(self.key)),
166165
modes.CBC(iv),
167-
backend=settings.CRYPTOGRAPHY_BACKEND,
168166
).decryptor()
169167
plaintext_padded = decryptor.update(ciphertext)
170168
try:

poetry.lock

Lines changed: 169 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)