Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for group_membership_filter in azuread #1458

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

bigkevmcd
Copy link
Contributor

Issue: rancher/rancher#46209

Problem

It's not currently possible to configure the user-group filter from Terraform.

Solution

This adds support for configuring the group_memembership_filter for Azure which configures a filter for querying groups for a user.

Testing

Engineering Testing

Manual Testing

Configured a simple "azuread" resource...

resource "rancher2_auth_config_azuread" "azuread" {
 // other fields omitted for simplicity
  group_membership_filter = "startswith(displayName,'admin')"
}

And confirmed that these are configured on the azuread AuthConfig resource, and that they are updated when changed.

Automated Testing

Tests were added for the new behaviour.

QA Testing Considerations

Regressions Considerations

@bigkevmcd bigkevmcd self-assigned this Jan 8, 2025
@bigkevmcd bigkevmcd marked this pull request as draft January 8, 2025 14:15
@bigkevmcd bigkevmcd marked this pull request as ready for review January 9, 2025 13:52
@bigkevmcd
Copy link
Contributor Author

There's an issue here, but it's not just this addition that's affected.

You can't clear the value once you've set it, you can change it, but not clear it.

There are a number of bugs that cause this...

  1. The AzureADConfig field GroupMembershipFilter is declared with omitempty which means that if you set it to an empty string, it won't actually be marshalled.
  2. Our code generation adds omitempty to every struct, field (it should really only be struct pointers that get omitempty) even if the field isn't declared as omitempty (I've tried stripping omitempty from the field, and the generated version gets omitempty), I have tried manually modifying the generated code to strip omitempty and this does fix the issue.
  3. We can't calculate a patch either, because we don't support PATCHing the AuthConfigs

Error: [ERROR] Updating Auth Config azuread: Bad response statusCode [405]. Status [405 Method Not Allowed]. Body: [baseType=error, code=MethodNotAllow, message=Method PATCH not supported] from [https://rancher.bigkevmcd.com:8443/v3/azureADConfigs/azuread]

To be clear, this impacts on the other fields in the AzureAD config, you can't clear the optional fields used for custom endpoints either:

The following problems may be the cause of any confusing errors from downstream operations:
- .auth_endpoint: was cty.StringVal(""), but now cty.StringVal("https://example.com")

Copy link

@enrichman enrichman left a comment

Choose a reason for hiding this comment

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

LGTM ✔️

@@ -35,7 +35,7 @@ func init() {
testAccRancher2AdminPass = testAccRancher2DefaultAdminPass
err := testAccCheck()
if err != nil {
log.Fatalf("%v", err)
log.Fatalf("failed check %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt of using %w instead o %s?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ops, sorry, my mistake

Copy link
Contributor

@alegrey91 alegrey91 left a comment

Choose a reason for hiding this comment

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

LGTM

@bigkevmcd bigkevmcd force-pushed the configure-user-group-filter branch 4 times, most recently from ed69cdb to 5cb5a48 Compare January 21, 2025 16:16
This adds support for configuring the group_memembership_filter for
Azure which configures a filter for querying groups for a user.

Signed-off-by: Kevin McDermott <[email protected]>
@bigkevmcd bigkevmcd force-pushed the configure-user-group-filter branch from 5cb5a48 to cc75ece Compare January 21, 2025 16:17
@bigkevmcd bigkevmcd merged commit 3f7656e into rancher:master Jan 21, 2025
1 check passed
@bigkevmcd bigkevmcd deleted the configure-user-group-filter branch January 21, 2025 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants