public AccountService( SiteUserManager <SiteUser> userManager, SignInManager <SiteUser> signInManager, IIdentityServerIntegration identityServerIntegration, ISocialAuthEmailVerfificationPolicy socialAuthEmailVerificationPolicy, ILdapHelper ldapHelper, IUserCommands userCommands, IProcessAccountLoginRules loginRulesProcessor, INewUserDisplayNameResolver displayNameResolver, IOptions <CustomSocialAuthSchemes> customSchemesAccessor //,ILogger<AccountService> logger ) { UserManager = userManager; SignInManager = signInManager; IdentityServerIntegration = identityServerIntegration; SocialAuthEmailVerificationPolicy = socialAuthEmailVerificationPolicy; LoginRulesProcessor = loginRulesProcessor; DisplayNameResolver = displayNameResolver; CustomSocialAuthSchemes = customSchemesAccessor.Value; LdapHelper = ldapHelper; UserCommands = userCommands; }
public LdapRepository(ILdapHelper ldapHelper, IRolesMapper rolesMapper, IApplicationUserRepository userRepository) { this.ldapHelper = ldapHelper; this.rolesMapper = rolesMapper; this.userRepository = userRepository; }
private void ProcessAuth(XmppStream stream, Auth auth, XmppHandlerContext context) { AuthData authStep; lock (authData) { authData.TryGetValue(stream.Id, out authStep); } if (auth.MechanismType == MechanismType.DIGEST_MD5) { if (authStep != null) { context.Sender.SendToAndClose(stream, XmppFailureError.TemporaryAuthFailure); } else { lock (authData) { authData[stream.Id] = new AuthData(); } var challenge = GetChallenge(stream.Domain); context.Sender.SendTo(stream, challenge); } } else if (auth.MechanismType == MechanismType.PLAIN) { if (auth.TextBase64 == null) { context.Sender.SendToAndClose(stream, XmppFailureError.TemporaryAuthFailure); } else { string[] array = auth.TextBase64.Split('\0'); if (array.Length == 3) { string userName = array[1]; string password = array[2]; bool isAuth = false; User user = context.UserManager.GetUser(new Jid(userName, stream.Domain, null)); if (user != null) { if (user.Sid != null) { if (!user.Sid.StartsWith("l")) { var storage = new DbLdapSettingsStore(); storage.GetLdapSettings(stream.Domain); ILdapHelper ldapHelper = !WorkContext.IsMono ? (ILdapHelper) new SystemLdapHelper() : new NovellLdapHelper(); var accountName = ldapHelper.GetAccountNameBySid(user.Sid, storage.Authentication, storage.Login, storage.Password, storage.Server, storage.PortNumber, storage.UserDN, storage.LoginAttribute, storage.StartTls); if (accountName != null && ldapHelper.CheckCredentials(accountName, password, storage.Server, storage.PortNumber, storage.Login, storage.StartTls)) { // ldap user isAuth = true; } } } else if (user.Password == password) { // usual user isAuth = true; } } if (isAuth) { log.DebugFormat("User {0} authorized, Domain = {1}", userName, stream.Domain); context.Sender.ResetStream(stream); stream.Authenticate(userName); context.Sender.SendTo(stream, new Success()); } else { log.DebugFormat("User {0} not authorized, Domain = {1}", userName, stream.Domain); context.Sender.SendToAndClose(stream, XmppFailureError.NotAuthorized); } } else { context.Sender.SendToAndClose(stream, XmppFailureError.TemporaryAuthFailure); } } } else { context.Sender.SendToAndClose(stream, XmppFailureError.InvalidMechanism); } }