ASP.NET Webforms 웹 사이트에 STS (보안 토큰 서비스)를 추가해야한다는 요구 사항이 있습니다. 주요 문제는 ID 공급자가 역할 정보를 가지고 있지 않기 때문에 인증이 수행 된 후에 역할에 대한 클레임을 추가해야한다는 것입니다.WIF (Windows Identity Foundation) 클레임에 추가하는 방법
다음과 비슷한 코드를 사용하여 로컬 STS에 CustomSecurityTokenService
을 구현했습니다. 이 코드는 예상대로 작동 - howeever, 나중에 그 과정에서 "여기에 사용자에 대한 역할을 얻을"주석 아래에 비트를 추가 할 필요가 ...
// Get the incoming identity
IClaimsIdentity callerIdentity = (IClaimsIdentity)principal.Identity;
// Issue custom claims.
ClaimsIdentity outputIdentity = new ClaimsIdentity("Federation");
var username = callerIdentity.Name;
var domain = "DOMAIN";
outputIdentity.Claims.Add(new Claim(ClaimTypes.Name, callerIdentity.Name));
outputIdentity.Claims.Add(new Claim(ClaimTypes.WindowsAccountName, string.Format("{0}\\{1}", domain, username)));
// get roles for user here:
var roles = "Admin";
string[] rolelist = roles.Split(',');
foreach (var role in rolelist)
{
outputIdentity.Claims.Add(new Claim(ClaimTypes.Role, role));
}
return outputIdentity;
내가 가진 문제
, 나는 역할을 얻을 수 있다는 것입니다 이 때 ID 제공자 외부의 서비스에서 제공됩니다. 내가 RP를 얻기 전에 RP (응용 프로그램)로 돌아갈 때까지 기다려야합니다.하지만 그때에는 web.config의 보안 설정이 역할 설정으로 인해 잠겨 있습니다.<location path="Pages/Secure/Messages/Default.aspx">
<system.web>
<authorization>
<allow roles="Admin, Tecchies"/>
</authorization>
</system.web>
</location>
나는 내가 Global.asax에에서 이벤트를 사용할 수있을 것으로 생각했지만, 아직 나는 일을 여기에 모든 옵션을 얻을 수 없었다. 이 같은 코드 : 나는 .NET 4.0을 사용하고
var currentUser = Service.GetUser(callerIdentity.Name);
foreach (var role in currentUser.Roles)
{
outputIdentity.Claims.Add(new Claim(ClaimTypes.Role, role));
}
- 나는 4.5로 업그레이드의 몇 가지 이점이있을 수 있음을 이해하지만, 이것은 나를 위해 현재 옵션을 선택하지 않습니다.
아이브는 나이를 먹었으므로 감사의 마음을 전했다.