diff --git a/docs/resources/user_permission.md b/docs/resources/user_permission.md index 82f04b657..5439df79d 100644 --- a/docs/resources/user_permission.md +++ b/docs/resources/user_permission.md @@ -8,6 +8,8 @@ description: |- With this resource, you can manage user permissions. +!> To prevent issues, avoid using this resource together with the `auth0_user_permissions` resource. + ## Example Usage ```terraform diff --git a/docs/resources/user_permissions.md b/docs/resources/user_permissions.md new file mode 100644 index 000000000..061eaac3a --- /dev/null +++ b/docs/resources/user_permissions.md @@ -0,0 +1,91 @@ +--- +page_title: "Resource: auth0_user_permissions" +description: |- + With this resource, you can manage all of a user's permissions. +--- + +# Resource: auth0_user_permissions + +With this resource, you can manage all of a user's permissions. + +!> To prevent issues, avoid using this resource together with the `auth0_user_permission` resource. + +## Example Usage + +```terraform +resource "auth0_resource_server" "resource_server" { + name = "Example Resource Server (Managed by Terraform)" + identifier = "https://api.example.com" + scopes { + value = "create:foo" + description = "Create foos" + } + + scopes { + value = "read:foo" + description = "Read foos" + } +} + +resource "auth0_user" "user" { + connection_name = "Username-Password-Authentication" + user_id = "12345" + username = "unique_username" + name = "Firstname Lastname" + nickname = "some.nickname" + email = "test@test.com" + email_verified = true + password = "passpass$12$12" + picture = "https://www.example.com/a-valid-picture-url.jpg" +} + +resource "auth0_user_permissions" "all_user_permissions" { + user_id = auth0_user.user.id + + permissions { + name = tolist(auth0_resource_server.resource_server.scopes)[0] + resource_server_identifier = auth0_resource_server.resource_server.identifier + } + + permissions { + name = tolist(auth0_resource_server.resource_server.scopes)[1] + resource_server_identifier = auth0_resource_server.resource_server.identifier + } +} +``` + + +## Schema + +### Required + +- `permissions` (Block Set, Min: 1) List of API permissions granted to the user. (see [below for nested schema](#nestedblock--permissions)) +- `user_id` (String) ID of the user to associate the permission to. + +### Read-Only + +- `id` (String) The ID of this resource. + + +### Nested Schema for `permissions` + +Required: + +- `name` (String) Name of permission. +- `resource_server_identifier` (String) Resource server identifier associated with the permission. + +Read-Only: + +- `description` (String) Description of the permission. +- `resource_server_name` (String) Name of resource server that the permission is associated with. + +## Import + +Import is supported using the following syntax: + +```shell +# This resource can be imported by specifying the user ID + +# Example: +terraform import auth0_user_permissions.all_user_permissions "auth0|111111111111111111111111" +``` diff --git a/templates/resources/user_permission.md.tmpl b/templates/resources/user_permission.md.tmpl new file mode 100644 index 000000000..ffc57218f --- /dev/null +++ b/templates/resources/user_permission.md.tmpl @@ -0,0 +1,31 @@ +--- +page_title: "{{.Type}}: {{.Name}}" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Type}}: {{.Name}} + +{{ .Description | trimspace }} + +!> To prevent issues, avoid using this resource together with the `auth0_user_permissions` resource. + +{{ if .HasExample -}} + +## Example Usage + +{{ tffile .ExampleFile }} + +{{- end }} + +{{ .SchemaMarkdown | trimspace }} + +{{ if .HasImport -}} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" .ImportFile }} + +{{- end }} diff --git a/templates/resources/user_permissions.md.tmpl b/templates/resources/user_permissions.md.tmpl new file mode 100644 index 000000000..62f695897 --- /dev/null +++ b/templates/resources/user_permissions.md.tmpl @@ -0,0 +1,31 @@ +--- +page_title: "{{.Type}}: {{.Name}}" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Type}}: {{.Name}} + +{{ .Description | trimspace }} + +!> To prevent issues, avoid using this resource together with the `auth0_user_permission` resource. + +{{ if .HasExample -}} + +## Example Usage + +{{ tffile .ExampleFile }} + +{{- end }} + +{{ .SchemaMarkdown | trimspace }} + +{{ if .HasImport -}} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" .ImportFile }} + +{{- end }}