Skip to content

Commit

Permalink
Merge pull request #206 from auth0/add-metadata-fields-samlp-connections
Browse files Browse the repository at this point in the history
Add metadata URL and metadata XML fields for SAMLP connections
  • Loading branch information
willvedd authored Jun 29, 2022
2 parents 0fe365e + 1145256 commit 0e322a9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
10 changes: 10 additions & 0 deletions auth0/resource_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,16 @@ var connectionSchema = map[string]*schema.Schema{
Optional: true,
Description: "When enabled, will disable sign out.",
},
"metadata_xml": {
Type: schema.TypeString,
Optional: true,
Description: "The XML content for the SAML metadata document.",
},
"metadata_url": {
Type: schema.TypeString,
Optional: true,
Description: "The URL of the SAML metadata document.",
},
"fields_map": {
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
Expand Down
9 changes: 9 additions & 0 deletions auth0/resource_auth0_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,8 @@ func TestAccConnectionSAML(t *testing.T) {
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.disable_sign_out", "false"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.entity_id", ""),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.idp_initiated.0.client_authorize_query", "type=code&timeout=30"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.metadata_url", ""),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.metadata_xml", "<?xml version=\"1.0\" encoding=\"utf-8\"?><EntityDescriptor ID=\"_391f377b-78d8-54132-1d47-a130e933bb1c\" entityID=\"https://example.com\" xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\"></EntityDescriptor>"),
),
},
{
Expand All @@ -1351,6 +1353,9 @@ func TestAccConnectionSAML(t *testing.T) {
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.sign_out_endpoint", ""),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.disable_sign_out", "true"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.entity_id", "example"),

resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.metadata_url", "https://saml.provider/imi/ns/FederationMetadata.xml"),
resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.metadata_xml", ""),
),
},
},
Expand Down Expand Up @@ -1409,6 +1414,8 @@ EOF
client_protocol = "samlp"
client_authorize_query = "type=code&timeout=30"
}
metadata_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><EntityDescriptor ID=\"_391f377b-78d8-54132-1d47-a130e933bb1c\" entityID=\"https://example.com\" xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\"></EntityDescriptor>"
metadata_url = ""
}
}
`
Expand Down Expand Up @@ -1463,6 +1470,8 @@ EOF
client_protocol = "samlp"
client_authorize_query = "type=code&timeout=60"
}
metadata_xml = ""
metadata_url = "https://saml.provider/imi/ns/FederationMetadata.xml"
}
}
`
4 changes: 4 additions & 0 deletions auth0/structure_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ func flattenConnectionOptionsSAML(options *management.ConnectionOptionsSAML) int
"set_user_root_attributes": options.GetSetUserAttributes(),
"non_persistent_attrs": options.GetNonPersistentAttrs(),
"entity_id": options.GetEntityID(),
"metadata_url": options.GetMetadataURL(),
"metadata_xml": options.GetMetadataXML(),
}

if options.IdpInitiated != nil {
Expand Down Expand Up @@ -781,6 +783,8 @@ func expandConnectionOptionsSAML(d ResourceData) *management.ConnectionOptionsSA
SetUserAttributes: String(d, "set_user_root_attributes"),
NonPersistentAttrs: castToListOfStrings(Set(d, "non_persistent_attrs").List()),
EntityID: String(d, "entity_id"),
MetadataXML: String(d, "metadata_xml"),
MetadataURL: String(d, "metadata_url"),
}

List(d, "idp_initiated").Elem(func(d ResourceData) {
Expand Down
Loading

0 comments on commit 0e322a9

Please sign in to comment.