在一个旧项目中,我们使用了 ASP.NET 4.5,我想在其中使用框架 OpenIdDict。它是由 ASP.NET Core 1 和 2 制作的。我还能使用它吗?我需要注意什么?如果我不能使用它,你知道哪些替代方案?
OpenIdDict 链接:https : //github.com/openiddict/openiddict-core
我有个问题.我今天早上打开了我的项目并得到了错误:
找不到类型或命名空间名称'OpenIddictDbContext <,,>'(您是否缺少using指令或程序集引用?)[netcoreapp1.1]
我恢复并构建项目时发生此错误.这很奇怪,因为我在我的project.json文件中有"OpenIddict":"1.0.0-*",我正在使用引用:using OpenIddict ;
这个问题在我的项目中到处都会出现问题,因为他似乎没有认识到"使用OpenIddict"
如果它有帮助,这是我得到错误的例子(ApplicationDbContext.cs)
namespace Overnight.Db
{
//the error: The type or namespace name 'OpenIddictDbContext<,,>' could not be found (are you missing a using directive or an assembly reference?)
public class ApplicationDbContext : OpenIddictDbContext<ApplicationUser, ApplicationRole, Guid>
{
Run Code Online (Sandbox Code Playgroud)
要么
//the error: 'OpenIddictDbContext<ApplicationUser, ApplicationRole, Guid>' does not contain a constructor that takes 1 arguments
protected override void OnModelCreating(ModelBuilder builder)
{
Run Code Online (Sandbox Code Playgroud)
这是我的project.json:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform", …Run Code Online (Sandbox Code Playgroud) 我正在使用密码授予流程和 asp.net Identity。
我想在每次执行登录时杀死用户的所有刷新令牌。即使他使用不同的设备(例如其他电脑或智能手机)登录,我也需要它来终止其“会话”。
那么,我该怎么做呢?
我可以只做一个UserManager.UpdateSecurityStampAsync(user.Id);,还是我需要别的东西?
非常感谢你的帮助!
正如标题所说,得到:
“IDX10609:解密失败。未尝试任何密钥:令牌:'System.String'。”
尝试进行身份验证时出错。使用 Openiddict 作为身份验证服务器。我确信我在其中或 api 服务器中配置了错误,但我不知道是什么。我一直在尝试不同的组合,但目前却陷入困境。这是身份验证服务器配置:
public void ConfigureServices(IServiceCollection services) {
services.AddDbContext<TrustContext>(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("Trust"), b => b.MigrationsAssembly("Application.Trust"));
options.UseOpenIddict();
});
services.AddDefaultIdentity<AspNetUsers>()
.AddEntityFrameworkStores<TrustContext>()
.AddDefaultTokenProviders();
services.Configure<IdentityOptions>(options =>
{
options.ClaimsIdentity.UserNameClaimType = Claims.Name;
options.ClaimsIdentity.UserIdClaimType = Claims.Subject;
options.ClaimsIdentity.RoleClaimType = Claims.Role;
});
services.AddOpenIddict()
// Register the OpenIddict core components.
.AddCore(options =>
{
options.UseEntityFrameworkCore()
.UseDbContext<TrustContext>();
})
.AddServer(options =>
{
options.IgnoreEndpointPermissions()
.IgnoreGrantTypePermissions()
.IgnoreScopePermissions();
// Enable the authorization, logout, token and userinfo endpoints.
options.SetAuthorizationEndpointUris("/connect/authorize")
.SetLogoutEndpointUris("/connect/logout")
.SetTokenEndpointUris("/connect/token")
.SetUserinfoEndpointUris("/connect/userinfo");
options.RegisterScopes(Scopes.Email, Scopes.Profile, Scopes.Roles, Scopes.OpenId);
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowImplicitFlow()
.AllowHybridFlow()
.AllowRefreshTokenFlow();
options.AddDevelopmentEncryptionCertificate()
.AddDevelopmentSigningCertificate(); …Run Code Online (Sandbox Code Playgroud) 我们的应用需要通过手机号码或Google登录.我们计划通过Twitter数字进行手机号码验证.
我理解的注册和认证流程如下:
移动应用程序使用Twitter数字或Google登录进行丰富的身份验证(用户可以使用丰富的身份验证而不是打开Web浏览器选项卡,从而获得更好的用户体验).Twitter Digits/Google Sign In返回身份令牌.
移动应用程序将AuthServer调用到SignIn并显示身份令牌.
身份服务器使用Digits服务或Google Auth服务验证所呈现的身份令牌.
一旦验证,AuthServer将尝试查找用户,如果不存在,它将创建一个.
AuthServer将Access Token返回给移动应用程序.
现在,我正在寻找实施步骤#3-4的选项.
目前,我所做的是修改令牌端点代码,该代码将用户名作为电话号码或电子邮件地址和密码作为Google/Twitter数字ID令牌发送.现在,由于auth服务器需要知道发送的密码实际上是需要通过第三方服务验证的令牌,我通过在TokenHint中发送服务名称"Digits"或"Google"来解决它.
这非常有效,但我想知道什么是最干净的方式来支持我想要实现的目标.
我https在非本地托管环境上使用 ARR,无需卸载。这意味着命中 ARR 的请求为 ,https但发送到后端服务器的请求仅为http。
如果我禁用httpsopeniddict 中的要求,则配置返回httpurl。如果我启用它,那么请求将被拒绝,因为后端服务器将它们接收为http. 有没有办法解决?