Skoruba.IdentityServer4.Admin 管理端登录成功后不跳转到首页管理页面

问题:按照Skoruba.IdentityServer4.Admin 切换到腾讯云的MySQL 安装运行后,访问http://localhost:9000/,会导航到5000端口,登录成功后一直停留在5000端口的登录页面,地址如下:

http://localhost:5000/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fresponse_type%3Dtoken%26client_id%3Dskoruba_identity_admin_api_swaggerui%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A5001%252Fswagger%252Foauth2-redirect.html%26scope%3Dskoruba_identity_admin_api%26state%3DU2F0IEZlYiAyOSAyMDIwIDA5OjQwOjI5IEdNVCswODAwICjkuK3lm73moIflh4bml7bpl7Qp

Skoruba.IdentityServer4.Admin 1.0.0-rc1版本,运行成功,前几天一直认为 rc1的版本有问题,苦等新版发布。20多天就是不发新版。只要看源码,怀疑过数据库问题,使用sql server和my sql 都失败,怀疑过初始的数据问题。

1.先发布:Skoruba.IdentityServer4.STS.Identity项目,运行发布目录下的Skoruba.IdentityServer4.STS.Identity.exe或者使用dotnet 命令行 dotnet Skoruba.IdentityServer4.STS.Identity.dll。

2.Skoruba.IdentityServer4.Admin项目更改appsettings.json配置文件,更改"IdentityServerBaseUrl": "http://localhost:5000/"为"IdentityServerBaseUrl": "https://localhost:5001/"。

3.设置Skoruba.IdentityServer4.Admin为启动项目并启动,如果是谷歌新版浏览器会强制使用https那你就悲剧了,我用Microsoft Edge可以正常运行。

登录: http://localhost:9000,自动转到如下

https://localhost:5001/Account/Login

登录成功后的页面:终于可以正常使用了,等Oracle发布了支持.net core 3.1的包,就可以继续升级了。

Chrome禁止http自动转为https,我试过,删除后,运行本项目还会自动增加上。

解决方法

在Chrome浏览器地址栏输入chrome://net-internals/#hsts
在Delete domain security policies 中输入要删除自动转换的域名

原因

将HTTP请求自动转为HTTPS请求是浏览器的默认策略。当浏览器访问过某个HTTPS的网站后,再访问该网站时,一切HTTP请求会自动转为HTTPS请求。
HTTP转为HTTPS的主要原因是为了安全。

实践

在测试时,通过端口直接访问比较简单。在生产环境中,最好通过Nginx配置HTTPS端口映射

 "DatabaseProviderConfiguration": {
    "ProviderType": "MySql"
  },
  "AdminConfiguration": {
    "PageTitle": "Skoruba IdentityServer4 Admin",
    "FaviconUri": "/favicon.ico",
    "IdentityAdminRedirectUri": "http://localhost:9000/signin-oidc",
    "IdentityServerBaseUrl": "https://localhost:5001/",
    "IdentityAdminCookieName": "IdentityServerAdmin",
    "IdentityAdminCookieExpiresUtcHours": 12,
    "RequireHttpsMetadata": false,
    "TokenValidationClaimName": "name",
    "TokenValidationClaimRole": "role",
    "ClientId": "skoruba_identity_admin",
    "ClientSecret": "skoruba_admin_client_secret",
    "OidcResponseType": "code id_token",
    "Scopes": [
      "openid",
      "profile",
      "email",
      "roles"
    ],
    "AdministrationRole": "SkorubaIdentityAdminAdministrator"
  }

发布了181 篇原创文章 · 获赞 35 · 访问量 76万+

猜你喜欢

转载自blog.csdn.net/dacong/article/details/104573267
今日推荐