問題:按照Skoruba.IdentityServer4.Admin 切換到騰訊雲的MySQL 安裝運行後,訪問http://localhost:9000/,會導航到5000端口,登錄成功後一直停留在5000端口的登錄頁面,地址如下:
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"
}