Skip to content

Commit 91957c5

Browse files
authored
Merge branch 'devel' into root_logger
2 parents ba37c4d + 2cf0b5b commit 91957c5

File tree

9 files changed

+633
-17
lines changed

9 files changed

+633
-17
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ env:
77
on:
88
workflow_dispatch:
99

10+
env:
11+
PROJECT_NAME: django-ansible-base
12+
1013
jobs:
11-
stage:
14+
build:
1215
runs-on: ubuntu-latest
13-
timeout-minutes: 90
14-
permissions:
15-
packages: write
16-
contents: write
16+
timeout-minutes: 2
1717
steps:
1818
- name: Checkout dab
1919
uses: actions/checkout@v4
@@ -24,12 +24,80 @@ jobs:
2424
run: echo py_version=`make PYTHON_VERSION` >> $GITHUB_ENV
2525

2626
- name: Install python ${{ env.py_version }}
27-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2828
with:
2929
python-version: ${{ env.py_version }}
3030

31-
- name: Install python deeps
31+
- name: Install python deps
3232
run: pip install -r requirements/requirements_dev.txt
3333

34-
- name: Create release
35-
run: ansible-playbook tools/ansible/release.yml -i localhost -e github_token=${{ secrets.GITHUB_TOKEN }}
34+
- name: Build the dists
35+
run: >-
36+
ansible-playbook
37+
tools/ansible/release.yml
38+
-i localhost
39+
-e github_token=${{ secrets.GITHUB_TOKEN }}
40+
-t build
41+
42+
- name: Store the distribution packages
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: python-package-distributions
46+
path: |
47+
dist/*.tar.gz
48+
dist/*.whl
49+
retention-days: 90
50+
51+
publish-pypi:
52+
name: Publish to PyPI
53+
needs:
54+
- build
55+
56+
runs-on: ubuntu-latest
57+
58+
timeout-minutes: 1
59+
60+
environment:
61+
name: pypi
62+
url: https://pypi.org/project/${{ env.PROJECT_NAME }}
63+
64+
permissions:
65+
contents: read # This job doesn't need to `git push` anything
66+
id-token: write # PyPI Trusted Publishing (OIDC)
67+
68+
steps:
69+
- name: Download all the dists
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: python-package-distributions
73+
path: dist/
74+
- name: Publish dists to PyPI
75+
uses: pypa/gh-action-pypi-publish@release/v1
76+
77+
post-release-repo-update:
78+
name: Make a GitHub Release
79+
needs:
80+
- publish-pypi
81+
82+
runs-on: ubuntu-latest
83+
84+
timeout-minutes: 2
85+
86+
permissions:
87+
packages: write
88+
contents: write
89+
90+
steps:
91+
- name: Download all the dists
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: python-package-distributions
95+
path: dist/
96+
97+
- name: Create a GitHub Release uploading the dists
98+
run: >-
99+
ansible-playbook
100+
tools/ansible/release.yml
101+
-i localhost
102+
-e github_token=${{ secrets.GITHUB_TOKEN }}
103+
-t github

ansible_base/authentication/authenticator_plugins/google_oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ansible_base.authentication.social_auth import SocialAuthMixin, SocialAuthValidateCallbackMixin
88
from ansible_base.lib.serializers.fields import BooleanField, CharField, ChoiceField, ListField, URLField
99

10-
logger = logging.getLogger('ansible_base.authentication.authenticator_plugins.oidc')
10+
logger = logging.getLogger('ansible_base.authentication.authenticator_plugins.google_oauth2')
1111

1212

1313
class GoogleOAuth2Configuration(BaseAuthenticatorConfiguration):

ansible_base/jwt_consumer/common/util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ def validate_x_trusted_proxy_header(header_value: str, ignore_cache=False) -> bo
4242
logger.warning("Failed to validate x-trusted-proxy-header, malformed, expected value to contain a -")
4343
return False
4444

45+
try:
46+
signature_bytes = bytes.fromhex(signature)
47+
except ValueError:
48+
logger.warning("Failed to validate x-trusted-proxy-header, malformed, expected signature to well-formed base64")
49+
return False
50+
4551
try:
4652
public_key.verify(
47-
bytes.fromhex(signature),
53+
signature_bytes,
4854
bytes(f'{_SHARED_SECRET}-{timestamp}', 'utf-8'),
4955
padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.MAX_LENGTH),
5056
hashes.SHA256(),

ansible_base/lib/cache/fallback_cache.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99
from django.core import cache as django_cache
1010
from django.core.cache.backends.base import BaseCache
1111

12+
from ansible_base.lib.utils.settings import get_setting
13+
1214
logger = logging.getLogger('ansible_base.cache.fallback_cache')
1315

1416
DEFAULT_TIMEOUT = None
1517
PRIMARY_CACHE = 'primary'
1618
FALLBACK_CACHE = 'fallback'
1719

18-
_temp_file = Path().joinpath(tempfile.gettempdir(), 'gw_primary_cache_failed')
20+
_temp_path = get_setting('ANSIBLE_BASE_FALLBACK_CACHE_FILE_PATH', tempfile.gettempdir())
21+
_temp_file = Path().joinpath(_temp_path, 'gw_primary_cache_failed')
22+
23+
24+
def create_temp_file():
25+
_temp_file.touch()
26+
_temp_file.chmod(mode=0o660)
1927

2028

2129
class DABCacheWithFallback(BaseCache):
@@ -77,7 +85,7 @@ def _op_with_fallback(self, operation, *args, **kwargs):
7785
time.sleep(random.uniform(10, 100) / 100.0)
7886
if not _temp_file.exists():
7987
logger.error("Primary cache unavailable, switching to fallback cache.")
80-
_temp_file.touch()
88+
create_temp_file()
8189
response = getattr(self._fallback_cache, operation)(*args, **kwargs)
8290

8391
return response

ansible_base/resource_registry/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def proxies_of_model(cls):
103103
def _should_reverse_sync():
104104
enabled = getattr(settings, 'RESOURCE_SERVER_SYNC_ENABLED', False)
105105
if enabled and (not resource_server_defined()):
106-
logger.error("RESOURCE_SERVER is not configured. Reverse sync will not be enabled.")
106+
logger.debug("RESOURCE_SERVER is not configured. Reverse sync will not be enabled.")
107107
enabled = False
108108
if enabled and resource_server_defined() and ('SECRET_KEY' not in settings.RESOURCE_SERVER or not settings.RESOURCE_SERVER['SECRET_KEY']):
109109
logger.error("RESOURCE_SERVER['SECRET_KEY'] is not configured. Reverse sync will not be enabled.")

0 commit comments

Comments
 (0)