사용자 저장을 위해 AspnetIdentity
인증을 위해 IdentityServer3을 사용하고 있습니다. 난 내가 너무 IdentityServerServiceFactory
와 ApplicationUserManager
의 정적 Create 메서드를 등록하려면 어떻게해야UserManager를 IdentityServerServiceFactory에 등록하는 방법은 무엇입니까?
ApplicationUserManager
public class ApplicationUserManager : UserManager<ApplicationUser, string>
{
public ApplicationUserManager(ApplicationUserStore store)
: base(store)
{
}
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new ApplicationUserStore(context.Get<ApplicationDbContext>()));
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
// Configure validation logic for passwords
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
};
manager.EmailService = new EmailService();
var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null)
{
manager.UserTokenProvider =
new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
}
return manager;
}
}
을 UserValidator, PasswordValidator, IdentityTokenProvider 등을 구성하고 ApplicationUserManager
클래스의 인스턴스를 반환 static Create
방법이있다 ApplicationUserManager
클래스가 요청 당 단일 인스턴스를 사용할 수 있습니다.
public static IdentityServerServiceFactory Configure(this IdentityServerServiceFactory factory, string connectionString)
{
factory.UserService = new Registration<IUserService, UserService>();
// ????? HOW do I Register ApplicationUserManager's static Create method. ???
// ????? The line below will not configure Validators, IdentityTokenProvider, EmailService etc ?????
factory.Register(new Registration<ApplicationUserManager>());
factory.Register(new Registration<ApplicationUserStore>());
factory.Register(new Registration<ApplicationDbContext>(resolver => new ApplicationDbContext(connectionString)));
return factory;
}
UPDATE 1
여기 내 핵심 문제를 설명하려고합니다. 전체 ID 솔루션을위한 3 가지 VS 응용 프로그램이 있습니다.
1>Identity Server : 인증에만 사용되는 identityserver3입니다.
2>관리 포털 :이 응용 프로그램은 사용자, 클라이언트, 범위를 관리하기 위해 개발자/관리자 만 액세스 할 수 있습니다. 이것은 그 IdentityServer3.Admin 및 IdentityManager
3>클라이언트 포털을 결합한 솔루션 VS입니다 : 사용자가 암호를 변경, 암호를 재설정 할 수있는이 응용 프로그램은 최종 사용자가 액세스 할 수 있습니다. 이것은 표준 VS ASP.NET MVC5 응용 프로그램입니다. ApplicationUser
, ApplicationUserStore
, ApplicationDbContext
, ApplicationRole
, ApplicationUserManager
등 등
내 우려 등
모든 3 주 애플리케이션을 동일한 엔티티 Create
방법을 통해 EmailService
, UserTokenProvider
, PasswordValidator
구성되는 ApplicationUserManager
로했다.
3 개의 응용 프로그램 공유는 모두 ApplicationUserManager
이며 서로 다른 목적으로 사용합니다.
AdminPortal :이 응용 프로그램은 새로운 사용자를 생성하므로 암호는 & 사용자 이름 요구 사항을 따라야합니다. 그래서 ApplicationUserManager
을 등록해야합니다. 생성 방법은 IdentityManagerServiceFactory
입니다. 다시 어떻게해야합니까?
ClientPortal : 여기서 사용자는 & 암호를 재설정합니다. 암호 요구 사항을 따라야하며, 또한 EmailService & UserTokenProvider가 필요합니다. 이후 이것은 표준 VS MVC 응용 프로그램입니다. 나는
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
IdentityServer OWIN
문맥의 작성 방법 ApplicationUserManager
을 등록 할 수 있습니다 : 기본 생성자 ApplicationUserManager
를 등록 할만큼 (기본 생성자는 검증, UserTokenProvider, EmailService을 구성하지 않습니다) 경우 여기 모르겠어요.
또는 IdentityServer도 사용자를 생성하는 동안 사용한 것과 동일한 PasswordValidator, UserNameValidator, UserTokenProvider, EmailSerice가 필요합니까?
나는 동일한 질문을 가지고있다. 당신의 문제에 대한 해결책을 찾았습니까? http://stackoverflow.com/questions/41242738/setup-custom-usermanager-with-asp-net-identity-in-identityserver –