如果使用SSO来IdentityServer4授权打在每个请求的端点?

问题描述 投票:0回答:1

我使用IdentityServer4从多个ASP.net核心网站实现单点登录。我可以通过一个网站登录,并成功登录我到其他站点。我发现了什么奇怪的,然而,就是我登录到这两个网站后,需要进行身份验证/授权任何页面重定向我回授权端点如果我浏览在此期间其他站点。一个例子:

+-----+--------------------+-------------------------------------+---------------------------------------------------------------------+
| Seq |        Host        |               Request               |                              Response                               |
+-----+--------------------+-------------------------------------+---------------------------------------------------------------------+
|   1 | apple.example.com  | GET /About                          | 302 Found; Location=https://login.example.com/connect/authorize?... |
|   2 | login.example.com  | GET /connect/authorize?...          | 302 Found; Location=https://login.example.com/Account/Login?…       |
|   3 | login.example.com  | GET Account/Login?…                 | 200 OK                                                              |
|   4 | login.example.com  | POST /Account/Login?...             | 302 Found; Location=/connect/authorize/callback?...                 |
|   5 | login.example.com  | GET /connect/authorize/callback?... | 200 OK                                                              |
|   6 | apple.example.com  | POST /signin-oidc                   | 302 Found; Location=https://apple.example.com/About                 |
|   7 | apple.example.com  | GET /About                          | 200 OK                                                              |
|   8 | banana.example.com | GET /About                          | 302 Found; Location=https://login.example.com/connect/authorize?... |
|   9 | login.example.com  | GET /connect/authorize?...          | 200 OK                                                              |
|  10 | banana.example.com | POST /signin-oidc                   | 302 Found; Location=https://banana.example.com/About                |
|  11 | banana.example.com | GET /About                          | 200 OK                                                              |
|  12 | banana.example.com | GET /About                          | 200 OK                                                              |
|  13 | banana.example.com | GET /About                          | 200 OK                                                              |
|  14 | apple.example.com  | GET /About                          | 302 Found; Location=https://login.example.com/connect/authorize?... |
|  15 | login.example.com  | GET /connect/authorize?...          | 200 OK                                                              |
|  16 | apple.example.com  | POST /signin-oidc                   | 302 Found; Location=https://apple.example.com/About                 |
|  17 | apple.example.com  | GET /About                          | 200 OK                                                              |
|  18 | apple.example.com  | GET /About                          | 200 OK                                                              |
+-----+--------------------+-------------------------------------+---------------------------------------------------------------------+

截至SEQ = 11一切正常。我签署了两个站点(苹果和香蕉),但只有进入我的凭据一次。我最后装上banana.example.com的页面。只要我留在该网站上(线12和13),该网站的cookie工作。但如果我上加载apple.example.com另一个页面,它传递我回授权终点,即使我已经验证在该网站上。这就是令我感到诧异。这种情况继续发生 - 无论何时我切换网站,我不得不再次打的身份服务器。我不必重新输入我的凭据,但重定向有点不和谐。我特别关注的是,它会用POST请求来干扰。

我们的网站是这样,这将是普遍地使用用户的多个站点在同一时间,跨栏回往复。

这是它应该工作的方式,或者是有什么毛病我的配置?我预计只需要每个站点一旦击中授权端点。

asp.net-core identityserver4
1个回答
1
投票

您的期望是正确的。请确保您使用不同的cookie名称为每个应用程序,否则它会导致你所描述的具体行为。

您可以在认证服务配置设置cookie的名称:

services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; })
        .AddCookie(options =>
        {
            options.Cookie.Name = "someCookieName";
        })
© www.soinside.com 2019 - 2024. All rights reserved.