如何使用 AWS 身份验证保护我的 wcf 服务

How to secure my wcf service using AWS authentication

我可以使用 AWS 身份验证保护我的 WCF 服务吗?我试图通过 google 搜索和查找有关调用已使用 AWS 身份验证保护的服务的文章来解决这个问题。不是一篇关于如何使用 AWS 保护 WCF 服务的文章。没有选项吗,我对 AWS 身份验证和签名的理解是错误的。请指出一篇文章作为开始。

我假设您打算创建一个使用 an HMAC based authentication scheme like Amazon S3 的 WCF REST 服务。

实现它的方法是创建您自己的 WebServiceHost and override the ApplyConfiguration 方法。在这个方法中,你设置了一个新的 ServiceAuthorizationManager.

this.Authorization.ServiceAuthorizationManager = new MyServiceAuthorizationManager();

从 WCF 的 ServiceAuthorizationManager 派生 MyServiceAuthorizationManager class 并覆盖 CheckAccessCore 方法。

class MyServiceAuthorizationManager : ServiceAuthorizationManager
{
    protected override bool CheckAccessCore(OperationContext operationContext)
    {
        // check the validity of the HMAC
        // return true if valid, false otherwise;
        return IsValidHMAC(WebOperationContext.Current);
    }
}

有关算法实现的更多详细信息,请参见this answer