Skip to content

Commit bcdc4fa

Browse files
committed
fix: bring back python 3.10 support
1 parent 256a7ea commit bcdc4fa

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ There are two methods of 2FA available:
1111

1212
## Requirements
1313

14-
Python 3.11+
14+
Python 3.10+
1515

1616
This extension uses __Redis__, so it must be configured for CKAN.
1717

ckanext/auth/model.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from __future__ import annotations
22

33
import logging
4-
from datetime import UTC
54
from datetime import datetime as dt
6-
from typing import Self, cast
5+
from datetime import timezone as tz
6+
7+
try:
8+
from typing import Self, cast
9+
except ImportError:
10+
from typing_extensions import Self, cast
711

812
import pyotp
913
from sqlalchemy import DateTime, ForeignKey, Text
@@ -118,7 +122,7 @@ def check_code(self, code: str, verify_only: bool = False) -> bool:
118122
if is_totp_enabled and self.last_access and totp.at(cast(dt, self.last_access)) == code:
119123
raise ReplayAttackError("The code has already been used")
120124

121-
self.last_access = dt.now(UTC)
125+
self.last_access = dt.now(tz.utc)
122126
model.Session.commit()
123127
else:
124128
log.debug("2FA: Failed to verify the totp code for user %s", self.user_id)

ckanext/auth/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import logging
44
from datetime import timedelta
5-
from typing import NotRequired, TypedDict, cast
5+
6+
try:
7+
from typing import NotRequired, TypedDict, cast
8+
except ImportError:
9+
from typing_extensions import NotRequired, TypedDict, cast
610

711
import ckan.lib.mailer as ckan_mailer
812
import ckan.plugins as p

ckanext/auth/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _setup_totp_extra_vars(self, user_id: str) -> dict[str, Any]:
9494

9595
test_code = cast(str, data_dict.get("code"))
9696

97-
extra_vars: dict[str, Any]= {
97+
extra_vars: dict[str, Any] = {
9898
"totp_secret": user_secret.secret,
9999
"provisioning_uri": user_secret.provisioning_uri,
100100
}

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ckanext-auth"
7-
version = "0.4.2"
7+
version = "0.4.3"
88
description = "2FA authentication for CKAN"
99
authors = [
1010
{name = "DataShades", email = "datashades@linkdigital.com.au"},
@@ -17,6 +17,7 @@ license = {text = "AGPL"}
1717
classifiers = [
1818
"Development Status :: 4 - Beta",
1919
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
20+
"Programming Language :: Python :: 3.10",
2021
"Programming Language :: Python :: 3.11",
2122
"Programming Language :: Python :: 3.12",
2223
"Programming Language :: Python :: 3.13",
@@ -51,7 +52,7 @@ addopts = "--ckan-ini test.ini"
5152
extraPaths = [
5253
"../ckan",
5354
]
54-
pythonVersion = "3.11"
55+
pythonVersion = "3.10"
5556
include = ["ckanext"]
5657
strict = []
5758

@@ -123,7 +124,7 @@ reportExplicitAny = false
123124

124125

125126
[tool.ruff]
126-
target-version = "py311"
127+
target-version = "py310"
127128
line-length = 120
128129

129130
[tool.ruff.lint]

0 commit comments

Comments
 (0)