【发布时间】:2017-01-09 12:29:44
【问题描述】:
我正在使用服务堆栈开发自托管 Windows HTTP 服务,我有一个请求来实现基本身份验证(用户名/密码)以对调用应用程序进行身份验证。这是我现在正在使用的代码,它工作正常:
Plugins.Add(new AuthFeature(() => new AuthUserSession() {},
new IAuthProvider[] { new BasicAuthProvider() })); //CustomBasicAuthProvider()
container.Register<ICacheClient>(new MemoryCacheClient());
var userRepository = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRepository);
string hash;
string salt;
new SaltedHash().GetHashAndSaltString("passwordinhere", out hash, out salt);
userRepository.CreateUserAuth(new UserAuth()
{
Id = 1,
DisplayName = "userdisplayname",
UserName = "usernameinhere",
PasswordHash = hash,
Salt = salt
}
, "app");
当我检查来自我的服务的响应标头时,我清楚地看到它包含 2 个 cookie:
设置 Cookie:ss-id=dT8Yy6ejhgfjhgfkVvcxcxCNtngYRS4;path=/
Set-Cookie:ss-pid=p4lsgo18JhYF4CTcxkhgkhgffRZob;path=/;expires=Fri, 09 Jan 2037 12:17:03 GMT
出于安全目的,我需要配置 ServiceStack 以将 ;httpOnly 标志添加到这些 cookie 中,但我不知道该怎么做。
各位,有人知道怎么做吗?任何想法都非常受欢迎。
提前感谢您的帮助:)
【问题讨论】:
标签: rest servicestack httponly cookie-httponly