Tag: asp.net identity 3

实体类型“类型”处于阴影状态。 有效模型要求所有实体类型都具有相应的CLR类型

我正在使用Asp.net Core和EF core来设置IdentityServer4。 在此过程中,我想将数据合同和数据访问与核心项目分开。 为此,我创建了两个相关项目,一个包含DbContext,另一个包含合同。 最终我想让事情变得更复杂,但首先我只想尝试向IdentityUser添加一个相关对象,该对象默认为ApplicationUser,并在涉及Asp.net Identity的默认项目中存储为ApsnetUsers。 为此,我创建了一个inheritanceIdentityUser的基础ApplicationUserDto类。 我已经将补充对象/表添加到该对象,并通过更新ModelBuilder测试应用程序,最终,所有内容都按预期工作。 现在的问题。 我的最终目标是两个有两个独立的类,它们都inheritanceApplicationUserDto,一个用于内部用户,一个用于外部用户。 每个人都有自己的补充一对一数据表。 为了开始构建这个,我创建了两个类,InternalUserDto和InternalUserProfilePropertiesDto。 ApplicationUserDto类: namespace SingleSignOn.Identity.DataAccess.Contracts { public class ApplicationUserDto: IdentityUser {} } InternalUserDto.cs namespace SingleSignOn.Identity.DataAccess.Contracts { public class InternalUserDto : ApplicationUserDto { public virtual InternalUserProfilePropertiesDto InternalUserProfilePropertiesDto { get; set; } public InternalUserDto() { } } } InternalUserProfilePropertiesDto.cs namespace SingleSignOn.Identity.DataAccess.Contracts.UserProperties { public class InternalUserProfilePropertiesDto { […]

ASP.NET 5 Identity 3用户在应用程序重新启动后退出

我们正在使用ASP.NET Identity 3。 我们的用户会随机自动退出。 为了重现这个问题,我尝试重启应用程序,所有用户都退出了,即使是那些已经检查过的人也Remember me 。 它只发生在Production中,在开发环境中工作正常。 更新: 我们只有一台服务器在生产中。

使用Azure中的ASP.NET Core在Redis中保存用户会话

我正在使用redis缓存来保存项目中的一些东西。 我正在使用Azure(WebApp),当我在我的预生产环境到生产之间进行SWAP时,用户会话丢失了,他需要重新登录我的网页。 我正在使用Identity 3.0,使用UseCookieAuthentication。 我想在Redis中存储“会话”以便在我进行交换时解决我的问题。 我没有找到有关它的信息,有什么想法吗? 谢谢 Startup.cs代码配置服务: public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); // Registers MongoDB conventions for ignoring default and blank fields // NOTE: if you have registered default conventions elsewhere, probably don’t need to do this //RegisterClassMap.Init(); AutoMapperWebConfiguration.Configure(); services.AddSingleton(); // Add Mongo Identity services to the services container. […]

ASP.NET Core Identity 3 Cookie超时

RC2发生了一个奇怪的问题。 我使用以下配置选项将Identity 3 ExpireTimeSpan设置为12小时 options.Cookies.ApplicationCookie.ExpireTimeSpan = new TimeSpan(12,0,0); 登录到网站并保持不变约35-40分钟后,我收到401错误(对于我的ajaxpost调用)并刷新网站,我回到登录页面。 当我将ExpireTimeSpan设置为12小时时,为什么必须重新进行身份validation? 我需要其他设置或配置吗? 也, 如何在到期前剩下时间? 我想访问该信息,以便我可以警告我的用户他们的会话将在X时间后过期。 谢谢!

ASP.NET Identity(使用IdentityServer4)获取外部资源oauth访问令牌

我已经浏览了identityServer4的文档,我已将其设置为使用Microsoft Office 365作为登录提供程序。 当用户登录时,我想创建一个按钮,他可以让我的应用程序使用graph.microsoft.com的webhooks api订阅他的日历事件 startup.cs中的代码 app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions { AuthenticationScheme = “Microsoft”, DisplayName = “Microsoft”, SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme, ClientId = “CLIENT ID”, ClientSecret = “CLIENT SECRET”, CallbackPath = new PathString(“/signin-microsoft”), Events = new OAuthEvents { OnCreatingTicket = context => { redisCache.Set(“AccessToken”, context.AccessToken.GetBytes(), new DistributedCacheEntryOptions { AbsoluteExpiration = DateTimeOffset.UtcNow.AddDays(3) }); return Task.FromResult(context); } } Scope = […]

ASP.NET Core错误:实施忘记密码时出现无效令牌错误

在VS2017 ver 15.3.3具有Individual User Accounts模式的ASP.NET MVC Core 1.1.1应用程序中,我正在实现Forgot Passwordfunction。 该应用正确地使用生成的链接发送电子邮件。 我可以打开我的电子邮件,可以看到生成的链接如下。 链接正确显示ResetPassWord.cshtml视图。 但是当我输入所需的用户名,密码,确认密码信息并单击“提交”按钮时,我收到Invalid Token错误。 问题 :如何解决问题? 注意 : 答:如果我已登录并希望将密码重置为其他内容,则PasswordResetfunction可以正常工作。 B.不确定它是否相关:我没有使用电子邮件作为用户名。 相反,我改变了AccountCountroller的Email属性 [Required] [EmailAddress] public string Email { get; set; } 至 [Required] public string UserName { get; set; } 等等,并在ApplicationUser.cs扩展了用户属性,如下所示: ApplicationUser.cs // Add profile data for application users by adding properties to the ApplicationUser class […]

如何在asp.net核心中创建角色并将其分配给用户

我使用asp.net核心默认网站模板和身份validation选择为个人用户帐户。 如何创建角色并将其分配给用户,以便我可以使用控制器中的角色来过滤访问权限。