Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for rediss protocol in url #1282

Merged
merged 2 commits into from Jan 9, 2018
Merged

Conversation

calebboyd
Copy link
Contributor

@calebboyd calebboyd commented Oct 27, 2017

This adds the ability to pass rediss as the protocol for a redis_url

This functionality is common in several other redis clients (redis-py, lettuce, Jedis etc)
It is the equivalent of doing

redis.createClient(url, { tls: {} })

It is useful when the the host is signed by a global CA, and no advanced (self signed etc) configuration is required.

@svengerlach
Copy link

I just wanted to start on working on the exact same thing.

Some PaaS providers (e.g. Azure) default to make redis available through a TLS socket.

Alongside the clients @calebboyd already mentioned, Predis (PHP) does the same. Would be cool to see this small change merged.

@dcharbonnier
Copy link
Contributor

#1268

Copy link
Contributor

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost LGTM with some nits.

What is still required is updating the documentation to add a part about what happens if you use rediss: instead of redis: including a note that TLS options have to be passed in with the tls option if required.

README.md Outdated
@@ -216,7 +216,7 @@ using unix sockets if possible to increase throughput.
| host | 127.0.0.1 | IP address of the Redis server |
| port | 6379 | Port of the Redis server |
| path | null | The UNIX socket string of the Redis server |
| url | null | The URL of the Redis server. Format: `[redis:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). |
| url | null | The URL of the Redis server. Format: `[redis:][rediss:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change this to the following?

[redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]

Right now the syntax would be wrong as it would actually "allow" redis:rediss://....

options.tls = options.tls || {};
} else {
console.warn('node_redis: WARNING: You passed "' + parsed.protocol.substring(0, parsed.protocol.length - 1) + '" as protocol instead of the "redis" protocol!');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change this to the following:

if (parsed.protocol) {
  if (parsed.protocol === 'rediss:') {
    options.tls = ...
  } else if (parsed.protocol !== 'redis:') {
    console.warn('...')
  }
}

test/tls.spec.js Outdated
@@ -108,6 +108,29 @@ describe('TLS connection tests', function () {
client.get('foo', helper.isString('bar', done));
});

describe('using rediss as url protocol', function (done) {
var tls = require('tls')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the require to the top of the file.

@calebboyd
Copy link
Contributor Author

@BridgeAR updated!

@BridgeAR BridgeAR merged commit 1a4c410 into redis:master Jan 9, 2018
@calebboyd calebboyd deleted the rediss branch January 9, 2018 16:59
epatters added a commit to epatters/datascienceontology-backend that referenced this pull request Oct 18, 2018
Use master version of Node Redis client for now, because TLS support is
not yet officially released:

redis/node-redis#1268
redis/node-redis#1282
epatters added a commit to epatters/datascienceontology-backend that referenced this pull request Dec 1, 2019
Use master version of Node Redis client for now, because TLS support is
not yet officially released:

redis/node-redis#1268
redis/node-redis#1282
epatters added a commit to epatters/datascienceontology-backend that referenced this pull request Dec 1, 2019
Use master version of Node Redis client for now, because TLS support is
not yet officially released:

redis/node-redis#1268
redis/node-redis#1282
@lenkan
Copy link

lenkan commented Jan 29, 2020

@BridgeAR do you have any plans to publish a new version with this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants