rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
263 stars 228 forks source link

Add `must_change_password` attribute to `rancher2_user` resource #1380

Closed alegrey91 closed 3 months ago

alegrey91 commented 3 months ago

Issue: https://github.com/rancher/rancher/issues/45736

Problem

When declaring users with rancher2_user, there is no option to ask the user to change their password on the next login like there is in the UI.

Solution

Add the missing attribute in order to allow the user to force the reset of rancher users managed with the provider.

Testing

Engineering Testing

Manual Testing

Setup a rancher instance from docker:

sudo docker run --privileged -it --rm -p 8080:80 -p 443:443 rancher/rancher

In order to test this new attribute I've used the following terraform script to ensure the new user had this attribute set:

resource "rancher2_user" "testuser" {
  name     = "Test User"
  username = "testuser"
  password = "password12345"
  must_change_password = true
  enabled     = true
}

# Assign global role bindings to the user (optional)
resource "rancher2_global_role_binding" "new_user_role" {
  user_id       = rancher2_user.testuser.id
  global_role_id = "user-base"
}

Once terraform completed its run, you can login with the new created user testuser. Once logged in the UI will show the reset password page.

Automated Testing

QA Testing Considerations

Regressions Considerations