authentication - ServiceStack Redis 身份验证持久化

标签 authentication redis persistence servicestack

我正在尝试学习如何使用 Redis 在 ServiceStack 中实现 UserAuth 持久化。

我的 Global.asax.cs 中有以下代码:

public class HelloAppHost : AppHostBase
{
    public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) {}

    public override void Configure(Funq.Container container)
    {
        container.Register<ICacheClient>(new MemoryCacheClient());

        Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
            new CredentialsAuthProvider()
        }));
        container.Register(c => new PooledRedisClientManager(
            "127.0.0.1:6379"
        ));
        container.Register<IUserAuthRepository>(
            c => new RedisAuthRepository(c.Resolve<PooledRedisClientManager>()));
    }
}

我在 TCP/6379(来自 Deb7 包)上本地公开了 Redis 的默认安装/配置。

当我调用身份验证服务时,我收到以下错误:

Response Status

Error Code RedisResponseException
MessageZero length respose, sPort: 65470, LastCommand: 
Stack Trace[Auth: 07/06/2013 17:29:08]: [REQUEST: {UserName:test,Password:test}]
ServiceStack.Redis.RedisResponseException: Zero length respose, sPort: 65470, LastCommand: at 
ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error) at 
ServiceStack.Redis.RedisNativeClient.ParseSingleLine(String r) at 
ServiceStack.Redis.RedisNativeClient.ReadData() at 
ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) at 
ServiceStack.Redis.RedisNativeClient.HGet(String hashId, Byte[] key) at 
ServiceStack.Redis.RedisClient.GetValueFromHash(String hashId, String key) at 
ServiceStack.ServiceInterface.Auth.RedisClientManagerFacade.RedisClientFacade.GetValueFromHash(String hashId, String key) at 
ServiceStack.ServiceInterface.Auth.RedisAuthRepository.GetUserAuthByUserName(IRedisClientFacade redis, String userNameOrEmail) at 
ServiceStack.ServiceInterface.Auth.RedisAuthRepository.GetUserAuthByUserName(String userNameOrEmail) at 
ServiceStack.ServiceInterface.Auth.RedisAuthRepository.TryAuthenticate(String userName, String password, UserAuth& userAuth) at 
ServiceStack.ServiceInterface.Auth.CredentialsAuthProvider.TryAuthenticate(IServiceBase authService, String userName, String password) at 
ServiceStack.ServiceInterface.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, String userName, String password, String referrerUrl) at 
ServiceStack.ServiceInterface.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, Auth request) at 
ServiceStack.ServiceInterface.Auth.AuthService.Authenticate(Auth request, String provider, IAuthSession session, IAuthProvider oAuthConfig) at 
ServiceStack.ServiceInterface.Auth.AuthService.Post(Auth request) at 
ServiceStack.ServiceInterface.Auth.AuthService.Get(Auth request) at 
lambda_method(Closure , Object , Object ) at ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext requestContext, Object instance, TRequest request)

是什么导致了这个错误?

我怀疑它可能是以下之一:

-我需要以某种方式设置 Redis 吗? -我的 Global.asax.cs 里面有错误吗? -还有什么东西不见了吗? -我完全走错路了吗?!

谢谢!

最佳答案

万一其他人遇到这个问题,看起来这是由于客户端和服务器之间的版本不匹配(debian 7 稳定包来自旧的 2.4.x 分支)。我从 2.6.13 源构建服务器,一切似乎都正常。

关于authentication - ServiceStack Redis 身份验证持久化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16993048/

相关文章:

sharepoint - 登录 SharePoint 之前的自定义使用条款页面

javascript - 401 在 3G 上提示,但在 Wi-Fi 上不提示 - XmlHttpRequest over SSL with Basic Authentication, hard-coded credentials

javascript - 在数组内的对象中搜索

c - 如何在多个Lua State(多线程)之间传递数据?

delphi - 如何向 Delphi Docking 示例添加持久性

java - Maven 无法定位持久单元

java - 持久化和ormapping之间的关系

authentication - 限制 Azure 身份提供商

java - Spring @Cacheable 使用 hset

redis - 更改redis哨兵中的法定人数