Token-Based Authentication in WCF

前端 未结 1 737
终归单人心
终归单人心 2021-01-13 06:46

I am creating a website which will contain both ASP.NET pages and a Flash applet. I want to encapsulate my business logic in a WCF service which will be exposed through two

相关标签:
1条回答
  • 2021-01-13 07:06

    As it seems the original question has been answered I'll keep this brief, but one approach would indeed be to pass the authentication token in an http header and override CheckAccess(OperationContext operationContext, ref Message message) in a custom ServiceAuthorizationManager .

    You will have previously configured the service to use a custom policy that implements IAuthorizationPolicy.

    All that remains is to implement simple IIdentity and IPrincipal classes to store your authorization state.

    A number of good articles exist on this subject:

    http://msdn.microsoft.com/en-us/library/system.identitymodel.policy.iauthorizationpolicy.aspx

    http://msdn.microsoft.com/en-us/library/system.servicemodel.serviceauthorizationmanager.aspx

    I guess this may still feel like a "roll-your-own" solution, but its at least reassuring when you're following an established pattern. It does have the advantage of black-boxing your authorization code from your service methods.

    0 讨论(0)
提交回复
热议问题