Skip to content

Commit

Permalink
Merge branch 'main' into GH-593/import-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed May 23, 2023
2 parents f6d517e + bf352fa commit e8ca3a1
Show file tree
Hide file tree
Showing 26 changed files with 3,060 additions and 17 deletions.
71 changes: 66 additions & 5 deletions MIGRATION_GUIDE.md
Expand Up @@ -8,14 +8,13 @@ automated workflows before upgrading.
### Deprecations

- [Client Authentication Method](#client-authentication-method)

- [Resource Server Scopes](#resource-server-scopes)

#### Client Authentication Method


The `token_endpoint_auth_method` field on the `auth0_client` resource will continue to be available for managing the
client's authentication method. However, to ensure a smooth transition when we eventually remove the capability to
manage the authentication method through this field, we recommend proactively migrating to the newly introduced
client's authentication method. However, to ensure a smooth transition when we eventually remove the capability to
manage the authentication method through this field, we recommend proactively migrating to the newly introduced
`auth0_client_credentials` resource as this will also give you the possibility of managing the client secret.
This will help you stay prepared for future changes.

Expand All @@ -31,7 +30,7 @@ This will help you stay prepared for future changes.
# Example:
resource "auth0_client" "my_client" {
name = "My Client"
token_endpoint_auth_method = "client_secret_post"
}
```
Expand All @@ -56,6 +55,68 @@ resource "auth0_client_credentials" "test" {
</tr>
</table>

#### Resource Server Scopes

The `scopes` field on the `auth0_resource_server` resource will continue to be available for managing resource server scopes. However, to ensure a smooth transition when we eventually remove the capability to manage scopes through this field, we recommend proactively migrating to the newly introduced `auth0_resource_server_scope` resource. This will help you stay prepared for future changes.

<table>
<tr>
<th>Before (v0.47.0)</th>
<th>After (v0.48.0)</th>
</tr>
<tr>
<td>

```terraform
resource auth0_resource_server api {
name = "Example API"
identifier = "https://api.travel0.com/"
scopes {
value = "read:posts"
description = "Can read posts"
}
scopes {
value = "write:posts"
description = "Can write posts"
}
}
```

</td>
<td>

```terraform
resource auth0_resource_server api {
name = "Example API"
identifier = "https://api.travel0.com/"
# Until we remove the ability to operate changes on
# the scopes field it is important to have this
# block in the config, to avoid diffing issues.
lifecycle {
ignore_changes = [scopes]
}
}
resource auth0_resource_server_scope read_posts {
resource_server_identifier = auth0_resource_server.api.identifier
scope = "read:posts"
description = "Can read posts"
}
resource auth0_resource_server_scope write_posts {
resource_server_identifier = auth0_resource_server.api.identifier
scope = "write:posts"
description = "Can write posts"
}
```

</td>
</tr>
</table>

## Upgrading from v0.46.0 → v0.47.0

There are deprecations in this update. Please ensure you read this guide thoroughly and prepare your potential
Expand Down
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -21,8 +21,11 @@ The Auth0 Terraform Provider is the official plugin for managing Auth0 tenant co

## Documentation

- [Quickstart Guide](./docs/guides/quickstart.md)
- [Official Docs](https://registry.terraform.io/providers/auth0/auth0/latest/docs)
- [Guides]
- [Quickstart](./docs/guides/quickstart.md)
- [List available triggers for actions](./docs/guides/action_triggers.md)
- [Zero downtime client credentials rotation](./docs/guides/client_secret_rotation.md)

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/client.md
Expand Up @@ -40,7 +40,7 @@ data "auth0_client" "some-client-by-id" {
- `callbacks` (List of String) URLs that Auth0 may call back to after a user authenticates for the client. Make sure to specify the protocol (https://) otherwise the callback may fail in some cases. With the exception of custom URI schemes for native clients, all callbacks should use protocol https://.
- `client_aliases` (List of String) List of audiences/realms for SAML protocol. Used by the wsfed addon.
- `client_metadata` (Map of String) Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: `:,-+=_*?"/\()<>@ [Tab] [Space]`.
- `client_secret` (String) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string.
- `client_secret` (String) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string. Use this attribute on the `auth0_client_credentials` resource instead, to allow managing it directly.
- `cross_origin_auth` (Boolean) Whether this client can be used to make cross-origin authentication requests (`true`) or it is not allowed to make such requests (`false`). Requires the `coa_toggle_enabled` feature flag to be enabled on the tenant by the support team.
- `cross_origin_loc` (String) URL of the location in your site where the cross-origin verification takes place for the cross-origin auth flow when performing authentication in your own domain instead of Auth0 Universal Login page.
- `custom_login_page` (String) The content (HTML, CSS, JS) of the custom login page.
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/global_client.md
Expand Up @@ -28,7 +28,7 @@ data "auth0_global_client" "global" {}
- `client_aliases` (List of String) List of audiences/realms for SAML protocol. Used by the wsfed addon.
- `client_id` (String) The ID of the client.
- `client_metadata` (Map of String) Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: `:,-+=_*?"/\()<>@ [Tab] [Space]`.
- `client_secret` (String) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string.
- `client_secret` (String) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string. Use this attribute on the `auth0_client_credentials` resource instead, to allow managing it directly.
- `cross_origin_auth` (Boolean) Whether this client can be used to make cross-origin authentication requests (`true`) or it is not allowed to make such requests (`false`). Requires the `coa_toggle_enabled` feature flag to be enabled on the tenant by the support team.
- `cross_origin_loc` (String) URL of the location in your site where the cross-origin verification takes place for the cross-origin auth flow when performing authentication in your own domain instead of Auth0 Universal Login page.
- `custom_login_page` (String) The content (HTML, CSS, JS) of the custom login page.
Expand Down
141 changes: 141 additions & 0 deletions docs/guides/client_secret_rotation.md
@@ -0,0 +1,141 @@
---
page_title: Zero downtime client credentials rotation
description: |-
Achieve zero downtime client credentials rotation with the Auth0 Terraform provider.
---

# Achieving zero downtime client credentials rotation

In this guide we'll show how to rotate a client's credentials to eliminate downtime for the impacted system.

## Pre-requisites:

- The system relies on the configuration to maintain either a list of client secrets or at least two separate
configuration entries (CURRENT and NEXT) representing client secrets.
- By default, the system uses the first client secret in the list or the CURRENT configuration entry. If an error is
received during an exchange that requires client authentication and the error is known to be associated with a problem
related to client credentials, the system should be capable of retrying the operation using the next secret in the
list or the NEXT configuration entry.
- If an event occurs that forces the system to attempt to use the next secret in the list or the NEXT configuration
entry and the operation succeeds when using the new secret, the system should discard the old secret and update the
configuration in a way that the next secret (the one that succeeded) is considered to be the default/current one going
forward.

## Process (to rotate the credentials):

### Rotating a client secret

1. Generate a new value for the client secret on behalf of the system associated with the client application record.
This value should have similar entropy to the client secret values generated by the Auth0 service, minimum 48 characters
and valid characters are numbers, letters and `_`, `-`, `+`, `=`, `.` symbols. You can make use of the
[Terraform random provider](https://registry.terraform.io/providers/hashicorp/random/latest/docs) to generate this.
2. Add the newly generated secret to the system configuration as the next secret in the list or in the respective entry
if separate configuration entries are used.
3. Add the new client secret generated in the first step in your terraform configuration and run `terraform apply`:

```terraform
resource "auth0_client" "my_client" {
name = "My client that needs the secret rotated"
app_type = "non_interactive"
}
resource "random_password" "client_secret" {
length = 48
special = true
override_special = "_-+=."
}
resource "auth0_client_credentials" "test" {
client_id = auth0_client.my_client.id
authentication_method = "client_secret_post" # Your target authentication method, client_secret_post or client_secret_basic.
client_secret = random_password.client_secret.result # You can also patch directly with your own client secret.
}
```

### Rotating Private Key JWT credentials

1. Generate a new Private Key JWT credential on behalf of the system associated with the client application record.
2. Add the newly generated credential to the system configuration as the next credential in the list or in the
respective entry if separate configuration entries are used.
3. Attach the Private Key JWT credential to the client application record using Terraform and run `terraform apply`:

```terraform
resource "auth0_client" "my_client" {
name = "My client that needs the credentials rotated"
app_type = "non_interactive"
jwt_configuration {
alg = "RS256"
}
}
resource "auth0_client_credentials" "test" {
client_id = auth0_client.my_client.id
authentication_method = "private_key_jwt"
private_key_jwt {
credentials {
name = "Current Credential"
credential_type = "public_key"
algorithm = "RS256"
pem = <<EOF
-----BEGIN CERTIFICATE-----
MIIFWDCCA0ACCQDXqpBo3R...G9w0BAQsFADBuMQswCQYDVQQGEwJl
-----END CERTIFICATE-----
EOF
}
credentials {
name = "Next Credential"
credential_type = "public_key"
algorithm = "RS256"
pem = <<EOF
-----BEGIN CERTIFICATE-----
BBBIIFWDCCA0ACCQDXqpBo3R...G9w0BAQsFADBuMQswCQYDVQQGEwJl
-----END CERTIFICATE-----
EOF
}
}
}
```

4. Remove the old Private Key JWT credential on the client application record using Terraform and run `terraform apply`:

```terraform
resource "auth0_client" "my_client" {
name = "My client that needs the credentials rotated"
app_type = "non_interactive"
jwt_configuration {
alg = "RS256"
}
}
resource "auth0_client_credentials" "test" {
client_id = auth0_client.my_client.id
authentication_method = "private_key_jwt"
private_key_jwt {
credentials {
name = "Current Credential" # Next becomes current.
credential_type = "public_key"
algorithm = "RS256"
pem = <<EOF
-----BEGIN CERTIFICATE-----
BBBIIFWDCCA0ACCQDXqpBo3R...G9w0BAQsFADBuMQswCQYDVQQGEwJl
-----END CERTIFICATE-----
EOF
}
}
}
```

## Summary

Given the system is prepared to automatically fall back to use the next client credential as available in system
configuration, this process will allow rotating a credential without downtime because by the time that the new
credential takes effect in the Auth0 service, the system is already aware of that value and can automatically fall back
and retry any operation that fails due to the old credential that got rotated.
4 changes: 2 additions & 2 deletions docs/resources/client.md
Expand Up @@ -102,7 +102,7 @@ resource "auth0_client" "my_client" {
- `callbacks` (List of String) URLs that Auth0 may call back to after a user authenticates for the client. Make sure to specify the protocol (https://) otherwise the callback may fail in some cases. With the exception of custom URI schemes for native clients, all callbacks should use protocol https://.
- `client_aliases` (List of String) List of audiences/realms for SAML protocol. Used by the wsfed addon.
- `client_metadata` (Map of String) Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: `:,-+=_*?"/\()<>@ [Tab] [Space]`.
- `client_secret_rotation_trigger` (Map of String) Custom metadata for the rotation. The contents of this map are arbitrary and are hashed by the provider. When the hash changes, a rotation is triggered. For example, the map could contain the user making the change, the date of the change, and a text reason for the change. For more info: [rotate-client-secret](https://auth0.com/docs/get-started/applications/rotate-client-secret).
- `client_secret_rotation_trigger` (Map of String, Deprecated) Custom metadata for the rotation. The contents of this map are arbitrary and are hashed by the provider. When the hash changes, a rotation is triggered. For example, the map could contain the user making the change, the date of the change, and a text reason for the change. For more info: [rotate-client-secret](https://auth0.com/docs/get-started/applications/rotate-client-secret). Migrate to the `auth0_client_credentials` resource to manage a client's secret directly instead. Refer to the [client secret rotation guide](Refer to the [client secret rotation guide](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/client_secret_rotation) for instructions on how to rotate client secrets with zero downtime.
- `cross_origin_auth` (Boolean) Whether this client can be used to make cross-origin authentication requests (`true`) or it is not allowed to make such requests (`false`). Requires the `coa_toggle_enabled` feature flag to be enabled on the tenant by the support team.
- `cross_origin_loc` (String) URL of the location in your site where the cross-origin verification takes place for the cross-origin auth flow when performing authentication in your own domain instead of Auth0 Universal Login page.
- `custom_login_page` (String) The content (HTML, CSS, JS) of the custom login page.
Expand Down Expand Up @@ -131,7 +131,7 @@ resource "auth0_client" "my_client" {
### Read-Only

- `client_id` (String) The ID of the client.
- `client_secret` (String, Sensitive) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string.
- `client_secret` (String, Sensitive, Deprecated) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string. Use this attribute on the `auth0_client_credentials` resource instead, to allow managing it directly.
- `id` (String) The ID of this resource.
- `signing_keys` (List of Map of String, Sensitive) List containing a map of the public cert of the signing key and the public cert of the signing key in PKCS7.

Expand Down
3 changes: 3 additions & 0 deletions docs/resources/client_credentials.md
Expand Up @@ -8,6 +8,9 @@ description: |-

With this resource, you can configure the method to use when making requests to any endpoint that requires this client to authenticate.

-> Refer to the [client secret rotation guide](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/client_secret_rotation)
for instructions on how to rotate client secrets with zero downtime.

## Example Usage

```terraform
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/global_client.md
Expand Up @@ -40,8 +40,8 @@ PAGE
- `client_aliases` (List of String) List of audiences/realms for SAML protocol. Used by the wsfed addon.
- `client_id` (String) The ID of the client.
- `client_metadata` (Map of String) Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: `:,-+=_*?"/\()<>@ [Tab] [Space]`.
- `client_secret` (String, Sensitive) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string.
- `client_secret_rotation_trigger` (Map of String) Custom metadata for the rotation. The contents of this map are arbitrary and are hashed by the provider. When the hash changes, a rotation is triggered. For example, the map could contain the user making the change, the date of the change, and a text reason for the change. For more info: [rotate-client-secret](https://auth0.com/docs/get-started/applications/rotate-client-secret).
- `client_secret` (String, Sensitive, Deprecated) Secret for the client. Keep this private. To access this attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string. Use this attribute on the `auth0_client_credentials` resource instead, to allow managing it directly.
- `client_secret_rotation_trigger` (Map of String, Deprecated) Custom metadata for the rotation. The contents of this map are arbitrary and are hashed by the provider. When the hash changes, a rotation is triggered. For example, the map could contain the user making the change, the date of the change, and a text reason for the change. For more info: [rotate-client-secret](https://auth0.com/docs/get-started/applications/rotate-client-secret). Migrate to the `auth0_client_credentials` resource to manage a client's secret directly instead. Refer to the [client secret rotation guide](Refer to the [client secret rotation guide](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/client_secret_rotation) for instructions on how to rotate client secrets with zero downtime.
- `cross_origin_auth` (Boolean) Whether this client can be used to make cross-origin authentication requests (`true`) or it is not allowed to make such requests (`false`). Requires the `coa_toggle_enabled` feature flag to be enabled on the tenant by the support team.
- `cross_origin_loc` (String) URL of the location in your site where the cross-origin verification takes place for the cross-origin auth flow when performing authentication in your own domain instead of Auth0 Universal Login page.
- `custom_login_page` (String) The content (HTML, CSS, JS) of the custom login page.
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/hook.md
Expand Up @@ -8,6 +8,9 @@ description: |-

Hooks are secure, self-contained functions that allow you to customize the behavior of Auth0 when executed for selected extensibility points of the Auth0 platform. Auth0 invokes Hooks during runtime to execute your custom Node.js code. Depending on the extensibility point, you can use Hooks with Database Connections and/or Passwordless Connections.

!> This resource is deprecated. Refer to the [guide on how to migrate from rules to actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions)
and manage your actions using the `auth0_action` resource.

## Example Usage

```terraform
Expand Down

0 comments on commit e8ca3a1

Please sign in to comment.