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

Fix client#removeGroupMemberships parameter order #51

Merged

Conversation

mdgreenfield
Copy link
Contributor

@mdgreenfield mdgreenfield commented Oct 23, 2020

I wasn't able to see the following Azure error in the audit logs
warnings field. It looks as though even though the request to Azure
fails, when the Azure app is removed the group memberships are still
cleaned up.

I was only able to see the error below by adding a log line to print the
error when revoke is called.

1 error occurred:
        * error removing group membership: graphrbac.GroupsClient#RemoveMember: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="Unknown" Message="Unknown service error" Details=[{"odata.error":{"code":"Request_ResourceNotFound","date":"2020-10-23T20:32:14","message":{"lang":"en","value":"Resource 'c1004989-2986-48e8-9e2e-aa03b7cacbc1' does not exist or one of its queried reference-property objects are not present."},"requestId":"a2d4d4c6-4e0a-4ea2-a807-16486c307d03"}}]

With that said, I think it begs the question whether or not calling removeGroupMemberships should even be called on revoke.

I wasn't able to see the following Azure error in the audit logs
`warnings` field. It looks as though even though the request to Azure
fails, when the Azure app is removed the group memberships are still
cleaned up.

I was only able to see the error below by adding a log line to print the
error when revoke is called.

```
1 error occurred:
        * error removing group membership: graphrbac.GroupsClient#RemoveMember: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="Unknown" Message="Unknown service error" Details=[{"odata.error":{"code":"Request_ResourceNotFound","date":"2020-10-23T20:32:14","message":{"lang":"en","value":"Resource 'c1004989-2986-48e8-9e2e-aa03b7cacbc1' does not exist or one of its queried reference-property objects are not present."},"requestId":"a2d4d4c6-4e0a-4ea2-a807-16486c307d03"}}]

: timestamp=2020-10-23T14:32:14.604-0600
```
client.go Outdated
@@ -302,7 +302,7 @@ func (c *client) removeGroupMemberships(ctx context.Context, servicePrincipalObj
var merr *multierror.Error

for _, id := range groupIDs {
if _, err := c.provider.RemoveGroupMember(ctx, servicePrincipalObjectID, id); err != nil {
if _, err := c.provider.RemoveGroupMember(ctx, id, servicePrincipalObjectID); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref to RemoveGroupMember -

RemoveGroupMember(ctx context.Context, groupObjectID, memberObjectID string) (result autorest.Response, err error)

@mdgreenfield
Copy link
Contributor Author

I came across this working on an implementation of #50 with our internal fork.

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@austingebauer austingebauer left a comment

Choose a reason for hiding this comment

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

I realize it's been a while on this one, but it makes sense to fix the parameter order. Thanks, @mdgreenfield!

@austingebauer austingebauer merged commit e2de23d into hashicorp:main Feb 2, 2023
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