Skip to content

Commit

Permalink
Update usages of the Go SDK to match beta branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 27, 2023
1 parent a399d5e commit 8c2063a
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 2 deletions.
56 changes: 56 additions & 0 deletions internal/auth0/client/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,59 @@ func flattenClientMobile(mobile *management.ClientMobile) []interface{} {

return []interface{}{m}
}

func flattenClientAddons(addons *management.ClientAddons) []interface{} {
if addons == nil {
return nil
}

m := map[string]interface{}{
"aws": nil,
"azure_blob": nil,
"azure_sb": nil,
}

if addons.GetAWS() != nil {
m["aws"] = []interface{}{
map[string]interface{}{
"principal": addons.GetAWS().GetPrincipal(),
"role": addons.GetAWS().GetRole(),
"lifetime_in_seconds": addons.GetAWS().GetLifetimeInSeconds(),
},
}
}

if addons.GetAzureBlob() != nil {
m["azure_blob"] = []interface{}{
map[string]interface{}{
"account_name": addons.GetAzureBlob().GetAccountName(),
"storage_access_key": addons.GetAzureBlob().GetStorageAccessKey(),
"container_name": addons.GetAzureBlob().GetContainerName(),
"blob_name": addons.GetAzureBlob().GetBlobName(),
"expiration": addons.GetAzureBlob().GetExpiration(),
"signed_identifier": addons.GetAzureBlob().GetSignedIdentifier(),
"blob_read": addons.GetAzureBlob().GetBlobRead(),
"blob_write": addons.GetAzureBlob().GetBlobWrite(),
"blob_delete": addons.GetAzureBlob().GetBlobDelete(),
"container_read": addons.GetAzureBlob().GetContainerRead(),
"container_write": addons.GetAzureBlob().GetContainerWrite(),
"container_delete": addons.GetAzureBlob().GetContainerDelete(),
"container_list": addons.GetAzureBlob().GetContainerList(),
},
}
}

if addons.GetAzureSB() != nil {
m["azure_sb"] = []interface{}{
map[string]interface{}{
"namespace": addons.GetAzureSB().GetNamespace(),
"sas_key_name": addons.GetAzureSB().GetSASKeyName(),
"sas_key": addons.GetAzureSB().GetSASKey(),
"entity_path": addons.GetAzureSB().GetEntityPath(),
"expiration": addons.GetAzureSB().GetExpiration(),
},
}
}

return []interface{}{m}
}
172 changes: 171 additions & 1 deletion internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,176 @@ func NewResource() *schema.Resource {
Description: "List containing a map of the public cert of the signing key and the public cert " +
"of the signing key in PKCS7.",
},
"addons": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Addons enabled for this client and their associated configurations.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"aws": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "AWS Addon configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"principal": {
Description: "AWS principal ARN, for example `arn:aws:iam::010616021751:saml-provider/idpname`.",
Type: schema.TypeString,
Optional: true,
},
"role": {
Description: "AWS role ARN, for example `arn:aws:iam::010616021751:role/foo`.",
Type: schema.TypeString,
Optional: true,
},
"lifetime_in_seconds": {
Description: "AWS token lifetime in seconds.",
Type: schema.TypeInt,
ValidateFunc: validation.IntBetween(900, 43200),
Optional: true,
},
},
},
},
"azure_blob": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Azure Blob Storage Addon configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_name": {
Description: "Your Azure storage account name. Usually first segment in your " +
"Azure storage URL, for example `https://acme-org.blob.core.windows.net` would " +
"be the account name `acme-org`.",
Type: schema.TypeString,
Optional: true,
},
"storage_access_key": {
Description: "Access key associated with this storage account.",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"container_name": {
Description: "Container to request a token for, such as `my-container`.",
Type: schema.TypeString,
Optional: true,
},
"blob_name": {
Description: "Entity to request a token for, such as `my-blob`. If blank the " +
"computed SAS will apply to the entire storage container.",
Type: schema.TypeString,
Optional: true,
},
"expiration": {
Description: "Expiration in minutes for the generated token (default of 5 minutes).",
Type: schema.TypeInt,
ValidateFunc: validation.IntAtLeast(0),
Optional: true,
},
"signed_identifier": {
Description: "Shared access policy identifier defined in your storage account resource.",
Type: schema.TypeString,
Optional: true,
},
"blob_read": {
Description: "Indicates if the issued token has permission to read the " +
"content, properties, metadata and block list. Use the blob as the " +
"source of a copy operation.",
Type: schema.TypeBool,
Optional: true,
},
"blob_write": {
Description: "Indicates if the issued token has permission to create or " +
"write content, properties, metadata, or block list. Snapshot or lease " +
"the blob. Resize the blob (page blob only). Use the blob as the " +
"destination of a copy operation within the same account.",
Type: schema.TypeBool,
Optional: true,
},
"blob_delete": {
Description: "Indicates if the issued token has permission to delete the blob.",
Type: schema.TypeBool,
Optional: true,
},
"container_read": {
Description: "Indicates if the issued token has permission to read the " +
"content, properties, metadata or block list of any blob in the " +
"container. Use any blob in the container as the source of a copy operation.",
Type: schema.TypeBool,
Optional: true,
},
"container_write": {
Description: "Indicates that for any blob in the container if the issued " +
"token has permission to create or write content, properties, metadata, " +
"or block list. Snapshot or lease the blob. Resize the blob " +
"(page blob only). Use the blob as the destination of a copy operation " +
"within the same account.",
Type: schema.TypeBool,
Optional: true,
},
"container_delete": {
Description: "Indicates if issued token has permission to delete any blob in " +
"the container.",
Type: schema.TypeBool,
Optional: true,
},
"container_list": {
Description: "Indicates if the issued token has permission to list blobs in the container.",
Type: schema.TypeBool,
Optional: true,
},
},
},
},
"azure_sb": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Azure Storage Bus Addon configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"namespace": {
Description: "Your Azure Service Bus namespace. Usually the first segment of " +
"your Service Bus URL (for example `https://acme-org.servicebus.windows.net` " +
"would be `acme-org`).",
Type: schema.TypeString,
Optional: true,
},
"sas_key_name": {
Description: "Your shared access policy name defined in your Service Bus entity.",
Type: schema.TypeString,
Optional: true,
},
"sas_key": {
Description: "Primary Key associated with your shared access policy.",
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"entity_path": {
Description: "Entity you want to request a token for, such as `my-queue`.",
Type: schema.TypeString,
Optional: true,
},
"expiration": {
Description: "Optional expiration in minutes for the generated token. Defaults to 5 minutes.",
Type: schema.TypeInt,
ValidateFunc: validation.IntAtLeast(0),
Optional: true,
},
},
},
},
},
},
},
},
}
}
Expand Down Expand Up @@ -541,7 +711,7 @@ func readClient(ctx context.Context, d *schema.ResourceData, m interface{}) diag
d.Set("jwt_configuration", flattenClientJwtConfiguration(client.GetJWTConfiguration())),
d.Set("refresh_token", flattenClientRefreshTokenConfiguration(client.GetRefreshToken())),
d.Set("encryption_key", client.GetEncryptionKey()),
// D.Set("addons", flattenClientAddons(client.Addons)), TODO: DXCDT-441 Add new go-auth0 v1-beta types.
d.Set("addons", flattenClientAddons(client.Addons)),
d.Set("mobile", flattenClientMobile(client.GetMobile())),
d.Set("initiate_login_uri", client.GetInitiateLoginURI()),
d.Set("signing_keys", client.SigningKeys),
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func ConfigureProvider(terraformVersion *string) schema.ConfigureContextFunc {
debug := data.Get("debug").(bool)

apiClient, err := management.New(domain,
authenticationOption(clientID, clientSecret, apiToken, audience),
authenticationOption(ctx, clientID, clientSecret, apiToken, audience),
management.WithDebug(debug),
management.WithUserAgent(userAgent(terraformVersion)),
management.WithAuth0ClientEnvEntry(providerName, version),
Expand Down

0 comments on commit 8c2063a

Please sign in to comment.