有几天我正在阅读Duende服务器(IdentityServer4),因此我了解不同的概念及其用法,例如Scopes、Resources、Client .
我对此感到困惑的地方是客户。因此,我将AspIdentity集成为IdentityServer中的一个ApplicationUser (您可以在代码部分找到下面的信任),但是当我想调用/connect/令牌(这是Duende预定义的端点)时,它需要添加ClientId和ClientId,但我想使用用户名和注册用户的密码。
因此,我想到的想法是创建一个自定义端点:在使用SignInManager验证用户凭据之后,我将找到用户客户端,然后登录到Duende IdentityServer,但是我尝试这样做,但是让HTTP再次调用相同的服务以获取用户的令牌有点不便。
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(connectionString));
builder.Services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
builder.Services.AddSwaggerGen();
builder.Services
.AddIdentityServer(options =>
{
options.Events.RaiseErrorEvents = true;
options.Events.RaiseInformationEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;
options.EmitStaticAudienceClaim = true;
})
.AddAspNetIdentity<ApplicationUser>()
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b =>
b.UseSqlite(connectionString, dbOpts => dbOpts.MigrationsAssembly(typeof(Program).Assembly.FullName));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b =>
b.UseSqlite(connectionString, dbOpts => dbOpts.MigrationsAssembly(typeof(Program).Assembly.FullName));
options.EnableTokenCleanup = true;
options.RemoveConsumedTokens = true;
});
builder.Services.AddAuthentication();如果我能以一种方便的方式解决这个问题,那么其他的步骤是非常明显和直接的。
发布于 2022-11-20 19:11:31
clientID和机密用于标识希望连接到IdentityServer的应用程序,而不是用户;为什么不能使用clientID/保密来实现它的目的呢?
此外,OpenID连接的主要目的是不让客户端应用程序接触或查看用户的用户名/密码。这就是为什么我们将身份验证委托给IdentityServer的原因。
https://stackoverflow.com/questions/74501378
复制相似问题