首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OAuth承载令牌认证授权码

OAuth承载令牌认证授权码
EN

Stack Overflow用户
提问于 2017-08-30 05:49:25
回答 1查看 564关注 0票数 1

目前,我们的cookie MVC系统是使用OpenIdConnect和cookie身份验证来保护的。我们已经使用azure active directory启用了oauth身份验证流。

代码语言:javascript
复制
    public void ConfigureAuthOpenIdConnect(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        var cookieAuthenticationOptions = new CookieAuthenticationOptions()
        {
           //...
        };

        app.UseCookieAuthentication(cookieAuthenticationOptions);

        var notifications = new OAOpenIdConnectAuthenticationNotifications();
        var openIdConnectAuthenticationOptions = new OpenIdConnectAuthenticationOptions()
        {
            //...
            Notifications = notifications
        };

        app.UseOpenIdConnectAuthentication(openIdConnectAuthenticationOptions);

        app.UseWindowsAzureActiveDirectoryBearerAuthentication(
           new WindowsAzureActiveDirectoryBearerAuthenticationOptions
           {
               Tenant = ConfigHelper.ClientSettings.TenantName,
               TokenValidationParameters = new TokenValidationParameters
               {
                   ValidAudience = ConfigHelper.ClientSettings.ClientId
               }
           });
    }

现在,当我们通过OpenIdConnect进行身份验证时,我们使用OpenIdConnectAuthenticationOptions选项上的自定义Notifications检索授权码,这使我们能够使用ADAL请求和缓存资源令牌。

当一个人尝试使用azure AD承载令牌访问我们的系统时,就会出现这个问题,这个获取和缓存资源令牌的工作流程并不存在。

因此,我的问题是,如何使用持有者令牌启用此功能?如何像我们使用OpenIdConnect那样请求额外的资源令牌?是否可以使用ADAL从持有者令牌获取授权码?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-30 11:22:35

正如你所提到的,你正在使用OpenID连接ASP.NET中间件和ADAL .NET来使用Azure AD进行登录,然后在OnAuthorizationCodeReceived OpenID连接通知中调用登录用户身份下的web API。

在这种情况下,您可以使用授权码将其交换为特定资源的访问令牌。

另一方面,当客户端应用程序使用azure AD承载令牌访问您的系统时,没有授权码。在此场景中,如果您希望使用该访问令牌将其交换到另一个资源访问令牌,例如Microsoft Graph,则可以使用OAuth 2.0 On-Behalf-Of flow。OAuth 2.0代表流程服务于应用程序调用服务/web的用例,而服务/web又需要调用另一个服务/web。

有关协议在此方案中如何工作的更多信息,请参阅Authentication Scenarios for Azure ADOn-Behalf-Of flow tutorial。当然,您也可以使用ADAL.NET来执行代表流程,请参阅this code sample

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45948827

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档