-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DXCDT-363: Add connection data source (#470)
- Loading branch information
Showing
10 changed files
with
2,415 additions
and
1 deletion.
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,223 @@ | ||
--- | ||
page_title: "Data Source: auth0_connection" | ||
description: |- | ||
Data source to retrieve a specific Auth0 connection by connection_id or name. | ||
--- | ||
|
||
# Data Source: auth0_connection | ||
|
||
Data source to retrieve a specific Auth0 connection by `connection_id` or `name`. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `connection_id` (String) The ID of the connection. If not provided, `name` must be set. | ||
- `name` (String) The name of the connection. If not provided, `connection_id` must be set. | ||
|
||
### Read-Only | ||
|
||
- `display_name` (String) Name used in login screen. | ||
- `enabled_clients` (Set of String) IDs of the clients for which the connection is enabled. | ||
- `id` (String) The ID of this resource. | ||
- `is_domain_connection` (Boolean) Indicates whether the connection is domain level. | ||
- `metadata` (Map of String) Metadata associated with the connection, in the form of a map of string values (max 255 chars). Maximum of 10 metadata properties allowed. | ||
- `options` (List of Object) Configuration settings for connection options. (see [below for nested schema](#nestedatt--options)) | ||
- `realms` (List of String) Defines the realms for which the connection will be used (e.g., email domains). If not specified, the connection name is added as the realm. | ||
- `show_as_button` (Boolean) Display connection as a button. Only available on enterprise connections. | ||
- `strategy` (String) Type of the connection, which indicates the identity provider. | ||
- `strategy_version` (String) | ||
- `validation` (Map of String) | ||
|
||
<a id="nestedatt--options"></a> | ||
### Nested Schema for `options` | ||
|
||
Read-Only: | ||
|
||
- `adfs_server` (String) | ||
- `allowed_audiences` (Set of String) | ||
- `api_enable_users` (Boolean) | ||
- `app_id` (String) | ||
- `auth_params` (Map of String) | ||
- `authorization_endpoint` (String) | ||
- `brute_force_protection` (Boolean) | ||
- `client_id` (String) | ||
- `client_secret` (String) | ||
- `community_base_url` (String) | ||
- `configuration` (Map of String) | ||
- `custom_scripts` (Map of String) | ||
- `debug` (Boolean) | ||
- `digest_algorithm` (String) | ||
- `disable_cache` (Boolean) | ||
- `disable_sign_out` (Boolean) | ||
- `disable_signup` (Boolean) | ||
- `discovery_url` (String) | ||
- `domain` (String) | ||
- `domain_aliases` (Set of String) | ||
- `enable_script_context` (Boolean) | ||
- `enabled_database_customization` (Boolean) | ||
- `entity_id` (String) | ||
- `fed_metadata_xml` (String) | ||
- `fields_map` (String) | ||
- `forward_request_info` (Boolean) | ||
- `from` (String) | ||
- `gateway_authentication` (List of Object) (see [below for nested schema](#nestedobjatt--options--gateway_authentication)) | ||
- `gateway_url` (String) | ||
- `icon_url` (String) | ||
- `identity_api` (String) | ||
- `idp_initiated` (List of Object) (see [below for nested schema](#nestedobjatt--options--idp_initiated)) | ||
- `import_mode` (Boolean) | ||
- `ips` (Set of String) | ||
- `issuer` (String) | ||
- `jwks_uri` (String) | ||
- `key_id` (String) | ||
- `max_groups_to_retrieve` (String) | ||
- `messaging_service_sid` (String) | ||
- `metadata_url` (String) | ||
- `metadata_xml` (String) | ||
- `mfa` (List of Object) (see [below for nested schema](#nestedobjatt--options--mfa)) | ||
- `name` (String) | ||
- `non_persistent_attrs` (Set of String) | ||
- `password_complexity_options` (List of Object) (see [below for nested schema](#nestedobjatt--options--password_complexity_options)) | ||
- `password_dictionary` (List of Object) (see [below for nested schema](#nestedobjatt--options--password_dictionary)) | ||
- `password_history` (List of Object) (see [below for nested schema](#nestedobjatt--options--password_history)) | ||
- `password_no_personal_info` (List of Object) (see [below for nested schema](#nestedobjatt--options--password_no_personal_info)) | ||
- `password_policy` (String) | ||
- `pkce_enabled` (Boolean) | ||
- `protocol_binding` (String) | ||
- `provider` (String) | ||
- `request_template` (String) | ||
- `requires_username` (Boolean) | ||
- `scopes` (Set of String) | ||
- `scripts` (Map of String) | ||
- `set_user_root_attributes` (String) | ||
- `should_trust_email_verified_connection` (String) | ||
- `sign_in_endpoint` (String) | ||
- `sign_out_endpoint` (String) | ||
- `sign_saml_request` (Boolean) | ||
- `signature_algorithm` (String) | ||
- `signing_cert` (String) | ||
- `signing_key` (List of Object) (see [below for nested schema](#nestedobjatt--options--signing_key)) | ||
- `strategy_version` (Number) | ||
- `subject` (String) | ||
- `syntax` (String) | ||
- `team_id` (String) | ||
- `template` (String) | ||
- `tenant_domain` (String) | ||
- `token_endpoint` (String) | ||
- `totp` (List of Object) (see [below for nested schema](#nestedobjatt--options--totp)) | ||
- `twilio_sid` (String) | ||
- `twilio_token` (String) | ||
- `type` (String) | ||
- `upstream_params` (String) | ||
- `use_cert_auth` (Boolean) | ||
- `use_kerberos` (Boolean) | ||
- `use_wsfed` (Boolean) | ||
- `user_id_attribute` (String) | ||
- `userinfo_endpoint` (String) | ||
- `validation` (List of Object) (see [below for nested schema](#nestedobjatt--options--validation)) | ||
- `waad_common_endpoint` (Boolean) | ||
- `waad_protocol` (String) | ||
|
||
<a id="nestedobjatt--options--gateway_authentication"></a> | ||
### Nested Schema for `options.gateway_authentication` | ||
|
||
Read-Only: | ||
|
||
- `audience` (String) | ||
- `method` (String) | ||
- `secret` (String) | ||
- `secret_base64_encoded` (Boolean) | ||
- `subject` (String) | ||
|
||
|
||
<a id="nestedobjatt--options--idp_initiated"></a> | ||
### Nested Schema for `options.idp_initiated` | ||
|
||
Read-Only: | ||
|
||
- `client_authorize_query` (String) | ||
- `client_id` (String) | ||
- `client_protocol` (String) | ||
|
||
|
||
<a id="nestedobjatt--options--mfa"></a> | ||
### Nested Schema for `options.mfa` | ||
|
||
Read-Only: | ||
|
||
- `active` (Boolean) | ||
- `return_enroll_settings` (Boolean) | ||
|
||
|
||
<a id="nestedobjatt--options--password_complexity_options"></a> | ||
### Nested Schema for `options.password_complexity_options` | ||
|
||
Read-Only: | ||
|
||
- `min_length` (Number) | ||
|
||
|
||
<a id="nestedobjatt--options--password_dictionary"></a> | ||
### Nested Schema for `options.password_dictionary` | ||
|
||
Read-Only: | ||
|
||
- `dictionary` (Set of String) | ||
- `enable` (Boolean) | ||
|
||
|
||
<a id="nestedobjatt--options--password_history"></a> | ||
### Nested Schema for `options.password_history` | ||
|
||
Read-Only: | ||
|
||
- `enable` (Boolean) | ||
- `size` (Number) | ||
|
||
|
||
<a id="nestedobjatt--options--password_no_personal_info"></a> | ||
### Nested Schema for `options.password_no_personal_info` | ||
|
||
Read-Only: | ||
|
||
- `enable` (Boolean) | ||
|
||
|
||
<a id="nestedobjatt--options--signing_key"></a> | ||
### Nested Schema for `options.signing_key` | ||
|
||
Read-Only: | ||
|
||
- `cert` (String) | ||
- `key` (String) | ||
|
||
|
||
<a id="nestedobjatt--options--totp"></a> | ||
### Nested Schema for `options.totp` | ||
|
||
Read-Only: | ||
|
||
- `length` (Number) | ||
- `time_step` (Number) | ||
|
||
|
||
<a id="nestedobjatt--options--validation"></a> | ||
### Nested Schema for `options.validation` | ||
|
||
Read-Only: | ||
|
||
- `username` (List of Object) (see [below for nested schema](#nestedobjatt--options--validation--username)) | ||
|
||
<a id="nestedobjatt--options--validation--username"></a> | ||
### Nested Schema for `options.validation.username` | ||
|
||
Read-Only: | ||
|
||
- `max` (Number) | ||
- `min` (Number) | ||
|
||
|
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,72 @@ | ||
package connection | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/auth0/go-auth0/management" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema" | ||
) | ||
|
||
// NewDataSource will return a new auth0_connection_client data source. | ||
func NewDataSource() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: readConnectionForDataSource, | ||
Description: "Data source to retrieve a specific Auth0 connection by `connection_id` or `name`.", | ||
Schema: dataSourceSchema(), | ||
} | ||
} | ||
|
||
func dataSourceSchema() map[string]*schema.Schema { | ||
dataSourceSchema := internalSchema.TransformResourceToDataSource(NewResource().Schema) | ||
dataSourceSchema["connection_id"] = &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The ID of the connection. If not provided, `name` must be set.", | ||
AtLeastOneOf: []string{"connection_id", "name"}, | ||
} | ||
|
||
internalSchema.SetExistingAttributesAsOptional(dataSourceSchema, "name") | ||
dataSourceSchema["name"].Description = "The name of the connection. If not provided, `connection_id` must be set." | ||
dataSourceSchema["name"].AtLeastOneOf = []string{"connection_id", "name"} | ||
|
||
return dataSourceSchema | ||
} | ||
|
||
func readConnectionForDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
connectionID := data.Get("connection_id").(string) | ||
if connectionID != "" { | ||
data.SetId(connectionID) | ||
return readConnection(ctx, data, meta) | ||
} | ||
|
||
api := meta.(*management.Management) | ||
name := data.Get("name").(string) | ||
page := 0 | ||
for { | ||
connections, err := api.Connection.List( | ||
management.IncludeFields("id", "name"), | ||
management.Page(page), | ||
) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
for _, connection := range connections.Connections { | ||
if connection.GetName() == name { | ||
data.SetId(connection.GetID()) | ||
return readConnection(ctx, data, meta) | ||
} | ||
} | ||
|
||
if !connections.HasNext() { | ||
break | ||
} | ||
|
||
page++ | ||
} | ||
|
||
return diag.Errorf("No connection found with \"name\" = %q", name) | ||
} |
Oops, something went wrong.