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

Application Object Id can never be removed from role once it has been set #224

Open
archimeid opened this issue Dec 4, 2024 · 0 comments

Comments

@archimeid
Copy link

Hi,

I've discovered what I assume is a bug concerning role property application_object_id. Once it has been set, it will never be removed from role during updates unless it is explicitly set to null or "".

In my opinion, application_object_id should be removed directly if not present in the payload.

I discovered this when using Vault provider for Terraform. When switching one role from using existing service principal to using Azure roles in addition to using the property permanently_delete, I got the following error :

permanently_delete must be false if application_object_id is provided

The following code should handle if application_object_id is missing from payload :

// update and verify Application Object ID if provided
if appObjectID, ok := d.GetOk("application_object_id"); ok {
role.ApplicationObjectID = appObjectID.(string)
}
if role.ApplicationObjectID != "" {
app, err := client.provider.GetApplication(ctx, role.ApplicationObjectID)
if err != nil {
return nil, fmt.Errorf("error loading Application: %w", err)
}
role.ApplicationID = app.AppID
if role.PermanentlyDelete {
return logical.ErrorResponse("permanently_delete must be false if application_object_id is provided"), nil
}
}

Adding an else block like this should be effective :

if appObjectID, ok := d.GetOk("application_object_id"); ok { 
    role.ApplicationObjectID = appObjectID.(string) 
} else {
    role.ApplicationObjectID = ""
}
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

No branches or pull requests

1 participant