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

(feat) Location Basic Auth and User Auth Methods … #202

Merged
merged 12 commits into from
Mar 23, 2023
Prev Previous commit
Next Next commit
enroll user on creation
  • Loading branch information
amazzalel-habib committed Mar 11, 2023
commit 04d8d3b0c8fc8cd058cb6aa6d7d75a75842d8225
22 changes: 17 additions & 5 deletions zia/resource_zia_user_management_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ func resourceUserManagement() *schema.Resource {
Description: "Temporary Authentication Email. If you enabled one-time tokens or links, enter the email address to which the Zscaler service sends the tokens or links. If this is empty, the service will send the email to the User email.",
},
"auth_methods": {
Type: schema.TypeString,
Type: schema.TypeSet,
Optional: true,
Description: "Accepted Authentication Methods",
ValidateFunc: validation.StringInSlice([]string{
"BASIC",
"DIGEST",
}, false),
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
"BASIC",
"DIGEST",
}, false),
},
},
"password": {
Type: schema.TypeString,
Expand Down Expand Up @@ -137,6 +140,15 @@ func resourceUserManagementCreate(d *schema.ResourceData, m interface{}) error {
return err
}
log.Printf("[INFO] Created zia user request. ID: %v\n", resp)
if len(resp.AuthMethods) > 0 {
_, err = zClient.usermanagement.EnrollUser(resp.ID, usermanagement.EnrollUserRequest{
AuthMethods: resp.AuthMethods,
Password: resp.Password,
})
if err != nil {
log.Printf("[ERROR] enrolling user failed: %v\n", err)
}
}
d.SetId(strconv.Itoa(resp.ID))
_ = d.Set("user_id", resp.ID)
return resourceUserManagementRead(d, m)
Expand Down