我应该签署(用公钥/私钥)基于表单的身份验证(无SSL)? [英] Should I sign (with a public/private key) a form based authentication (no SSL)?

查看:157
本文介绍了我应该签署(用公钥/私钥)基于表单的身份验证(无SSL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一个基于表单的身份验证。
我应该签署(用公钥/私钥)基于表单的身份验证(无SSL)?

I want to do a form based authentication. Should I sign (with a public/private key) a form based authentication (with no SSL)?

我知道这将无法避免中间人攻击,但至少如果我把它藏在签名会确保密码的值。

I know it will not avoid a middle man attack, but at least it will secure the value of the password if I hide it in the signature.

它是没用的,签署一份表格,身份验证?什么是没有SSL认证的最佳途径?

Is it useless to sign a form authentication? What are the best ways to authenticate without SSL?

做这样的Heroku场所免费提供SSL?我只是玩弄和努力学习很酷的东西,不希望支付:(

Do places like Heroku provide SSL for free? I am just playing around and trying to learn cool stuff, don't want to pay :(

[更新]
在一个非常简洁的方式我要开始并通过HTTP保持最低限度的安全一个简单的会话。我该怎么办呢?主要要求是,以避免未认证用户从做请求的REST API可能更改服务器上的东西。

[UPDATE]: In a very concise way I want to start and maintain a simple session with minimal security through HTTP. How can I do that? The main requirement is to avoid an unauthenticated user from doing requests to the REST API that might change something on the server.

推荐答案

假设你自己的客户端和服务器,因此可以平凡共享它们之间的秘密(即一定数量的随机字节),尽管有这些问题保持这个秘密的秘密,那么,假设你使用REST这样的HTTP请求的参数都是在URL,而不是在身体:

Assuming that you own the client and the server, and hence can trivially share a secret between them (i.e. some number of random bytes), and notwithstanding the issues of keeping that secret secret, then, assuming that you're using REST such that HTTP request parameters are in the URL and not in the body:


  • 创造一个共享的秘密。我们将这个K.例如,产生128个随机位:

  • Invent a shared secret. We'll call this K. For example, generate 128 random bits:

DD如果=的/ dev /随机BS = 16计数= 1 | OD -t X1

dd if=/dev/random bs=16 count=1 | od -t x1

(长度为128位必需/足够了吗?您的需求取决于...)

(Are 128 bits necessary / sufficient? Depends on your requirements...)

通过每个请求:


  • 生成一个随机数N.这可以是:

  • Generate a nonce N. This is either:


  • 一个随机数。

  • 时间戳:秒纪元以来的/时间窗口大小
    我们会回来的时间窗口的大小。

添加随机数作为一个请求参数:

Add the nonce as a request parameter:

http://foo.com/blah/blah? X = Y @心情惨淡=?N = 0x123456789abcdef

计算含带S:


  • 的HTTP方法,例如GET,POST。

  • 完整的URL。

计算一个HMAC其中:

Compute an HMAC where:


  • K是关键

  • 文本(即东西是HMACed)是S

追加HMAC作为请求参数。

Append the HMAC as a request parameters.

在服务器:


  • 从请求剥去HMAC。

  • Strip the HMAC from the request.

从请求中提取ñ。

验证N(见下文)。

计算能够像上面。

查找客户为其k。

计算的HMAC同上。

进行比较计算的HMAC与请求的人。

Compare computed HMAC with the one from the request.

这意味着:


  • 我要知道K可以发送一个请求。

  • 攻击者无法修改飞行请求的URL,因为这将无效HMAC。

然而,观察者能够捕获和重放请求。这也正是现时进来:

However, an observer can capture and replay the request. That's where the nonce comes in:


  • 如果您使用的是基于时间的随机数,然后

  • If you use a time-based nonce then


  • 的要求可能会在时间窗口内播放。

  • 的时间窗口必须大到足以容纳客户端和服务器,与网络延迟之间的时钟差异。

  • 验证意味着服务器必须检查时间戳,以确保它的现在。

如果您使用的是随机现时那么服务器必须记住历史的随机数,并拒绝与previously见过随机数的任何新的请求。

If you use a random nonce then the server must remember historic nonces and reject any new requests with previously-seen nonces.

更好的:使用时间窗/和/一个随机数。然后,服务器只保留当前的时间窗口内的随机数。

Better: use a time window /and/ a random number. The server then just remembers nonces within the current time window.

当然,这需要时钟同步和随机数的体面的来源,不提供保密性...

Of course, this needs synchronised clocks and a decent source of random numbers, and doesn't provide confidentiality...

这篇关于我应该签署(用公钥/私钥)基于表单的身份验证(无SSL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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