Skip to content

Commit

Permalink
azuread_client_config: return an error is object_id is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Dec 16, 2020
1 parent dbf80fc commit 6f7c4d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-uuid v1.0.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.3.0
github.com/hashicorp/terraform-plugin-test/v2 v2.1.2 // indirect
github.com/manicminer/hamilton v0.0.0-20201215144252-45b848b5f3fc
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package serviceprincipals

import (
"context"
"errors"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand All @@ -14,9 +15,9 @@ import (
func clientConfigDataSourceReadMsGraph(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*clients.Client)

objectId := ""
if client.Claims.ObjectId != "" {
objectId = client.Claims.ObjectId
objectId := client.Claims.ObjectId
if client.Claims.ObjectId == "" {
return tf.ErrorDiagPathF(errors.New("oid claim in access token is empty"), "object_id", "Could not determine object ID of authenticated principal")
}

d.SetId(fmt.Sprintf("%s-%s-%s", client.TenantID, client.ClientID, objectId))
Expand Down

0 comments on commit 6f7c4d8

Please sign in to comment.