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 updates for wiz_user and wiz_project, add SAML to wiz_user #156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 77 additions & 5 deletions internal/provider/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,83 @@ func resourceWizProjectUpdate(ctx context.Context, d *schema.ResourceData, m int

// define the graphql query
query := `mutation UpdateProject($input: UpdateProjectInput!) {
updateProject(input: $input) {
project {
id
}
}
updateProject(input: $input) {
project {
id
name
identifiers
description
businessUnit
projectOwners {
id
name
email
}
securityChampions {
id
name
email
}
cloudOrganizationLinks {
cloudOrganization {
id
}
environment
resourceTags {
key
value
}
shared
resourceGroups
}
cloudAccountLinks {
cloudAccount {
id
}
environment
resourceTags {
key
value
}
shared
resourceGroups
}
kubernetesClustersLinks {
kubernetesCluster {
id
}
environment
namespaces
shared
}
repositoryLinks {
repository {
id
}
}
containerRegistryLinks {
containerRegistry {
id
}
environment
}
ancestorProjects {
id
name
}
riskProfile {
businessImpact
hasAuthentication
isInternetFacing
hasExposedAPI
storesData
sensitiveDataTypes
regulatoryStandards
isCustomerFacing
isRegulated
}
}
}
}`

// populate the graphql variables
Expand Down
40 changes: 35 additions & 5 deletions internal/provider/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func resourceWizUser() *schema.Resource {
Description: "The user email address.",
Required: true,
},
"idpID": {
Type: schema.TypeString,
Description: "IDP ID.",
Required: false,
},
"role": {
Type: schema.TypeString,
Description: "Whether the project is archived/inactive",
Expand Down Expand Up @@ -86,9 +91,23 @@ func resourceWizUserCreate(ctx context.Context, d *schema.ResourceData, m interf

// populate the graphql variables
vars := &wiz.CreateUserInput{}
vars.IdpID = d.Get("idpID").(string)

// SAML Users require seperate query for create only
if ssoEnabled := vars.IdpID != ""; ssoEnabled {
query = `mutation CreateSAMLUser($input: CreateSAMLUserInput!) {
createSAMLUser(input: $input) {
user {
id
}
}
}`
}

vars.Name = d.Get("name").(string)
vars.Email = d.Get("email").(string)
vars.Role = d.Get("role").(string)

vars.SendEmailInvite = d.Get("send_email_invite").(bool)
vars.AssignedProjectIDs = utils.ConvertListToString(d.Get("assigned_project_ids").([]interface{}))

Expand Down Expand Up @@ -202,11 +221,22 @@ func resourceWizUserUpdate(ctx context.Context, d *schema.ResourceData, m interf

// define the graphql query
query := `mutation UpdateUser($input: UpdateUserInput!) {
updateUser(input: $input) {
user {
id
}
}
updateUser(input: $input) {
user {
id
name
email
isSuspended
effectiveRole {
id
name
}
effectiveAssignedProjects {
id
name
}
}
}
}`

// populate the graphql variables
Expand Down
1 change: 1 addition & 0 deletions internal/wiz/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ type CreateUserInput struct {
Role string `json:"role"`
AssignedProjectIDs []string `json:"assignedProjectIds,omitempty"`
SendEmailInvite bool `json:"sendEmailInvite"`
IdpID string `json:"idpID,omitempty"`
}

// CreateUserPayload struct
Expand Down