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

Add auth option for redis #8

Merged
merged 1 commit into from
Jul 29, 2019
Merged

Add auth option for redis #8

merged 1 commit into from
Jul 29, 2019

Conversation

D-Raiser
Copy link

@D-Raiser D-Raiser commented Jul 24, 2019

Some instances of Redis (Microsoft Azure Redis Cache for example) require authentication before allowing any other commands to be executed.

redis/redis.go Outdated
if store.auth != "" {
_ = c.Send("AUTH", store.auth)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is the right place for this.

AUTH needs to be the first command that we send - but is that per connection, or per connection pool? If it's per connection then we would need to do it every time we called store.getConn, i.e. for every kind of operation. But then we'd have no way of knowing if this is a new connection or a reused one.

I think possibly the way we're supposed to do this is by specifying the DialPassword option when we call redis.DialURL().

Copy link
Author

@D-Raiser D-Raiser Jul 25, 2019

Choose a reason for hiding this comment

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

@eli-darkly You're right, this should've been per Connection.

I updated the commit to use the redis.DialPassword option in redis.DialURL().

@eli-darkly
Copy link
Contributor

I had two more thoughts about this, a bit late:

  1. It should already be possible to specify a password in the Redis URL. I'm still fine with supporting a separate password option, but just wanted to mention that.
  2. This isn't the only advanced Redis option that people might want to configure: for instance, there's the TLS option. Rather than surfacing all of these as separate options in our own API, I think it might be better to have an option like this:
// DialOption creates an option for NewRedisFeatureStoreWithDefaults to specify any of the
// advanced Redis connection options supported by Redigo, such as DialPassword.
//
//     import (
//         redigo "github.com/garyburd/redigo/redis"
//         "gopkg.in/launchdarkly/go-server-sdk.v4/redis"
//     )
//     store, err := redis.NewRedisFeatureStoreWithDefaults(redis.DialOption(redigo.DialPassword("verysecure123")))

That would mean we are surfacing Redigo API details in our own API, but that is already the approach we use in our other SDKs where we provide direct access to advanced configuration options of the underlying implementation of Redis or DynamoDB or the HTTP client or whatever—and if we ever release a Redis integration that does not use Redigo, it will be in a new major version (and possibly will be broken out into a separate project, rather than being a subpackage of the SDK). So I think I would rather add that general feature now, rather than trying to anticipate all the other options people might want to use.

@eli-darkly eli-darkly changed the base branch from v4 to contrib July 29, 2019 21:33
@eli-darkly
Copy link
Contributor

By the way, I've retargeted this PR to the contrib branch because we are trying out a new workflow for accepting external PRs. Since in Go, merging anything onto the default branch is equivalent to immediately releasing it, we're going to start accumulating contributions on a separate branch until we're ready to release.

@eli-darkly
Copy link
Contributor

And since we're doing that, I'm fine with merging this now, and then we can consider making the additional changes I suggested.

@eli-darkly eli-darkly merged commit 0b1c9c3 into launchdarkly:contrib Jul 29, 2019
@D-Raiser D-Raiser deleted the dr/redisauth branch July 30, 2019 06:41
@eli-darkly eli-darkly mentioned this pull request Jul 31, 2019
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.

2 participants