/// <summary> /// Register Identity Server to use a ASP.NET 2.0 Membership database to authenticate users /// </summary> /// <param name="factory">Identity Server Service Factory</param> /// <param name="options">Identity Server Membership Options</param> public static void UseMembershipService(this IdentityServerServiceFactory factory, MembershipOptions options) { if (string.IsNullOrWhiteSpace(options.ConnectionString)) { throw new ArgumentException(nameof(options.ConnectionString)); } factory.Register(new Registration <MembershipOptions>(resolver => options)); factory.Register(new Registration <IMembershipPasswordHasher, MembershipPasswordHasher>()); factory.Register(new Registration <IMembershipContext, MembershipContext>()); factory.Register(new Registration <IMembershipRepository, MembershipRepository>()); factory.Register(new Registration <IRoleRepository, RoleRepository>()); factory.Register(new Registration <IMembershipService, MembershipService>()); factory.Register(new Registration <IRoleService, RoleService>()); factory.UserService = new Registration <IUserService, MembershipUserService>(); }
/// <summary>Constructor</summary> /// <param name="options">Membership Options</param> /// <param name="membershipService">Membership Service</param> /// <param name="roleService">Role Service</param> public MembershipUserService(MembershipOptions options, IMembershipService membershipService, IRoleService roleService) { this.options = options.ThrowIfNull(nameof(options)); this.membershipService = membershipService.ThrowIfNull(nameof(membershipService)); this.roleService = roleService.ThrowIfNull(nameof(roleService)); }