Skip to content

Commit eb12643

Browse files
authored
Merge branch 'devel' into to_debug
2 parents 79d61f6 + 27d2bf4 commit eb12643

File tree

6 files changed

+555
-6
lines changed

6 files changed

+555
-6
lines changed

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

0 commit comments

Comments
 (0)