私はIdentityServer3で保護しようとしている非常に単純なMVC5のWebサイトを持っています。なぜIdentityServerはhttpsではなくhttpにリダイレクトされますか?
私のウェブサイトと私のIdentityServerインスタンスの両方がAppHarborで別々のサイトとしてホストされています。どちらもhttpsの後ろにあります。
[Authorize]
属性(例:/Home/About
)で保護されている自分のウェブサイトのリソースにヒットした場合、正常にIdentityServerにリダイレクトされ、正常に認証できます。
IdentityServerがWebサイトに返信すると(app.FormPostResponse.js
を介して)、Webサイトは要求されたリソースへの302リダイレクトで応答します。しかし、このリダイレクトはへのhttp、ないHTTPS(下のネットワークトレースを参照)です。
私は、これはちょうど私のIdentityServerの設定に何か問題であると確信しているが、私は間違って持っているものに関しては任意のポインタをいただければと思います。
(AppHarborはSSLが終了IIS、目の前にリバースプロキシ(私は信じているnginxの)を使用しています - 。IdentityServerのドキュメントごとに、私はこのシナリオのRequireSsl = false
を持っている)
ここでは私のウェブサイトのStartup.cs
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "https://<my-idsrv3>.apphb.com/identity",
ClientId = "<my-client-id>",
Scope = "openid profile roles email",
RedirectUri = "https://<my-website>.apphb.com",
ResponseType = "id_token",
SignInAsAuthenticationType = "Cookies",
UseTokenLifetime = false
});
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
}
}
はStartup.csは私のIdentityServer3インスタンスからである。ここでは
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Map("/identity", idsrvApp =>
{
idsrvApp.UseIdentityServer(new IdentityServerOptions
{
SiteName = "My Identity Server",
SigningCertificate = Certificates.LoadSigningCertificate(),
RequireSsl = false,
PublicOrigin = "https://<my-idsrv3>.apphb.com",
Factory = new IdentityServerServiceFactory()
.UseInMemoryUsers(Users.Get())
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get())
});
});
}
}
は私のウェブサイトの定義ですクライアント:
new Client
{
Enabled = true,
ClientName = "My Website Client",
ClientId = "<my-client-id>",
Flow = Flows.Implicit,
RedirectUris = new List<string>
{
"https://<my-website>.apphb.com"
},
AllowAccessToAllScopes = true
}
ここではIdentityServerの同意画面で「はい、許可する」をクリックした後、Chromeからのトレースです: