asp.net-identity

How do I seed user roles in Identity ASP.NET Core 2.1 (Identity Scaffolded)

此生再无相见时 提交于 2020-06-16 04:41:05
问题 How do I seed a "admin" user role when identity is scaffolded? I would like to find my power-user account by email and seed the admin role. Most examples I find use Startup.cs , but you are supposed to use IdentityHostingStartup.cs to register identity related services. So where/how do I inject the RoleManager and UserManager in IdentityHostingStartup ? (I assume this is what I need, please let me know if there is a better way) public class IdentityHostingStartup : IHostingStartup { public

AddEntityFrameworkStores can only be called with a role that derives from IdentityRole in .NET Core 2.0

蓝咒 提交于 2020-06-13 17:34:48
问题 I have changed a project from the .NET Core 1.1 to 2.0 version, but I'm getting an error from the Identity, when It tries to add the stores: services.AddIdentity<ApplicationUser, IdentityRole<long>>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); The thrown error is: AddEntityFrameworkStores can only be called with a role that derives from IdentityRole These are my classes: public class ApplicationUser : IdentityUser<long> { } public class ApplicationDbContext

IdentityServer4 SPA Login

随声附和 提交于 2020-06-01 04:48:26
问题 I want to create an SPA, and Login Via my custom Login Screen (Frontend is in React&Redux), but i miserably fail at it. So basically i´ll get an 404 Error returned, when using const username = 'bob' const password = 'bob' const returnUrl = 'https://localhost:5001/' fetch('https://localhost:5000/api/Authenticate/Login', { method: 'POST', headers: { 'Content-Type': 'application/json', }, credentials: 'include', body: JSON.stringify({ username, password, returnUrl, }), the response I get is

IdentityServer4 SPA Login

非 Y 不嫁゛ 提交于 2020-06-01 04:48:25
问题 I want to create an SPA, and Login Via my custom Login Screen (Frontend is in React&Redux), but i miserably fail at it. So basically i´ll get an 404 Error returned, when using const username = 'bob' const password = 'bob' const returnUrl = 'https://localhost:5001/' fetch('https://localhost:5000/api/Authenticate/Login', { method: 'POST', headers: { 'Content-Type': 'application/json', }, credentials: 'include', body: JSON.stringify({ username, password, returnUrl, }), the response I get is

Is it possible to change UserManager<T>'s lifetime?

爱⌒轻易说出口 提交于 2020-05-30 08:06:58
问题 I'm trying to change UserManager<T> lifetime from Scoped to Transient inside the ConfigureServices(IServiceCollection service) but I don't know how to do that. Is it possible or I have to inject IServiceProvider inside every object that needs UserManager<T> and then create a new Scope every time I need to use the UserManager? 来源: https://stackoverflow.com/questions/60721511/is-it-possible-to-change-usermanagerts-lifetime

Onion Architecture Identity Framework

柔情痞子 提交于 2020-05-27 09:28:04
问题 I am following Onion Architecture. And in that I am using ASP.NET Identity Framework. Here is my Project Structure: 1-Core - Domain Classes //It contains my T4 template classes -- AppUser //It is Identity User. - Repository Interfaces - Service Interfaces 2-Infrastructure - Data //It contains my edmx file, I am using Db First approach. - Dependency Injection - Repository Interfaces Implementation - Service Interfaces Implementation 3-WebApi - Web Api Project 4-WebClient - My AngularJs App 5

Blazor hosted - authorize immediately before displaying application

家住魔仙堡 提交于 2020-05-24 05:13:11
问题 Can anybody give me a helping push to get my hosted Blazor application (Client, Server and Shared) to request a login immediately, before the application is initially shown. I want the experience that a user must log in before accessing the application at all. My starting point is the Blazor Webassembly (hosted) template with Api Authorization (Individual User Accounts) Using the Authorize attribute on either server-side actions or a client-side Razor page will not initiate the authentication

AWS DynamoDB with ASP .Net Core 3.1.0 Identity 2.2.0

戏子无情 提交于 2020-05-16 08:57:45
问题 I have to integrate Asp .net core identity 2.2.0 with AWS DynamoDB.I am using the .net core version 3.1.I searched for the reference but I didn't get any good one. Please help me. 回答1: I have got one reference from https://github.com/miltador/AspNetCore.Identity.DynamoDB. It sounds like someone wrote this and didn't maintain it. I have downloaded the Source code from this repo and updated the same to .net core 3.1.0 and identity 2.2.0[and also updated the startup file]. Now it's working fine

Blazor on server-side: using MongoDB for Identity management

淺唱寂寞╮ 提交于 2020-05-15 04:15:26
问题 The Asp.Net Core Blazor template in VS 2019 can create a server-side app that will use the Microsoft SQL Server to manage the accounts and claims for identity management. I would like to use MongoDB instead for account and claims management. This way I want to enable Blazor to use decorators and AuthorizeView to allow specific access for specific identities or claims. I have scaffolded the Identity construct but I am confused how to proceed. There is an open source Identity provider available

Blazor on server-side: using MongoDB for Identity management

有些话、适合烂在心里 提交于 2020-05-15 04:14:02
问题 The Asp.Net Core Blazor template in VS 2019 can create a server-side app that will use the Microsoft SQL Server to manage the accounts and claims for identity management. I would like to use MongoDB instead for account and claims management. This way I want to enable Blazor to use decorators and AuthorizeView to allow specific access for specific identities or claims. I have scaffolded the Identity construct but I am confused how to proceed. There is an open source Identity provider available