[英]Step by step instruction for secure replication?
Not sure if the question should rather be on ServerFault ? 不确定问题是否应该在ServerFault上 ?
I have a couchDB setup on my server using Apache credentials (but I can switch that off if it is an distraction). 我在我的服务器上使用Apache凭据进行了一个couchDB设置(但如果分散注意力,我可以关闭它)。
I have local instances on various laptops. 我在各种笔记本电脑上都有本地实例。 Now I want to setup secure (continuous) replication.
现在我想设置安全(连续)复制。 From my understanding I could use username/password, SSL certificates or OAuth.
根据我的理解,我可以使用用户名/密码,SSL证书或OAuth。 I found bits and pieces of information:
我发现了一些信息:
All this documents added a hunch, but also confusion (I'm just a simple mind ). 所有这些文件都增添了预感,但也让人感到困惑(我只是一个简单的想法 )。
What I'm looking for is a step by step instruction: 我正在寻找的是一步一步的指导:
Where could I find that? 我在哪里可以找到它?
Secure transfer of user credentials is a very delicate question. 安全传输用户凭据是一个非常棘手的问题。
If we wouldn't look on third-party, in most cases, SSL is better way to start from since it has wide support by every tool you might used. 如果我们不想第三方,在大多数情况下,SSL是更好的开始方式,因为它可能会被您使用的每个工具广泛支持。 SSL certificate, provides not only encryption (even self-signed ones), but insurance that user had requested right resource.
SSL证书,不仅提供加密(甚至是自签名的加密),还提供用户请求正确资源的保险。 Last option also worth to be highlighted if you're care about server security.
如果您关心服务器安全性,最后一个选项也值得强调。 The main drawback of SSL usage is performance degradation (vary on used algorithm) since server have to decrypt data and client need to validate certificate in additional to common communication routines.
SSL使用的主要缺点是性能下降(因使用的算法而异),因为服务器必须解密数据,并且除了常见的通信例程之外,客户端还需要验证证书。 Also you have to pay some money for trusted certificate ( not always true ).
此外,你必须为可靠的证书支付一些钱( 并非总是如此 )。
Using OAuth allows to not disclose real user credentials and easily maintain their access control from server side. 使用OAuth可以不泄露真实的用户凭据,并且可以轻松地从服务器端维护其访问控制。 Also, you need some library that handle OAuth 1.0 specification properly and if your platform miss such - you have to implement it by your own.
此外,您需要一些能够正确处理OAuth 1.0规范的库,如果您的平台错过了 - 您必须自己实现它。 In additional OAuth provides transfer data signing, so it aims to be safe for MiTM case.
另外OAuth提供传输数据签名,因此它旨在为MiTM案例提供安全保障。 That's actually all that he does.
这实际上就是他所做的一切。
As you note, SSL and OAuth are about two different things: SSL helps to encrypt data on transport level (TLS) while OAuth take care about credentials disclosure in non secure environment. 如您所知,SSL和OAuth有两个不同的东西:SSL有助于在传输级别(TLS)上加密数据,而OAuth会在非安全环境中处理凭据泄露。 They are not replacement for each other, but each of them may stand as good additional to other.
它们不是彼此的替代品,但是它们中的每一个都可以替代其他的。
To setup SSL support for CouchDB just follow the documentation guide . 要为CouchDB设置SSL支持,请按照文档指南进行操作 。 It's quite simple and easy to do.
这很简单易行。 Note, that if there is some proxy server in front of CouchDB, it might be wise to setup SSL for him and proxy data to local CouchDB instance via regular HTTP protocol.
请注意,如果CouchDB前面有一些代理服务器,那么为他设置SSL并通过常规HTTP协议将代理数据代理到本地CouchDB实例可能是明智之举。
To setup OAuth there need to make next steps: 0. Ensure that {couch_httpd_oauth, oauth_authentication_handler}
handler is exists for authentication_handlers
option of [httpd]
section for default.ini
config file: 要设置OAuth,需要执行以下步骤:0。确保
{couch_httpd_oauth, oauth_authentication_handler}
[httpd]
部分的authentication_handlers
选项的{couch_httpd_oauth, oauth_authentication_handler}
处理程序存在于default.ini
配置文件中:
[httpd] authentication_handlers = {couch_httpd_oauth, oauth_authentication_handler}, {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler} [httpd] authentication_handlers = {couch_httpd_oauth,oauth_authentication_handler},{couch_httpd_auth,cookie_authentication_handler},{couch_httpd_auth,default_authentication_handler}
After that you need to edit your local.ini
file in next way: 之后,您需要以下一种方式编辑
local.ini
文件:
[oauth_consumer_secrets]
example.org = sekr1t
[oauth_token_secrets]
token1 = tokensekr1t
[oauth_token_users]
token1 = joe
That's all! 就这样! If you have CouchDB version 1.2 or higher, you may also define OAuth credentials within user document inside
_users
database: 如果您有CouchDB 1.2或更高版本,您还可以在
_users
数据库中的用户文档中定义OAuth凭据:
{
"_id": "org.couchdb.user:joe",
"type": "user",
"name": "joe",
"password_sha": "fe95df1ca59a9b567bdca5cbaf8412abd6e06121",
"salt": "4e170ffeb6f34daecfd814dfb4001a73"
"roles": ["foo", "bar"],
"oauth": {
"consumer_keys": {
"example.org": "sekr1t",
"consumerKey2": "key2Secret"
},
"tokens": {
"token1": "tokensekr1t",
"token2": "token2Secret"
}
}
}
Now, when we'd setup OAuth credentials for our user joe , let's start our replication. 现在,当我们为用户joe设置OAuth凭据时,让我们开始复制。 To let CouchDB use OAuth credentials, we need to extend
source
or target
fields, depending on which side will authorize our user: 要让CouchDB使用OAuth凭据,我们需要扩展
source
或target
字段,具体取决于哪一方将授权我们的用户:
{
"source": "mailbox",
"target": {
"url": "https://secure.example.org/mailbox",
"auth": {
"oauth": {
"consumer_secret": "sekr1t",
"consumer_key": "example.org",
"token_secret": "tokensekr1t",
"token": "token1"
}
}
}
}
and POST
this data to _replicate
resource or create document for _replicator
database. 并将此数据
POST
到_replicate
资源或为_replicator
数据库创建文档。 Replication will start from local server to remote secure.example.org
using SSL protocol encryption and all operations will goes for remote user with login joe
. 复制将使用SSL协议加密从本地服务器启动到远程
secure.example.org
,所有操作都将通过登录joe
进行远程用户操作。
Summarizing: combination of SSL and OAuth allows you not only protect transfered data (not only user credentials) and insure that target server was not faked, but also protects real user login name and password from accidental disclosure, control consumer sources (eg if example.org
will be compromised, we can only remove his consumer token, but not force user to change his password) and signing requests for additional protection against MiTM attacks. 总结:SSL和OAuth的组合不仅可以保护传输的数据(不仅是用户凭证),还可以保证目标服务器不是伪造的,还可以保护真实用户登录名和密码免于意外泄露,控制消费者来源(例如,如果
example.org
将被泄露,我们只能删除他的消费者令牌,但不能强迫用户更改他的密码)并签署针对MiTM攻击的额外保护请求。
UPDATE : For your case regular SSL certificate routines are ok: you will need to create personal certificates signed by your own and let clients to setup for further work with your CouchDB. 更新 :对于您的情况,常规SSL证书例程是可以的:您需要创建自己签名的个人证书,并让客户设置以便与CouchDB进一步协作。 The only thing required from CouchDB side is to validate certificates before process the connection.
CouchDB方面唯一需要的是在处理连接之前验证证书。 But note, that custom personal SSL certificate installation may be not trivial especially for mobile clients.
但请注意,自定义个人SSL证书安装可能并非易事,特别是对于移动客户端。
Speaking for OAuth side, CouchDB may use RSA-SHA1 auth method that uses some kind of personal certificate for secret. 对于OAuth方面,CouchDB 可能会使用RSA-SHA1身份验证方法,该方法使用某种个人证书进行保密。 However, you need to patch sources first to unlock this method - it's disabled by default.
但是,您需要首先修补源以解锁此方法 - 默认情况下禁用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.