【发布时间】:2015-07-08 04:02:40
【问题描述】:
我正在复制Social Sample,但尝试使用此处未显示的其他 OAuth 提供程序,所以我有一些类似这样的代码:
app.UseOAuthAuthentication("test", options =>
{
options.ClientId = "xxx";
options.ClientSecret = "xxx";
options.AuthorizationEndpoint = "xxx";
options.TokenEndpoint = "xxx";
options.CallbackPath = new PathString("/signin-test");
});
我的应用在终止 SSL 的反向代理后面运行。当我需要它为https://myapp.com/signin-test 时,我的redirect_uri 然后变成http://myapp.com/signin-test 之类的东西。
应用只知道 X-Forwarded-Proto HTTP 标头是否设置为“http”或“https”,但似乎没有被检测到。
有没有办法强制 CallbackPath 使用 HTTPS 而不管请求是否这样做?或者其他方式来实现这一点?
我尝试将所有请求重定向到 HTTPS,但没有帮助:
app.Use(async (context, next) =>
{
if ("https".Equals(context.Request.Headers["x-forwarded-proto"]))
{
await next();
}
else
{
var withHttps = "https://" + context.Request.Host + context.Request.Path;
context.Response.Redirect(withHttps);
}
});
【问题讨论】:
标签: asp.net-core