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

Commit

Permalink
Merge pull request #467 from alexkappa/fix-connection-strategy-adfs
Browse files Browse the repository at this point in the history
Flatten/expand ADFS
  • Loading branch information
alexkappa authored Nov 9, 2021
2 parents 0fe4bc3 + 6b69061 commit 12e4017
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
28 changes: 28 additions & 0 deletions auth0/structure_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func flattenConnectionOptions(d ResourceData, options interface{}) []interface{}
m = flattenConnectionOptionsAD(o)
case *management.ConnectionOptionsAzureAD:
m = flattenConnectionOptionsAzureAD(o)
case *management.ConnectionOptionsADFS:
m = flattenConnectionOptionsADFS(o)
case *management.ConnectionOptionsSAML:
m = flattenConnectionOptionsSAML(o)
}
Expand Down Expand Up @@ -250,6 +252,18 @@ func flattenConnectionOptionsAzureAD(o *management.ConnectionOptionsAzureAD) int
}
}

func flattenConnectionOptionsADFS(o *management.ConnectionOptionsADFS) interface{} {
return map[string]interface{}{
"tenant_domain": o.GetTenantDomain(),
"domain_aliases": o.DomainAliases,
"icon_url": o.GetLogoURL(),
"adfs_server": o.GetADFSServer(),
"api_enable_users": o.GetEnableUsersAPI(),
"set_user_root_attributes": o.GetSetUserAttributes(),
"non_persistent_attrs": o.GetNonPersistentAttrs(),
}
}

func flattenConnectionOptionsSAML(o *management.ConnectionOptionsSAML) interface{} {
return map[string]interface{}{
"signing_cert": o.GetSigningCert(),
Expand Down Expand Up @@ -323,6 +337,8 @@ func expandConnection(d ResourceData) *management.Connection {
c.Options = expandConnectionOptionsEmail(d)
case management.ConnectionStrategySAML:
c.Options = expandConnectionOptionsSAML(d)
case management.ConnectionStrategyADFS:
c.Options = expandConnectionOptionsADFS(d)
default:
log.Printf("[WARN]: Unsupported connection strategy %s", s)
log.Printf("[WARN]: Raise an issue with the auth0 provider in order to support it:")
Expand Down Expand Up @@ -666,6 +682,18 @@ func expandConnectionOptionsSAML(d ResourceData) *management.ConnectionOptionsSA
return o
}

func expandConnectionOptionsADFS(d ResourceData) *management.ConnectionOptionsADFS {
return &management.ConnectionOptionsADFS{
TenantDomain: String(d, "tenant_domain"),
DomainAliases: Slice(d, "domain_aliases"),
LogoURL: String(d, "icon_url"),
ADFSServer: String(d, "adfs_server"),
EnableUsersAPI: Bool(d, "api_enable_users"),
SetUserAttributes: String(d, "set_user_root_attributes"),
NonPersistentAttrs: castToListOfStrings(Set(d, "non_persistent_attrs").List()),
}
}

type scoper interface {
Scopes() []string
SetScopes(enable bool, scopes ...string)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go 1.16
require (
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/terraform-plugin-sdk v1.16.1
gopkg.in/auth0.v5 v5.21.0
gopkg.in/auth0.v5 v5.21.1
)
Loading

0 comments on commit 12e4017

Please sign in to comment.