0
私のWebサービス上の操作を呼び出す各クライアントがデータベースに対応するユーザー名とパスワードを持つようにするため、WCFサービスはカスタムの認証情報検証ツールをカスタムメッセージベースセキュリティに使用します。ユーザーは、私は、コンテキストベースの呼び出しを行うために、私のOperationContractの実装でユーザ名を使用した認証を渡した後WCF操作からClientCredentialsを取得する
Imports System.IdentityModel.Selectors
Imports System.IdentityModel.Tokens
Public Class CredentialsValidator
Inherits UserNamePasswordValidator
Public Overrides Sub Validate(ByVal userName As String, ByVal password As String)
Dim authenticationApi As New AuthenticationGateway()
If Not authenticationApi.IsValid(userName, password) Then
Throw New SecurityTokenException("Validation Failed.")
End If
End Sub
End Class
事は、あります。
<ServiceContract(Name:="IMyService")> _
Public Interface IMyService
<OperationContract()> _
Function GetAccountNumber() As String
End Interface
Public Class IntegrationService
Implements IIntegrationService
Public Function GetAccountNumber() As String Implements IMyService.GetAccountNumber
Dim userName As String '' Here I want the userName set from credentials
Dim accountApi As New AccountGateway()
Return accountApi.GetAccountNumber(userName)
End Function
End Class
私は彼らの実際のユーザー名を指定するには、呼び出し先の誠実さに依存しているカントので、パスワードに渡さずにそれを渡すことはできません。私は、Webサービスを呼び出すたびにClientCredentialsを受け入れることを避けたいと思っていました。
ありがとうございました。