瀏覽代碼

feat(go): read creds from env vars;

Vishal Dalwadi 5 月之前
父節點
當前提交
77d7051381
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      pro/idp/azure/azure.go

+ 7 - 1
pro/idp/azure/azure.go

@@ -7,6 +7,7 @@ import (
 	msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
 	msgraphgroups "github.com/microsoftgraph/msgraph-sdk-go/groups"
 	msgraphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
+	"os"
 )
 
 type Client struct {
@@ -14,8 +15,13 @@ type Client struct {
 }
 
 func NewAzureEntraIDClient() (*Client, error) {
-	cred, err := azidentity.NewClientSecretCredential("", "", "", nil)
+	tenantID := os.Getenv("AZURE_TENANT")
+	clientID := os.Getenv("CLIENT_ID")
+	clientSecret := os.Getenv("CLIENT_SECRET")
+
+	cred, err := azidentity.NewClientSecretCredential(tenantID, clientID, clientSecret, nil)
 	if err != nil {
+		return nil, err
 	}
 
 	client, err := msgraphsdk.NewGraphServiceClientWithCredentials(cred, nil)