针对iPhone与认证大厦.NET WCF服务 [英] Building .NET WCF service for iPhone with authentication

查看:147
本文介绍了针对iPhone与认证大厦.NET WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想创建一个非常简单的REST风格的WCF服务,这将提供数据的iPhone应用程序。

Trying to create a very simple restful WCF service which will serve data to an iPhone application.

想利用某种基本的身份验证,最有可能的用户名/密码或某种形式的象征。

Would like to utilise basic authentication of some kind, most likely username / password or a token of some sort.

有几个问题寻找拍摄目标周围的任何好的文档,因此任何帮助将非常AP preciated!

Having a few issues finding any good documentation around the subject so any help would be much appreciated!

干杯, 蒂姆·

推荐答案

对于任何人谁是有兴趣的,我解决了这个具有以下内容:

For anyone who's interested, I resolved this with the following:

在以下system.servicemodel web.config中:

In web.config under system.servicemodel:

<behaviors>
    <serviceBehaviors>
        <behavior name="default">
            <serviceAuthorization serviceAuthorizationManagerType="Your.ServiceAuthorizationManager"></serviceAuthorization>
        </behavior>
    </serviceBehaviors>
</behaviors>
<services>
    <service name="Your.WCF.Service" behaviorConfiguration="default">
</services>

然后在您的经理处理(Your.ServiceAuthorizationManager类)可以访问在操作方面的要求,可以授权,如果授权;否则为false返回true。

Then in your manager handling (Your.ServiceAuthorizationManager class) you have access to the request in the operation context, can authorize and return true if authorized and false if not.

public class Your.ServiceAuthorizationManager : ServiceAuthorizationManager
{
    protected override bool CheckAccessCore(OperationContext operationContext)
    {
        // Validate request here...

        return true;
    }
}

  • 显然复制粘贴此code将无法正常工作,你需要编辑一些地方。
  • 希望它可以帮助别人!

    这篇关于针对iPhone与认证大厦.NET WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆