2016-09-23 40 views
1

我目前正在建立一个使用https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server和asp.net核心身份作为后备存储的openid连接服务器。我知道协议,流程和安全漏洞。openidconnect.server,第三方提供商和重定向

当前设置如下: [server] - 授权服务器&资源服务器 [front-end] - 一个angularJS应用 [third-party-provider] - 谷歌 [external-app] - 其中要使用从[服务器]

的令牌的第二应用[front-end][external-app]都已注册为[server]的客户端。所以,他们被允许检索令牌。登录页面内置于[front-end]

请记住,登录页面等由[front-end]应用程序(而不是返回从一个的AccountController AuthView)

所示想象我愿意与[external-app]登录到从[server]得到一个身份。登录页面显示为[front-end]。然后,该流程将是以下几点:

1. [external-app] -> http://[server]/account/authorize?client_id=[external-  
    app-clientid]&response_type=token&redirect_uri=http://[external-app- 
    redirecturi] 
2. [front-end] -> matches route -> show login page 
3. [front-end] -> user clicks on login with google 
4. [front-end] -> redirect to 'http://[server]/account/authorize/connect? 
    provider=Google&redirect_uri=http://[front- 
    end]/account/thirdparty/authorized&response_type=code&client_id=[front- 
    end-clientid] 
5. [server] -> no identity found, save request in session and let the user 
    login at the [third-party] (using ChallengeResult and also passing in the 
    request id which was stored in session) 
6. [third-party-provider] user logs in 
7. [front-end] -> http://[front-end]/account/thirdparty/authorized recieved 
    the code 
8. [front-end] -> exchange authcode for token with [server] using 
    http://[server]/account/token&grant_type=authorization_code&code= 
    [code]&redirect_uri=http://[front- 
    end]/account/thirdparty/authorized&client=[front-end-clientid] 
9. [server] -> generate claims and return token 
10. [front-end] -> token recieved 

一件事我很想念(这可能是一个程序错误,以为瑕疵或其他)是我需要重定向回[external-app]与给定令牌。我是否需要在[front-end]上做到这一点?它的感觉和我有点确定我混合/匹配的东西错了。谁能帮我吗?

在此先感谢!

PS是的,我知道,应该是https。以上仅为举例目的;)

+0

您确定要构建自己的openid连接服务器吗?您可能有充分的理由这么做,但我想我会提及已经实施的解决方案,它完全符合您要实现的目标。看看Identity Server:https://github.com/IdentityServer/IdentityServer4 – henningst

+0

我目前使用https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server,所以我没有做这一切都在我自己的...但我需要有一些帮助重定向流:)我会更新我的问题,以反映即时通讯使用这个库的事实! –

回答

0

对于类似于隐式流的交互式流,需要记住的重要一点是您必须将用户重定向到身份提供者的授权端点,以便有机会准备授权响应。

您可以自由决定您的身份提供程序在收到授权请求和授权响应返回之间会发生什么,但您无法将用户从“前端”应用程序直接重定向到“外部应用程序”,因为它无法生成授权响应(这不是它的作用)。

考虑重新设计流程,以便您的前端应用程序将您的用户重定向到授权服务器,该授权服务器将自行将其重定向到您的外部应用程序。

+0

我们谈话后,我完全按照您的建议做了,重做流程。它现在工作完美无缺:) 我对这个事实感到困惑,因为'[front-end]'有两个工作,例如,登录'[前端]'本身,但也作为'[external-app]'的授权端点。将它们看作两个独立的过程使一切变得清晰。 再次感谢您的帮助! –

相关问题