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

[10/X] DXCDT-441: Reintroduce support for firebase client addon #666

Merged
merged 1 commit into from
Jun 29, 2023
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
13 changes: 13 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Read-Only:
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))
- `echosign` (List of Object) (see [below for nested schema](#nestedobjatt--addons--echosign))
- `egnyte` (List of Object) (see [below for nested schema](#nestedobjatt--addons--egnyte))
- `firebase` (List of Object) (see [below for nested schema](#nestedobjatt--addons--firebase))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
Expand Down Expand Up @@ -141,6 +142,18 @@ Read-Only:
- `domain` (String)


<a id="nestedobjatt--addons--firebase"></a>
### Nested Schema for `addons.firebase`

Read-Only:

- `client_email` (String)
- `lifetime_in_seconds` (Number)
- `private_key` (String)
- `private_key_id` (String)
- `secret` (String)


<a id="nestedobjatt--addons--mscrm"></a>
### Nested Schema for `addons.mscrm`

Expand Down
13 changes: 13 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Read-Only:
- `azure_sb` (List of Object) (see [below for nested schema](#nestedobjatt--addons--azure_sb))
- `echosign` (List of Object) (see [below for nested schema](#nestedobjatt--addons--echosign))
- `egnyte` (List of Object) (see [below for nested schema](#nestedobjatt--addons--egnyte))
- `firebase` (List of Object) (see [below for nested schema](#nestedobjatt--addons--firebase))
- `mscrm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--mscrm))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
Expand Down Expand Up @@ -130,6 +131,18 @@ Read-Only:
- `domain` (String)


<a id="nestedobjatt--addons--firebase"></a>
### Nested Schema for `addons.firebase`

Read-Only:

- `client_email` (String)
- `lifetime_in_seconds` (Number)
- `private_key` (String)
- `private_key_id` (String)
- `secret` (String)


<a id="nestedobjatt--addons--mscrm"></a>
### Nested Schema for `addons.mscrm`

Expand Down
13 changes: 13 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Optional:
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))
- `echosign` (Block List, Max: 1) Adobe EchoSign SSO configuration. (see [below for nested schema](#nestedblock--addons--echosign))
- `egnyte` (Block List, Max: 1) Egnyte SSO configuration. (see [below for nested schema](#nestedblock--addons--egnyte))
- `firebase` (Block List, Max: 1) Google Firebase addon configuration. (see [below for nested schema](#nestedblock--addons--firebase))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
Expand Down Expand Up @@ -203,6 +204,18 @@ Optional:
- `domain` (String) Your custom domain found in your Egnyte URL, for example `https://acme-org.echosign.com` would be `acme-org`.


<a id="nestedblock--addons--firebase"></a>
### Nested Schema for `addons.firebase`

Optional:

- `client_email` (String) ID of the Service Account you have created (shown as `client_email` in the generated JSON file, SDK v3+ tokens only).
- `lifetime_in_seconds` (Number) Optional expiration in seconds for the generated token. Defaults to 3600 seconds (SDK v3+ tokens only).
- `private_key` (String, Sensitive) Private Key for signing the token (SDK v3+ tokens only).
- `private_key_id` (String, Sensitive) Optional ID of the private key to obtain the `kid` header claim from the issued token (SDK v3+ tokens only).
- `secret` (String, Sensitive) Google Firebase Secret. (SDK v2 only).


<a id="nestedblock--addons--mscrm"></a>
### Nested Schema for `addons.mscrm`

Expand Down
13 changes: 13 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Optional:
- `azure_sb` (Block List, Max: 1) Azure Storage Bus Addon configuration. (see [below for nested schema](#nestedblock--addons--azure_sb))
- `echosign` (Block List, Max: 1) Adobe EchoSign SSO configuration. (see [below for nested schema](#nestedblock--addons--echosign))
- `egnyte` (Block List, Max: 1) Egnyte SSO configuration. (see [below for nested schema](#nestedblock--addons--egnyte))
- `firebase` (Block List, Max: 1) Google Firebase addon configuration. (see [below for nested schema](#nestedblock--addons--firebase))
- `mscrm` (Block List, Max: 1) Microsoft Dynamics CRM SSO configuration. (see [below for nested schema](#nestedblock--addons--mscrm))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
Expand Down Expand Up @@ -146,6 +147,18 @@ Optional:
- `domain` (String) Your custom domain found in your Egnyte URL, for example `https://acme-org.echosign.com` would be `acme-org`.


<a id="nestedblock--addons--firebase"></a>
### Nested Schema for `addons.firebase`

Optional:

- `client_email` (String) ID of the Service Account you have created (shown as `client_email` in the generated JSON file, SDK v3+ tokens only).
- `lifetime_in_seconds` (Number) Optional expiration in seconds for the generated token. Defaults to 3600 seconds (SDK v3+ tokens only).
- `private_key` (String, Sensitive) Private Key for signing the token (SDK v3+ tokens only).
- `private_key_id` (String, Sensitive) Optional ID of the private key to obtain the `kid` header claim from the issued token (SDK v3+ tokens only).
- `secret` (String, Sensitive) Google Firebase Secret. (SDK v2 only).


<a id="nestedblock--addons--mscrm"></a>
### Nested Schema for `addons.mscrm`

Expand Down
19 changes: 19 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.Sentry = expandClientAddonSentry(addonsCfg.GetAttr("sentry"))
addons.EchoSign = expandClientAddonEchoSign(addonsCfg.GetAttr("echosign"))
addons.Egnyte = expandClientAddonEgnyte(addonsCfg.GetAttr("egnyte"))
addons.Firebase = expandClientAddonFirebase(addonsCfg.GetAttr("firebase"))
return stop
})

Expand Down Expand Up @@ -420,6 +421,24 @@ func expandClientAddonEgnyte(egnyteCfg cty.Value) *management.EgnyteClientAddon
return &egnyteAddon
}

func expandClientAddonFirebase(firebaseCfg cty.Value) *management.FirebaseClientAddon {
var firebaseAddon management.FirebaseClientAddon

firebaseCfg.ForEachElement(func(_ cty.Value, firebaseCfg cty.Value) (stop bool) {
firebaseAddon = management.FirebaseClientAddon{
Secret: value.String(firebaseCfg.GetAttr("secret")),
PrivateKeyID: value.String(firebaseCfg.GetAttr("private_key_id")),
PrivateKey: value.String(firebaseCfg.GetAttr("private_key")),
ClientEmail: value.String(firebaseCfg.GetAttr("client_email")),
LifetimeInSeconds: value.Int(firebaseCfg.GetAttr("lifetime_in_seconds")),
}

return stop
})

return &firebaseAddon
}

func clientHasChange(c *management.Client) bool {
return c.String() != "{}"
}
13 changes: 13 additions & 0 deletions internal/auth0/client/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"sentry": nil,
"echosign": nil,
"egnyte": nil,
"firebase": nil,
}

if addons.GetAWS() != nil {
Expand Down Expand Up @@ -197,5 +198,17 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
}
}

if addons.GetFirebase() != nil {
m["firebase"] = []interface{}{
map[string]interface{}{
"secret": addons.GetFirebase().GetSecret(),
"private_key_id": addons.GetFirebase().GetPrivateKeyID(),
"private_key": addons.GetFirebase().GetPrivateKey(),
"client_email": addons.GetFirebase().GetClientEmail(),
"lifetime_in_seconds": addons.GetFirebase().GetLifetimeInSeconds(),
},
}
}

return []interface{}{m}
}
42 changes: 42 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,48 @@ func NewResource() *schema.Resource {
},
},
},
"firebase": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Google Firebase addon configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"secret": {
Description: "Google Firebase Secret. (SDK v2 only).",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"private_key_id": {
Description: "Optional ID of the private key to obtain the `kid` header " +
"claim from the issued token (SDK v3+ tokens only).",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"private_key": {
Description: "Private Key for signing the token (SDK v3+ tokens only).",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"client_email": {
Description: "ID of the Service Account you have created (shown as " +
"`client_email` in the generated JSON file, SDK v3+ tokens only).",
Type: schema.TypeString,
Optional: true,
},
"lifetime_in_seconds": {
Description: "Optional expiration in seconds for the generated token. " +
"Defaults to 3600 seconds (SDK v3+ tokens only).",
Type: schema.TypeInt,
Optional: true,
},
},
},
},
},
},
},
Expand Down
30 changes: 30 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,23 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsFirebase = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"

addons {
firebase {
secret = "secret"
private_key_id = "private-key-id"
private_key = "private-key"
client_email = "service-account"
lifetime_in_seconds = 7200
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -977,6 +994,19 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.egnyte.0.domain", "acmeorg"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsFirebase, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_client.my_client", "name", fmt.Sprintf("Acceptance Test - SSO Integration - %s", t.Name())),
resource.TestCheckResourceAttr("auth0_client.my_client", "app_type", "sso_integration"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.firebase.0.secret", "secret"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.firebase.0.private_key_id", "private-key-id"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.firebase.0.private_key", "private-key"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.firebase.0.client_email", "service-account"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.firebase.0.lifetime_in_seconds", "7200"),
),
},
},
})
}
Expand Down
Loading