-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(LH-86969): Generate API token for user in MSP managed tenant (#149)
* feat(lh-86969): add the ability to read users from an MSP tenant when creating This commit reads the users in an MSP-managed tenant after creating, and before deleting or updating them. BREAKING CHANGE: The `role` field has been changed to a list field called `roles`. * chore(lh-86969): clean up example * feat(lh-86969): add a new resource called `cdo_msp_managed_tenant_user_api_token` Add a new resource to generate an API token for a user in a MSP-managed tenant. * test(lh-86969): add tests * docs(lh-86969): fix documentation for msp_managed_tenant_user_api_token * docs(lh-86969): fix capitalization of error message * fix(lh-86969): remove fake JWT tokens in unit tests because it freaks GitGuardian out * fix(lh-86969): add gitleaks config to ignore false positives * fix(lh-86969): use toml instead of yaml * try fix gitleaks config
- Loading branch information
1 parent
978abd0
commit 1a60bda
Showing
16 changed files
with
406 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[[rules]] | ||
description = "Ignore ApiToken in tests" | ||
regex = '''(?i)ApiToken:\s?"fake-api-token"''' | ||
path = '''^.*_test\.go$''' | ||
|
||
[rules.allowlist] | ||
description = "Allow fake ApiToken in test files" | ||
commits = [] | ||
files = [] | ||
paths = ["^.*_test\\.go$"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "cdo_msp_managed_tenant_user_api_token Resource - cdo" | ||
subcategory: "" | ||
description: |- | ||
Provides a resource to manage an API token for a user in an MSP-managed tenant. | ||
--- | ||
|
||
# cdo_msp_managed_tenant_user_api_token (Resource) | ||
|
||
Provides a resource to manage an API token for a user in an MSP-managed tenant. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `tenant_uid` (String) Universally unique identifier of the tenant in which the API token for the user should be generated. | ||
- `user_uid` (String) Universally unique identifier of the user for whom the API token should be generated. | ||
|
||
### Read-Only | ||
|
||
- `api_token` (String, Sensitive) The generated API token for the user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,21 @@ resource "cdo_msp_managed_tenant_users" "example" { | |
username = "[email protected]", | ||
roles = ["ROLE_ADMIN"] | ||
api_only_user = false | ||
}, | ||
{ | ||
username = "api-only-user", | ||
roles = ["ROLE_SUPER_ADMIN"] | ||
api_only_user = true | ||
} | ||
] | ||
} | ||
|
||
resource "cdo_msp_managed_tenant_user_api_token" "user_token" { | ||
tenant_uid = data.cdo_msp_managed_tenant.tenant.id | ||
user_uid = cdo_msp_managed_tenant_users.example.users[2].id | ||
} | ||
|
||
output "api_token" { | ||
value = cdo_msp_managed_tenant_user_api_token.user_token.api_token | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package msp_tenant_user_api_token | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
type MspManagedTenantUserApiTokenResourceModel struct { | ||
TenantUid types.String `tfsdk:"tenant_uid"` | ||
UserUid types.String `tfsdk:"user_uid"` | ||
ApiToken types.String `tfsdk:"api_token"` // Additional field | ||
} |
Oops, something went wrong.