[]
Microsoft는 ISecurityProvider 인터페이스를 제공합니다. 이 인터페이스를 구현함으로써 사용자는 다른 시스템과 통합할 수 있습니다.
이 섹션에서는 보안 공급자를 구현하는 방법에 대해 설명합니다.




using GrapeCity.Forguncy.SecurityProvider;
using System;
using System.Collections.Generic;
using System.Linq;
namespace DemoPasswordSecurityProvider
{
public class DemoPasswordSecurityProvider : ISecurityProvider
{
List<User> testUsers = new List<User>();
public DemoPasswordSecurityProvider()
{
AddUser("User1", "TestUser1", "User1@User1.com", "User1Property");
AddUser("User2", "TestUser2", "User2@User2.com", "User2Property");
AddUser("User3", "TestUser3", "User3@User3.com", "User3Property");
}
void AddUser(string userId, string userName, string email, string customProperty)
{
testUsers.Add(new User()
{
UserId = userId,
Email = email,
FullName = userName
});
testUsers.Last().Properties.Add("customProperty", customProperty);
}
public string Name
{
get
{
return "DemoPasswordSecurityProvider";
}
}
public AuthenticationType AuthenticationType
{
get
{
return AuthenticationType.UserNameAndPassword;
}
}
public UserInformationStorageMode UserInformationStorageMode
{
get
{
return UserInformationStorageMode.InForguncyDatabase;
}
}
public UserInformations UserInformations => throw new NotImplementedException();
public bool AllowLogout
{
get
{
return true;
}
}
private User GetUserInformation(string userId)
{
return testUsers.FirstOrDefault(u => u.UserId == userId);
}
public User VerifyUser(Dictionary<string, string> properties)
{
var userName = properties["userName"];
var password = properties["password"];
var user = GetUserInformation(userName);
if (user != null && password == "123456")
{
user.Properties.Add("FGC_Role", "MyRole");
return user;
}
return null;
}
}
}
그 중 InForguncyDatabase 는 사용자 정보를 포건시에 저장하는 방식이고 다른 방식은 InMemoryCache 입니다.

