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

Add Signing Keys to client resource #66

Merged
merged 7 commits into from
Feb 23, 2022
Merged
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
2 changes: 2 additions & 0 deletions auth0/data_source_auth0_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestAccDataClientByName(t *testing.T) {
Config: random.Template(fmt.Sprintf(testAccDataClientConfigByName, testAccClientConfig), rand),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.auth0_client.test", "client_id"),
resource.TestCheckResourceAttr("data.auth0_client.test", "signing_keys.#", "1"), // checks that signing_keys is set, and it includes 1 element
resource.TestCheckResourceAttr("data.auth0_client.test", "name", fmt.Sprintf("Acceptance Test - %v", rand)),
resource.TestCheckResourceAttr("data.auth0_client.test", "app_type", "non_interactive"), // Arbitrary property selection
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret_rotation_trigger"),
Expand Down Expand Up @@ -67,6 +68,7 @@ func TestAccDataClientById(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.auth0_client.test", "id"),
resource.TestCheckResourceAttrSet("data.auth0_client.test", "name"),
resource.TestCheckResourceAttr("data.auth0_client.test", "signing_keys.#", "1"), // checks that signing_keys is set, and it includes 1 element
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret_rotation_trigger"),
resource.TestCheckNoResourceAttr("data.auth0_client.test", "client_secret"),
),
Expand Down
6 changes: 6 additions & 0 deletions auth0/resource_auth0_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@ func newClient() *schema.Resource {
},
},
},
"signing_keys": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeMap},
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -642,6 +647,7 @@ func readClient(d *schema.ResourceData, m interface{}) error {
d.Set("client_metadata", c.ClientMetadata)
d.Set("mobile", c.Mobile)
d.Set("initiate_login_uri", c.InitiateLoginURI)
d.Set("signing_keys", c.SigningKeys)

return nil
}
Expand Down
1 change: 1 addition & 0 deletions auth0/resource_auth0_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func TestAccClient(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.samlp.0.signing_cert", "-----BEGIN PUBLIC KEY-----\nMIGf...bpP/t3\n+JGNGIRMj1hF1rnb6QIDAQAB\n-----END PUBLIC KEY-----\n"),
resource.TestCheckResourceAttr("auth0_client.my_client", "client_metadata.foo", "zoo"),
resource.TestCheckResourceAttr("auth0_client.my_client", "initiate_login_uri", "https://example.com/login"),
resource.TestCheckResourceAttr("auth0_client.my_client", "signing_keys.#", "1"), // checks that signing_keys is set, and it includes 1 element
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ At least one of the following arguments required:

## Attribute Reference

The client data source possesses the same attributes as the `auth0_client` resource, with the exception of `client_secret_rotation_trigger`. Refer to the [auth0_client resource documentation](../resources/client.md) for a list of returned attributes.
The client data source possesses the same attributes as the `auth0_client` resource, except for
`client_secret_rotation_trigger`. Refer to the [auth0_client resource documentation](../resources/client.md) for a list
of returned attributes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ No arguments accepted.

* `client_id` - String. ID of the client.
* `client_secret`<sup>[1](#client-keys)</sup> - String. Secret for the client; keep this private.
* `custom_login_page_on` - Boolean. Indicates whether or not a custom login page is to be used.
* `custom_login_page_on` - Boolean. Indicates whether a custom login page is to be used.
* `custom_login_page` - String. Content of the custom login page.
* `client_metadata` - (Optional) Map(String)

### Client Keys

To access the `client_secret` attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise, the attribute will contain an empty string.
To access the `client_secret` attribute you need to add the `read:client_keys` scope to the Terraform client. Otherwise,
the attribute will contain an empty string.
1 change: 1 addition & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ Attributes exported by this resource include:
* `grant_types` - List(String). Types of grants that this client is authorized to use.
* `custom_login_page_on` - Boolean. Indicates whether or not a custom login page is to be used.
* `token_endpoint_auth_method` - String. Defines the requested authentication method for the token endpoint. Options include `none` (public client without a client secret), `client_secret_post` (client uses HTTP POST parameters), `client_secret_basic` (client uses HTTP Basic).
* `signing_keys` - List(Map). List containing a map of the public cert of the signing key and the public cert of the signing key in pkcs7.

### Client keys

Expand Down