servicestack客户端认证加密密码

问题描述 投票:0回答:1

我有Xamarin应用程序,它使用servicestack作为后端API,当前对用户进行身份验证的实现是从客户端发送纯文本到服务器,然后对用户进行身份验证,我在这里需要两件事:

(i) 有没有办法使用 servicestack.client 在客户端加密密码

public override void Configure(Container container)
{
    Plugins.Add(new AuthFeature(() => new AuthUserSession(),
      new IAuthProvider[] { 
        new BasicAuthProvider(), 
        new CredentialsAuthProvider(),credentials
      }));

    Plugins.Add(new RegistrationFeature());

    container.Register<ICacheClient>(new MemoryCacheClient());
    var userRep = new InMemoryAuthRepository();
    container.Register<IUserAuthRepository>(userRep);
} 

(ii) 关于登录本身 - 当用户登录时,它会生成我无法在我的移动应用程序中使用的 cookie。如何让用户无需每次登录即可使用servicestack应用程序。

c# .net servicestack
1个回答
0
投票

确保您的密码(以及其他所有内容)加密发送的标准方法是使用 SSL 配置后端服务,以便所有流量都通过 https 发送。

替代方法是使用 ServiceStack 的加密消息传递功能

为了使用您的会话 ID 填充您的服务客户端,您可以使用以下方法保存来自经过身份验证的服务客户端的 cookie:

var ssId = client.GetSessionId();
var sspId = client.GetPermanentSessionId(); //If RememberMe=true

然后将其附加到新的服务客户端:

client.SetSessionId(ssId);
client.SetPermanentSessionId(sspId);
© www.soinside.com 2019 - 2024. All rights reserved.