Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Enrich "options.validation" for Auth0 connection. #42

Closed
hypnoglow opened this issue Aug 26, 2018 · 3 comments
Closed

Enrich "options.validation" for Auth0 connection. #42

hypnoglow opened this issue Aug 26, 2018 · 3 comments
Labels

Comments

@hypnoglow
Copy link
Contributor

hypnoglow commented Aug 26, 2018

As Auth0 documentation states, there is a "options.validation" (defined
as an object), that can be applied to a Connection. Sadly, there are no specific documented
properties for that.

The use case and the problem

I want to set username min and max length for Auth0 database
connection - that options are available to configure through Auth0 UI.

To configure them through the Management API, I need to send the following json structure:

...
"options": {
    "validation": {
        "username": {
            "min": 2,
            "max": 10,
        }
    }

This works, and I also receive the same structure in the connection object
from the API for the "GET connection" request.

So, connection definition in terraform should look like this:

resource "auth0_connection" "default" {
  name     = "My-Database"
  strategy = "auth0"

  options = {
    requires_username = true

    validation = {
      username = {
        min = 5
        max = 15
      }
    }
  }
}

Currently, this does not work, because in the provider "validation" schema is defined as the following:

"validation": {
    Type:     schema.TypeMap,
    Elem:     &schema.Schema{Type: schema.TypeString},
    Optional: true,
},

So terraform wouldn't accept the auth0_connection definition above.

Another bad thing: if create a connection from terraform, then manually set
those validation properties on that connection through the UI, and then apply
the terraform again - they'll reset to default values.

BTW, I think this is related to #40 (same kind of issue)

@hypnoglow
Copy link
Contributor Author

I made it work for the provider using the following code: #43

But that thing looks ugly, especially that mess with []map[string]interface{}-s and similar. I wonder if there is a better way to support validation properties.

@mattfysh
Copy link

also running into something similar, trying to set options.client_id and options.client_secret on a github connection

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity.
Stale issues will be closed after 5 days if no action is taken. If you
think this issue should not be closed, remove the stale label.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants