ServiceAuthorizationManager 클래스

정의

서비스 작업에 대한 인증 액세스 검사를 제공합니다.

public ref class ServiceAuthorizationManager
public class ServiceAuthorizationManager
type ServiceAuthorizationManager = class
Public Class ServiceAuthorizationManager
상속
ServiceAuthorizationManager

예제

다음 예제에서는 MyServiceAuthorizationManager로부터 상속되었으며 ServiceAuthorizationManager 메서드를 재정의하는 CheckAccessCore라는 클래스를 보여 줍니다.

public class MyServiceAuthorizationManager : ServiceAuthorizationManager
{
  protected override bool CheckAccessCore(OperationContext operationContext)
  {
    // Extract the action URI from the OperationContext. Match this against the claims
    // in the AuthorizationContext.
    string action = operationContext.RequestContext.RequestMessage.Headers.Action;
  
    // Iterate through the various claim sets in the AuthorizationContext.
    foreach(ClaimSet cs in operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets)
    {
      // Examine only those claim sets issued by System.
      if (cs.Issuer == ClaimSet.System)
      {
        // Iterate through claims of type "http://www.contoso.com/claims/allowedoperation".
          foreach (Claim c in cs.FindClaims("http://www.contoso.com/claims/allowedoperation", Rights.PossessProperty))
        {
          // If the Claim resource matches the action URI then return true to allow access.
          if (action == c.Resource.ToString())
            return true;
        }
      }
    }
  
    // If this point is reached, return false to deny access.
    return false;
  }
}

Public Class MyServiceAuthorizationManager
    Inherits ServiceAuthorizationManager
    
    Protected Overrides Function CheckAccessCore(ByVal operationContext As OperationContext) As Boolean 
        ' Extract the action URI from the OperationContext. Match this against the claims.
        ' in the AuthorizationContext.
        Dim action As String = operationContext.RequestContext.RequestMessage.Headers.Action
        
        ' Iterate through the various claimsets in the AuthorizationContext.
        Dim cs As ClaimSet
        For Each cs In  operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets
            ' Examine only those claim sets issued by System.
            If cs.Issuer Is ClaimSet.System Then
                ' Iterate through claims of type "http://www.contoso.com/claims/allowedoperation".
                Dim c As Claim
                For Each c In  cs.FindClaims("http://www.contoso.com/claims/allowedoperation", _
                     Rights.PossessProperty)
                    ' If the Claim resource matches the action URI then return true to allow access.
                    If action = c.Resource.ToString() Then
                        Return True
                    End If
                Next c
            End If
        Next cs 
        ' If this point is reached, return false to deny access.
        Return False
    
    End Function 
End Class

설명

이 클래스는 모든 정책(사용자에게 허용되는 작업을 정의하는 규칙)을 평가하고, 정책을 클라이언트의 클레임과 비교하며, 그 결과로 나온 AuthorizationContextServiceSecurityContext로 설정하고, 특정 서비스 작업에 대한 호출자의 액세스를 허용하거나 거부하여 권한 부여를 결정합니다.

CheckAccessCore 메서드는 리소스에 액세스 하려는 시도가 수행 될 때마다 Windows Communication Foundation (WCF) 인프라에서 호출 됩니다. 이 메서드는 true를 반환하여 액세스를 허용하거나 false를 반환하여 액세스를 거부합니다.

합니다 ServiceAuthorizationManager WCF의 일부인 Id 모델 인프라입니다. ID 모델을 통해 사용자 지정 권한 부여 정책 및 사용자 지정 권한 부여 체계를 만들 수 있습니다. Id 모델의 작동 방식에 대 한 자세한 내용은 참조 하세요. 관리 클레임 및 권한 부여 Id 모델을 사용 하 여입니다.

사용자 지정 권한 부여

이 클래스는 권한 부여를 수행하지 않으며 사용자가 모든 서비스 작업에 액세스하도록 허용합니다. 더 제한적으로 권한을 부여하려면 사용자 지정 정책을 확인하는 사용자 지정 권한 부여 관리자를 만들어야 합니다. 이렇게 하려면 이 클래스로부터 CheckAccessCore 메서드를 상속하여 재정의합니다. ServiceAuthorizationManager 속성을 통해 이 파생 클래스의 인스턴스를 지정합니다.

애플리케이션은 CheckAccessCore에서 OperationContext 개체를 사용하여 호출자 ID(ServiceSecurityContext)에 액세스할 수 있습니다.

IncomingMessageHeaders 개체를 반환하는 MessageHeaders 속성을 가져옴으로써 애플리케이션은 서비스(To)와 작업(Action)에 액세스할 수 있습니다.

RequestContext 개체를 반환하는 RequestContext 속성을 가져옴으로써 애플리케이션은 전체 요청 메시지(RequestMessage)에 액세스하고 그에 따라 권한 부여 결정을 수행할 수 있습니다.

예제를 보려면 방법: 서비스에 대 한 사용자 지정 권한 부여 관리자 만들기합니다.

사용자 지정 권한 부여 정책을 만들려면 IAuthorizationPolicy 클래스를 구현합니다. 예를 들어 참조 방법: 사용자 지정 인증 정책을 만들고합니다.

사용자 지정 클레임을 만들려면 Claim 클래스를 사용합니다. 예를 들어 참조 방법: 사용자 지정 클레임을 만드는합니다. 사용자 지정 클레임을 비교 하려면 비교 해야에 표시 된 대로 클레임 방법: 클레임 비교합니다.

자세한 내용은 사용자 지정 권한 부여합니다.

클라이언트 애플리케이션 구성 파일에서 serviceAuthorization>을< 사용하여 사용자 지정 권한 부여 관리자의 유형을 설정할 수 있습니다.

생성자

ServiceAuthorizationManager()

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

메서드

CheckAccess(OperationContext)

특정 작업 컨텍스트에 대한 권한 부여를 확인합니다.

CheckAccess(OperationContext, Message)

메시지에 액세스해야 할 때 특정 작업 컨텍스트에 대한 권한 부여를 확인합니다.

CheckAccessCore(OperationContext)

기본 정책 평가에 따라 해당 작업 컨텍스트에 대한 권한 부여를 확인합니다.

Equals(Object)

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

(다음에서 상속됨 Object)
GetAuthorizationPolicies(OperationContext)

정책 평가에 참여하는 정책 집합을 가져옵니다.

GetHashCode()

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

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상

추가 정보