MVC 3 .net 어플리케이션에서 기본 제공 멤버십 시스템을 사용합니다. 나중에 나는 인증을 위해 외부 웹 서비스를 사용할 것이다. 따라서 회원 시스템에 (고유 한) 사용자 이름 만 저장하면됩니다. 다른 모든 사용자 정보는 웹 서비스를 통해 검색 할 수 있습니다..net 회원 정보에 비밀번호를 저장하지 마십시오.
따라서 나는 이 아닌데 암호를 저장하는 방법 궁금해?
MVC 3 .net 어플리케이션에서 기본 제공 멤버십 시스템을 사용합니다. 나중에 나는 인증을 위해 외부 웹 서비스를 사용할 것이다. 따라서 회원 시스템에 (고유 한) 사용자 이름 만 저장하면됩니다. 다른 모든 사용자 정보는 웹 서비스를 통해 검색 할 수 있습니다..net 회원 정보에 비밀번호를 저장하지 마십시오.
따라서 나는 이 아닌데 암호를 저장하는 방법 궁금해?
비밀번호 저장에 대해 걱정할 필요가 없습니다. 사용자 생성시 비밀번호를 임의로 생성하고 저장하십시오. 하지만 당신 유무 :
계정 컨트롤러가 로그온 방법에서 외부 웹 서비스에 대한 암호를 확인 되세요, 올바른 경우, 단순히 사용자 :
보조 노트는 "로그인"할) FormsAuthentication.SetAuthCookie(userName, false /*persistantCookie*/
전화 비밀 번호 해시/소금 만 가지고 있다면 기존 사용자를 새로운 외부 웹 서비스로 마이그레이션하는 방법은 무엇입니까?
잘 이해할 수 있는지 확실하지 않지만이 문제를 해결하는 가장 좋은 방법은 맞춤 멤버십 제공 업체를 만드는 것입니다. 기본적으로이 클래스는 기본 멤버 자격 공급자에서 재정의 된 몇 가지 기능 만 가진 클래스입니다. 여기에서 등록, 로그인 및 로그 아웃을위한 자체 논리를 구현할 수 있습니다.
내가 사용했던 수업의 예를 찾았습니다. 직접 구현을 작성하십시오. 다른 옵션은 accountcontroller에서 작업하는 것입니다 (예를 들어 위험도 언급 됨).하지만 저는 항상 컨트롤러에 너무 많은 로직을 구현하지 않고 내 서비스가 비즈니스 로직을 처리하도록합니다.
public class CustomMembershipProvider : MembershipProvider
{
private readonly IGenericService<User> _genericUserService;
public CustomMembershipProvider(IGenericService<User> genericUserService)
{
_genericUserService = genericUserService;
}
public CustomMembershipProvider() : this(new GenericService<User>())
{
}
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
throw new NotImplementedException();
}
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
{
throw new NotImplementedException();
}
public override string GetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
throw new NotImplementedException();
}
public override string ResetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override void UpdateUser(MembershipUser user)
{
throw new NotImplementedException();
}
public override bool ValidateUser(string username, string password)
{
try
{
var encodedPassword = password.AsSha512();
var user = _genericUserService.First(u => u.Email == username && u.Password == string.Empty);
return user != null;
}
catch (Exception)
{
return false;
}
}
public override bool UnlockUser(string userName)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(string username, bool userIsOnline)
{
var user = _genericUserService.First(x => x.Email.Equals(username));
var a = new MembershipUser("", user.Firstname, user.Id, user.Email, "", "", true, user.Active,
user.RegisteredOn, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);
return a;
}
public override string GetUserNameByEmail(string email)
{
throw new NotImplementedException();
}
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
throw new NotImplementedException();
}
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override int GetNumberOfUsersOnline()
{
throw new NotImplementedException();
}
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override bool EnablePasswordRetrieval
{
get { throw new NotImplementedException(); }
}
public override bool EnablePasswordReset
{
get { throw new NotImplementedException(); }
}
public override bool RequiresQuestionAndAnswer
{
get { throw new NotImplementedException(); }
}
public override string ApplicationName
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public override int MaxInvalidPasswordAttempts
{
get { throw new NotImplementedException(); }
}
public override int PasswordAttemptWindow
{
get { throw new NotImplementedException(); }
}
public override bool RequiresUniqueEmail
{
get { throw new NotImplementedException(); }
}
public override MembershipPasswordFormat PasswordFormat
{
get { throw new NotImplementedException(); }
}
public override int MinRequiredPasswordLength
{
get { throw new NotImplementedException(); }
}
public override int MinRequiredNonAlphanumericCharacters
{
get { throw new NotImplementedException(); }
}
public override string PasswordStrengthRegularExpression
{
get { throw new NotImplementedException(); }
}
}