SessionAuthenticationModule 클래스

정의

WS-Federation 시나리오에서 세션 쿠키를 처리하는 ASP.NET 모듈을 구현합니다.

public ref class SessionAuthenticationModule : System::IdentityModel::Services::HttpModuleBase
public class SessionAuthenticationModule : System.IdentityModel.Services.HttpModuleBase
type SessionAuthenticationModule = class
    inherit HttpModuleBase
Public Class SessionAuthenticationModule
Inherits HttpModuleBase
상속
SessionAuthenticationModule

예제

void Application_Start(object sender, EventArgs e)
{
    // Code that runs on application startup

    //SUBSCRIBE TO SAM EVENTS
    FederatedAuthentication.SessionAuthenticationModule.SessionSecurityTokenCreated += new EventHandler<SessionSecurityTokenCreatedEventArgs>(SessionAuthenticationModule_SessionSecurityTokenCreated);
    FederatedAuthentication.SessionAuthenticationModule.SessionSecurityTokenReceived += new EventHandler<SessionSecurityTokenReceivedEventArgs>(SessionAuthenticationModule_SessionSecurityTokenReceived);
    FederatedAuthentication.SessionAuthenticationModule.SigningOut += new EventHandler<SigningOutEventArgs>(SessionAuthenticationModule_SigningOut);
    FederatedAuthentication.SessionAuthenticationModule.SignedOut += new EventHandler(SessionAuthenticationModule_SignedOut);
    FederatedAuthentication.SessionAuthenticationModule.SignOutError += new EventHandler<ErrorEventArgs>(SessionAuthenticationModule_SignOutError);
}
void SessionAuthenticationModule_SignOutError(object sender, ErrorEventArgs e)
{
    System.Diagnostics.Trace.WriteLine("Handling SignOutError event");
}

void SessionAuthenticationModule_SignedOut(object sender, EventArgs e)
{
    System.Diagnostics.Trace.WriteLine("Handling SignedOut event");
}

void SessionAuthenticationModule_SigningOut(object sender, SigningOutEventArgs e)
{
    System.Diagnostics.Trace.WriteLine("Handling SigningOut event");
}

void SessionAuthenticationModule_SessionSecurityTokenReceived(object sender, SessionSecurityTokenReceivedEventArgs e)
{
    System.Diagnostics.Trace.WriteLine("Handling SessionSecurityTokenReceived event");
}

void SessionAuthenticationModule_SessionSecurityTokenCreated(object sender, SessionSecurityTokenCreatedEventArgs e)
{
    System.Diagnostics.Trace.WriteLine("Handling SessionSecurityTokenCreated event");
    //Store session on the server-side token cache instead writing the whole token to the cookie.
    //It may improve throughput but introduces server affinity that may affect scalability
    FederatedAuthentication.SessionAuthenticationModule.IsReferenceMode = true;
}

다음 XML에는 SAM ASP.NET 파이프라인에서 구성 하는 방법을 보여 줍니다. 일반적인 구성에 있는 여러 가지 요소는 간단한 설명을 위해 여기 생략 됩니다.

<configuration>  
  <system.webServer>  
    <modules>  
      <!--WIF 4.5 modules -->  
      <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>  
      <add name="WsFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>  
    </modules>  
  </system.webServer>  
</configuration>  

설명

ASP.NET 파이프라인에 있는 경우는 SessionAuthenticationModule (SAM)는 WS-페더레이션 시나리오에서 세션 쿠키를 처리 합니다. 지정 된 쿠키 처리기를 사용 하는 CookieHandler HTTP 요청에서 원시 세션 쿠키를 읽고 HTTP 응답에 쓸 속성입니다. 사용 된 SessionSecurityTokenHandler 에 원시 세션 쿠키를 역직렬화 할 애플리케이션에 대해 구성 된 SessionSecurityToken 개체입니다. 세션 보안 토큰을 클레임을 포함 (Claim) 및 주체 (ClaimsPrincipal) 요청이 처리 되는 엔터티와 연결 합니다.

SAM 추가 해당 OnAuthenticateRequest 이벤트 처리기는 HttpApplication.AuthenticateRequest ASP.NET 파이프라인에는 이벤트입니다. 이 처리기 로그인 요청을 가로채서, 세션 토큰을 역직렬화하 고 설정 하면 세션 쿠키가 있으면 합니다 Thread.CurrentPrincipalHttpContext.User 세션 토큰에 포함 된 클레임 보안 주체에는 속성입니다. 다양 한이 프로세스 중 SAM에서 노출 되는 다른 메서드를 호출 합니다.

SignOut (예를 들어 SignOut.aspx.cs 코드 숨김 파일)에 세션에서 사용자 로그인 메서드를 호출할 수 있습니다.

SAM 해당 처리 파이프라인에 대 한 액세스를 제공 하는 여러 이벤트를 노출 합니다. 합니다 SessionSecurityTokenReceivedSessionSecurityTokenCreated 이벤트를 통해 쿠키에서 읽은 되거나 처리 중에 생성 되는 세션 토큰을 수정할 수 있습니다. 일반적으로 추가, 제거 또는 토큰의 클레임을 변환 하거나 만료 시간에 맞게 수행 됩니다. 합니다 SigningOut, SignedOut, 및 SignOutError 이벤트를 로그 아웃 요청을 처리 하는 후크를 제공 합니다. 많은 시나리오에서 global.asax.cs 파일에 종종 이러한 이벤트에 대 한 처리기를 추가 하기만 하면 됩니다.

더 복잡 한 시나리오에서 파생할 수 있습니다 SessionAuthenticationModule 사용자 지정 SAM을 구현 합니다. 이 위해 하는 동안 호출 되는 메서드의 대부분 OnAuthenticateRequestSignOut 세션 처리 수명 주기의 특정 단계에서 사용자 지정 동작을 제공할 수 있도록 노출 됩니다.

아래에서 HTTP 모듈에 추가 하 여 구성 파일의 ASP.NET 파이프라인에 SAM을 추가할 수 있습니다는 <system.webServer> 또는 IIS 7 이상 버전에 대 한 요소는 <system.web> IIS 7 이전 버전에 대 한 요소입니다. SAM에서 사용하는 쿠키 처리기는 cookieHandler> 요소로< 구성할 수 있습니다.

생성자

SessionAuthenticationModule()

SessionAuthenticationModule 클래스의 새 인스턴스를 초기화합니다.

속성

ContextSessionSecurityToken

현재 SessionSecurityToken에 대한 활성 HttpContext을 가져옵니다.

CookieHandler

세션 쿠키를 읽고 쓰고 삭제하는 데 사용되는 쿠키 처리기를 가져옵니다.

FederationConfiguration

현재 모듈에 적용되는 FederationConfiguration 개체를 가져오거나 설정합니다.

(다음에서 상속됨 HttpModuleBase)
IsReferenceMode

세션 정보(클레임 값 등)가 세션 쿠키에 저장되어야 하는지 여부나 세션 콘텐츠가 서버쪽에 저장되고 쿠키를 사용하여 참조만 저장해야 하는지 여부를 지정하는 값을 가져오거나 설정합니다.

메서드

AuthenticateSessionSecurityToken(SessionSecurityToken, Boolean)

들어오는 세션 토큰의 유효성을 검사하여 들어오는 요청을 인증합니다. 유효성 검사가 성공하면 현재 HTTP 컨텍스트 및 스레드 보안 주체를 지정된 SessionSecurityToken로 업데이트합니다.

ContainsSessionTokenCookie(HttpCookieCollection)

지정된 쿠키 컬렉션에 있는 세션 쿠키인지 여부를 확인합니다.

CreateSessionSecurityToken(ClaimsPrincipal, String, DateTime, DateTime, Boolean)

구성된 세션 토큰 처리기를 사용하여 지정된 매개 변수에서 SessionSecurityToken을 만듭니다.

DeleteSessionTokenCookie()

세션 쿠키를 삭제하고 캐시에서 제거합니다.

Dispose()

HttpModuleBase 클래스의 현재 인스턴스에서 사용하는 리소스(메모리 제외)를 해제합니다.

(다음에서 상속됨 HttpModuleBase)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
Init(HttpApplication)

HTTP 모듈을 초기화합니다.

(다음에서 상속됨 HttpModuleBase)
InitializeModule(HttpApplication)

모듈을 초기화하고 모듈의 ASP.NET 애플리케이션 개체에서 이벤트를 처리하도록 준비합니다.

InitializePropertiesFromConfiguration()

구성 파일의 정의를 기준으로 모듈 속성을 초기화합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnAuthenticateRequest(Object, EventArgs)

ASP.NET 파이프라인에서 이벤트를 처리합니다 AuthenticateRequest .

OnPostAuthenticateRequest(Object, EventArgs)

ASP.NET 파이프라인에서 이벤트를 처리합니다 PostAuthenticateRequest .

OnSessionSecurityTokenCreated(SessionSecurityTokenCreatedEventArgs)

SessionSecurityTokenCreated 이벤트를 발생시킵니다.

OnSessionSecurityTokenReceived(SessionSecurityTokenReceivedEventArgs)

SessionSecurityTokenReceived 이벤트를 발생시킵니다.

OnSignedOut(EventArgs)

SignedOut 이벤트를 발생시킵니다.

OnSigningOut(SigningOutEventArgs)

SigningOut 이벤트를 발생시킵니다.

OnSignOutError(ErrorEventArgs)

SignOutError 이벤트를 발생시킵니다.

ReadSessionTokenFromCookie(Byte[])

지정된 세션 쿠키에서 SessionSecurityToken을 읽습니다.

SetPrincipalFromSessionToken(SessionSecurityToken)

HttpContextThread의 주체를 지정한 세션 토큰에 포함된 주체로 설정합니다.

SignOut()

현재 사용자를 로그아웃하고 관련 이벤트를 발생시킵니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
TryReadSessionTokenFromCookie(SessionSecurityToken)

세션 쿠키에서 SessionSecurityToken을 읽으려고 시도하고 세션 쿠키를 성공적으로 읽었는지 여부를 나타내는 값을 반환합니다.

ValidateSessionToken(SessionSecurityToken)

지정된 SessionSecurityToken의 유효성을 검사하고 ID를 반환합니다.

WriteSessionTokenToCookie(SessionSecurityToken)

지정된 SessionSecurityToken을 세션 쿠키에 씁니다.

이벤트

SessionSecurityTokenCreated

세션 보안 토큰이 발생합니다.

SessionSecurityTokenReceived

쿠키에서 세션 보안 토큰을 읽으면 발생합니다.

SignedOut

사용자가 로그아웃한 후에 발생합니다.

SigningOut

로그인 세션을 삭제하기 전에 발생합니다.

SignOutError

로그아웃 중 오류가 있으면 발생합니다.

적용 대상