无需客户端 ID 和客户端密钥即可对 Azure 应用程序资源管理进行授权

我正在尝试创建一个应用程序,用户可以在其中管理其 Azure 资源(sql 数据库、存储)。如何在不需要用户的客户端 ID 和客户端密码的情况下授权用户。

我查看了他们的文档:https://godoc.org/github.com/Azure/go-autorest/autorest/azure/auth,但是它们都需要环境变量和/或 clientID/clientSecret。有没有一种方法可以让用户提供用户名/密码,然后我可以找回授权人

type Client struct {

    ServersClient postgresql.ServersClient

}


func NewCloudClient() *Client {

    return &Client{}

}


func (c *Client) Init(config map[string]string) error {

    var (

        subscriptionID = config["subscriptionID"]

        // tenantID       = config["tenantID"]

        // clientID       = config["clientID"]

        // clientSecret   = config["clientSecret"]

        // resourceGroup  = config["resourceGroup"]

    )

    // oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, tenantID)

    // if err != nil {

    //  return errors.Wrap(err, "error getting OAuthConfig")

    // }

    // spt, err := adal.NewServicePrincipalToken(*oauthConfig, clientID, clientSecret, resourceGroup)

    serversClient := postgresql.NewServersClient(subscriptionID)


    //serversClient.BaseClient.Authorizer = autorest.NewBearerAuthorizer(spt)

    c.ServersClient = serversClient

    return nil

}


MMMHUHU
浏览 102回答 1
1回答

哆啦的时光机

在授权流程的所有情况下,您至少需要client id。在某些情况下,您将需要更多类似client Secret的内容。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go