我有一个 Asp.Net Core/ReactJs 应用程序。我正在使用 Microsoft.AspNetCore.ApiAuthorization.IdentityServer
对 API 进行身份验证。但是,我收到一个错误,我认为这是由于配置错误造成的。
如果我在本地运行它,使用以下配置,一切正常,应用程序按预期重定向到登录屏幕:
"IdentityServer": {
"Clients": {
"MyApp": {
"Profile": "IdentityServerSPA",
}
},
"Key": {
"Type": "File",
"FilePath": "Assets/selfsignedcert.pfx",
"Password": "password"
}
},
但是,如果我将配置更改为以下内容:
"IdentityServer": {
"Clients": {
"MyApp": {
"Profile": "IdentityServerSPA",
"RedirectUri": "https://localhost:5211/authentication/login-callback"
"LogoutUri": "https://localhost:5211/authentication/logout-callback"
}
},
"Key": {
"Type": "File",
"FilePath": "Assets/selfsignedcert.pfx",
"Password": "password"
}
},
它出错(重定向到以下内容):
https://localhost:5211/home/error?errorId=1234...
看一下来自客户端的认证请求,它们是完全一样的;但是第二个返回错误,而第一个成功重定向。
我的配置有问题吗?或者,我该如何调试这个问题?
最佳答案
非工作配置中的两个 Uris 都指向注销。这真的是你想要做的吗?
在第一个配置中,您没有定义任何 Uris,因此它们将具有以下默认值:
redirect_uri 默认为/authentication/login-callback。
post_logout_redirect_uri 默认为/authentication/logout-callback。
如文档所示 here
尝试更改第二个配置以匹配默认值以查看是否有帮助。
关于reactjs - Asp.Net Core Api 授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62229327/