Blazor WebAssembly登录身份验证/来自.well-known/openid-configuration的登录提供了localhost URL而不是公共URL [英] Blazor WebAssembly login authentication/login from .well-known/openid-configuration gives localhost URL instead of public URL
问题描述
自动生成的oidc配置文件提供localhost而不是我的公共URL.如何设置它以提供正确的URL?
The autogenerated oidc configuration file gives localhost instead of my public URL. How do I set it up so that it gives the right URL?
http://167.172.118.170/.well-known/openid-configuration
在我的测试网站的登录链接中: http://167.172.118.170/authentication/login登录名将重定向到本地主机地址,而不是公共167.172.118.170地址,如下所示:
In the login link on my test site: http://167.172.118.170/authentication/login the login redirects to a localhost address instead of the public 167.172.118.170 address, like this:
http://localhost:5008/connect/authorize?client_id = MyProject.Web.Client& redirect_uri = http%3A%2F%2F167.172.118.170%2Fauthentication%2Flogin-callback& response_type = code& scope = MyProject.Web.ServerAPI%20openid%20profile& state = b18bc58127b54ea9aaff1a210b7899de& code_challenge = OOIuUi2yJnYcjZZIu4LveJfbLz0Na7IKkzlDTKb81IE& code_challenge_method = S256>
http://localhost:5008/connect/authorize?client_id=MyProject.Web.Client&redirect_uri=http%3A%2F%2F167.172.118.170%2Fauthentication%2Flogin-callback&response_type=code&scope=MyProject.Web.ServerAPI%20openid%20profile&state=b18bc58127b54ea9aaff1a210b7899de&code_challenge=OOIuUi2yJnYcjZZIu4LveJfbLz0Na7IKkzlDTKb81IE&code_challenge_method=S256&response_mode=query
如何配置它,使其进入 http://167.172.118.170/connect/authorize代替?
How do I configure it so that it goes to http://167.172.118.170/connect/authorize instead?
这是身份验证剃刀文件的内容:
This is the content of the authentication razor file:
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />
@code{
[Parameter] public string Action { get; set; }
}
没有提供服务器URL的选项.
There is no option to provide the server URL.
推荐答案
解决方案是添加以下内容:
The solution was to add the following:
使用IdentityServer4.Extensions;
using IdentityServer4.Extensions;
//...
app.Use((ctx, next) =>
{
ctx.SetIdentityServerOrigin("http://167.172.118.170");
return next();
});
这篇关于Blazor WebAssembly登录身份验证/来自.well-known/openid-configuration的登录提供了localhost URL而不是公共URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!