Skip to content

Commit 8039edc

Browse files
authored
Merge branch 'devel' into shared_middleware_with_trace_sql
2 parents a75d399 + f674f41 commit 8039edc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3328
-713
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Run tox
5454
run: |
5555
echo "::remove-matcher owner=python::" # Disable annoying annotations from setup-python
56-
tox -e ${{ matrix.tests.env }}
56+
tox --colored yes -e ${{ matrix.tests.env }}
5757
5858
- name: Inject PR number into coverage.xml
5959
if: matrix.tests.sonar

ansible_base/authentication/authenticator_plugins/azuread.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ class AzureADConfiguration(BaseAuthenticatorConfiguration):
4141
help_text=_("The JSON key used to extract the user's groups from the ID token or userinfo endpoint."),
4242
required=False,
4343
allow_null=False,
44-
default="Group",
44+
default="groups",
4545
ui_field_label=_("Groups Claim"),
4646
)
4747

4848
USERNAME_FIELD = CharField(
4949
help_text=_("The name of the field from the assertion to use as the username. If not set will default to name"),
5050
required=False,
5151
allow_null=True,
52-
default=None,
5352
ui_field_label=_("Field to use as username"),
5453
)
5554

ansible_base/authentication/authenticator_plugins/ldap.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import inspect
22
import logging
3-
import re
43
from collections import OrderedDict
54
from typing import Any
65

@@ -248,11 +247,6 @@ def validate_ldap_filter(value: Any, with_user: bool = False) -> None:
248247

249248
dn_value = value.replace(user_search_string, 'USER')
250249

251-
# Check if this is an and/or filter with multiple subfilters
252-
if re.match(r'^\([&|!]\(.*?\)\)$', dn_value):
253-
for sub_filter in dn_value[3:-2].split(')('):
254-
# We only need to check with_user at the top of the recursion stack
255-
validate_ldap_filter(f'({sub_filter})', with_user=False)
256250
try:
257251
Filter.parse(dn_value)
258252
except ParseError:

ansible_base/authentication/authenticator_plugins/oidc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class OpenIdConnectConfiguration(BaseAuthenticatorConfiguration):
124124

125125
JWT_ALGORITHMS = ListField(
126126
help_text=_("The algorithm(s) for decoding JWT responses from the IDP."),
127-
default=None,
127+
default=OpenIdConnectAuth.JWT_ALGORITHMS,
128128
allow_null=True,
129129
validators=[JWTAlgorithmListFieldValidator()],
130130
ui_field_label=_('OIDC JWT Algorithm(s)'),

ansible_base/authentication/authenticator_plugins/saml.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ def validate(self, attrs):
208208
raise ValidationError(_("Failed to load config: %(e)s") % {"e": e})
209209

210210
if invalid_security_settings:
211-
raise ValidationError({'SECURITY_CONFIG': _("Invalid keys:) {', '.join(invalid_security_settings)}")})
211+
raise ValidationError(
212+
{
213+
'SECURITY_CONFIG': _("Invalid keys: %(keys)s, Valid keys: %(valid_keys)s")
214+
% {"keys": ', '.join(sorted(invalid_security_settings)), "valid_keys": ', '.join(sorted(valid_security_settings))}
215+
}
216+
)
212217

213218
response = super().validate(attrs)
214219
return response
@@ -289,9 +294,21 @@ def extra_data(self, user, backend, response, *args, **kwargs):
289294
if perm in attrs:
290295
kwargs["social"].extra_data[perm] = attrs[perm]
291296

292-
# Move group spec up a level if present
293-
if "Group" in attrs:
294-
response["Group"] = attrs["Group"]
297+
# Get configured group attribute, if present
298+
configuration = getattr(self.database_instance, 'configuration', {})
299+
idp_groups_attribute_name = self.configuration_class.settings_to_enabled_idps_fields.get('IDP_GROUPS', None)
300+
configured_groups_attribute = configuration.get('ENABLED_IDPS', {}).get(idp_string, {}).get(idp_groups_attribute_name, None)
301+
302+
if configured_groups_attribute in attrs:
303+
logger.debug(f"Setting {self.groups_claim} from attribute: {configured_groups_attribute}")
304+
response[self.groups_claim] = attrs[configured_groups_attribute]
305+
# Else try getting the "Group" attribute, if present
306+
elif self.groups_claim in attrs:
307+
logger.debug(f"Setting {self.groups_claim} from attribute: {self.groups_claim}")
308+
response[self.groups_claim] = attrs[self.groups_claim]
309+
else:
310+
logger.debug("Unable to get any group claims from the SAML response")
311+
295312
data = super().extra_data(user, backend, response, *args, **kwargs)
296313

297314
# Ideally we would always have a DB instance

0 commit comments

Comments
 (0)