尝试使用IdentityServer4上的Introspection Endpoint验证令牌.我一直得到401:未经授权.我的日志看起来像这样:
dbug: IdentityServer4.EntityFramework.Stores.ResourceStore[0]
Found MyAPI API resource in database
info: IdentityServer4.Validation.HashedSharedSecretValidator[0]
Secret: MyAPI API uses invalid hashing algorithm.
dbug: IdentityServer4.Validation.SecretValidator[0]
Secret validators could not validate secret
fail: IdentityServer4.Validation.ApiSecretValidator[0]
API validation failed.
fail: IdentityServer4.Endpoints.IntrospectionEndpoint[0]
API unauthorized to call introspection endpoint. aborting.
Run Code Online (Sandbox Code Playgroud)
我的API配置如下:
new ApiResource
{
Name = "MyAPI",
DisplayName = "My API",
ApiSecrets =
{
new Secret("TopSecret".Sha256())
},
}
Run Code Online (Sandbox Code Playgroud)
我将内容类型的标题传递为application/x-www-form-urlencoded,授权为Basic xxxxxxxxxxxxxxxxx,其中x是我的base64编码的auth字符串(myapi:TopSecret).我的令牌在帖子的正文中
我错过了什么?为什么我得到"MyAPI API使用无效散列算法"?如果它无效,什么是有效的哈希算法?
附加信息:我的资源包含在通过Entity Framework访问的SQL数据库中.具体来说,设置与此处的快速入门文档中的设置相同.为了达到我的目的,我必须手动将我的API添加到ApiSecrets表并给它一个Type(SharedSecret)和一个值,这是一个Sha256密码.
在Startup.cs中,我的COnfigureServices包括
services.AddIdentityServer()
.AddTemporarySigningCredential()
.AddInMemoryApiResources(Configurations.Scopes.GetApiResources())
.AddInMemoryClients(Configurations.Clients.GetClients())
.AddConfigurationStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(builder => …Run Code Online (Sandbox Code Playgroud) 所以我正在搞乱Delphi 2009中的一个新项目,可以删除到表单上的默认组件用于访问数据,包括SQLConnection,DataSource和SQLQuery.如果我向查询组件添加一个简单的选择,请说:
select name from customers
Run Code Online (Sandbox Code Playgroud)
然后在表单上删除一个DBComboBox并将其与DataSource链接我在组合框中得到一条记录.在使用谷歌一半和一小时来弄清楚我做错了什么之后,看起来你必须手动为项目添加一些代码,这些代码循环遍历数据集并将所有记录添加到下拉框中.就像是:
while not SQLQuery.eof do
begin
DBComboBox.items.add(SQLQuery.fieldbyname('name').asstring);
SQLQuery.next;
end;
Run Code Online (Sandbox Code Playgroud)
这实际上是有效的,但是你会在下拉列表中找到一个列表,你无法从中选择任何东西.无论结果如何,但我想知道为什么如果你必须手动将查询结果添加到它中,你甚至会使用DBComboBox?在我看来,如果它没有自动使用查询结果填充db组合框,那么我们也可能使用像tcombobox这样的非数据感知组件.
我想我问的是为什么它会这样工作?数据感知拖放控件的目的不是最小化实际编写的代码量和加速开发吗?有没有一种我想念的方法可以让这更容易?
使用IDS4和调试跟踪,日志只给我一点点继续.我发布时遇到上述错误(令牌端点的无效HTTP请求):
Request starting HTTP/1.1 POST http://localhost:5000/connect/token?grant_type=password&client_id=resClient&client_secret=TopSecret&username=admin&password=admin123
Run Code Online (Sandbox Code Playgroud)
在客户端(Web浏览器)我得到
{ "error": "invalid_request" }
Run Code Online (Sandbox Code Playgroud)
整个调试日志如下所示:
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
Connection id "0HL2NGBR0Q1O4" started.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 POST http://localhost:5000/connect/token?grant_type=password&client_id=resClient&client_secret=TopSecret&username=admin&password=admin123 0
dbug: Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware[9]
AuthenticationScheme: idsrv was not authenticated.
dbug: IdentityServer4.Hosting.EndpointRouter[0]
Request path /connect/token matched to endpoint type Token
dbug: IdentityServer4.Hosting.EndpointRouter[0]
Mapping found for endpoint: Token, creating handler: IdentityServer4.Endpoints.TokenEndpoint
info: IdentityServer4.Hosting.IdentityServerMiddleware[0]
Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
trce: IdentityServer4.Endpoints.TokenEndpoint[0]
Processing token request.
warn: IdentityServer4.Endpoints.TokenEndpoint[0]
Invalid HTTP request for token endpoint
trce: IdentityServer4.Hosting.IdentityServerMiddleware[0]
Invoking result: IdentityServer4.Endpoints.Results.TokenErrorResult
info: …Run Code Online (Sandbox Code Playgroud)