Skip to content

Commit f537d4f

Browse files
committed
update altcha
1 parent 3684d33 commit f537d4f

5 files changed

Lines changed: 35 additions & 18 deletions

File tree

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Each line is a pattern followed by one or more owners
33

44
# Default owners for the entire repository
5-
* @gmelikov @phantomii @akremenetsky @slashburygin
5+
* @exordos/code_owners

exordos_core/tests/functional/restapi/iam/test_user_creation_security.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1+
# Copyright 2026 Genesis Corporation.
2+
#
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
117
import json
2-
import sys
18+
import time
319
from unittest import mock
420
from urllib.parse import urljoin
521

22+
import altcha
623
from gcl_iam.tests.functional import clients as iam_clients
7-
import pytest
824
import requests
925

1026
from exordos_core.tests.functional.restapi.iam import base
1127
from exordos_core.user_api.security.dm import models as security_models
1228

13-
pytestmark = pytest.mark.skipif(
14-
sys.version_info < (3, 9),
15-
reason="altcha 0.2.x in security actions require Python 3.9+",
16-
)
17-
1829
CREATE_USER_PATH = "iam/users/"
1930

2031

@@ -154,7 +165,14 @@ def test_create_user_firebase_or_captcha_or_admin_bypass(
154165

155166
# altcha is imported inside action, so patch its global function
156167
with mock.patch("altcha.verify_solution") as mock_verify_solution:
157-
mock_verify_solution.return_value = (True, None)
168+
mock_verify_solution.return_value = altcha.VerifySolutionResult(
169+
expired=False,
170+
invalid_signature=None,
171+
invalid_solution=None,
172+
time=time.time(),
173+
verified=True,
174+
error=None,
175+
)
158176
headers = {
159177
"Authorization": f"Bearer {admin_token}",
160178
"X-Captcha": captcha_payload,

exordos_core/user_api/security/dm/models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,11 @@ def execute(self, context):
214214
LOG.exception("Failed to parse CAPTCHA payload.")
215215
return False
216216

217-
verified, _error = altcha.verify_solution(
217+
result = altcha.verify_solution(
218218
payload,
219-
hmac_key=self.hmac_key,
220-
check_expires=True,
219+
hmac_secret=self.hmac_key,
221220
)
222-
return bool(verified)
221+
return result.verified
223222

224223

225224
class AdminBypassVerifier(AbstractVerifier):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"netaddr>=1.3.0,<2.0.0", # BSD License (BSD License)
3737
"cryptography>=45.0.5,<47.0.0", # BSD-3
3838
"firebase-admin>=6.0.0,<7.0.0", # Apache-2.0
39-
"altcha>=0.2.0,<0.3.0", # MIT License
39+
"altcha>=0.2.0,<2.1.0", # MIT License
4040
"openapi-schema-validator>=0.8.1", # BSD-3
4141
]
4242
[project.urls]

uv.lock

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

0 commit comments

Comments
 (0)