Skip to content

Conversation

@tvernum
Copy link
Contributor

@tvernum tvernum commented Mar 8, 2022

GroupMappingIT would somtimes due to a timeout when authenticating
against the SMB fixture.

This changes the test to first perform an "authenticate" request,
with retries in order to cache the user's credentials before
performing the access checks.

This means that the access checks should pass/fail due to true
authorization behaviour rather than authentication behaviour.

Resolves: #84586, #83144

GroupMappingIT would somtimes due to a timeout when authenticating
against the SMB fixture.

This changes the test to first perform an "authenticate" request,
with retries in order to cache the user's credentials before
performing the access checks.

This means that the access checks should pass/fail due to true
authorization behaviour rather than authentication behaviour.

Resolves: elastic#84586
@tvernum tvernum added >test Issues or PRs that are addressing/adding tests :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) labels Mar 8, 2022
@tvernum tvernum requested a review from albertzaharovits March 8, 2022 06:33
@elasticmachine elasticmachine added the Team:Security Meta label for security team label Mar 8, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@tvernum
Copy link
Contributor Author

tvernum commented Mar 14, 2022

Ping @albertzaharovits

final Client client = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, userHeader(user, PASSWORD)));
// Force an authentication to populate the cache.
// We can safely re-try this if it fails, which means we can be more confident that the index request failed for the correct reason
authenticateUser(client, user, 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you say if we move this bits in a method like assertAdFixtureIsActive (maybe followed by a realm cache call) and call that in a @Before method.
I think this would scoped tighter to the lazy fixture problem. Scatering authenticate calls before every index runs the slight potential to hide true issues (and it makes test console dumps harder to follow).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tricky bit is that we need to do it for each user - the problem is that we need every user to be in the cache so we avoid external LDAP calls during authz checks

That could be done, but it's not just one user - it's several and we'd need to pre-cache each of them.

String asgardian = "odin";
String securityPhilanthropist = realmConfig.loginWithCommonName ? "Bruce Banner" : "hulk";
String securityMappedUser = realmConfig.loginWithCommonName ? "Phil Coulson" : "phil";
String securityAsgardianPhilanthropist = "thor";
String noGroupUser = "jarvis";

I'm not sure that ends up being a nicer solution.

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would repeat the authn to probe the fixture only once per test suite, but I'm OK either way.
Sorry for defering the review of this.
LGTM

@tvernum
Copy link
Contributor Author

tvernum commented Mar 18, 2022

I'm going to merge as-is. I like the idea of moving this out of the assertion method, but I don't see a nice way to do that, and I'm keen to get the test fixed.

Happy to revisit if there are suggestions.

@tvernum tvernum merged commit 1e6b30e into elastic:master Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) Team:Security Meta label for security team >test Issues or PRs that are addressing/adding tests v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] GroupMappingIT testGroupMapping failing

4 participants