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

INS-12991: Redis authentication support #101

Merged
merged 98 commits into from
Sep 20, 2021
Merged

INS-12991: Redis authentication support #101

merged 98 commits into from
Sep 20, 2021

Conversation

XA21X
Copy link
Member

@XA21X XA21X commented May 28, 2021

TODO:

  • Connect to replica nodes to propagate ACL commands.
  • Extract refactors into separate PR to reduce size.
  • Benchmark auth vs non-auth for regression.
  • Write additional tests. (Extended existing test.)
  • Bump version.

Closes #91

Copy link
Member

@benbromhead benbromhead left a comment

Choose a reason for hiding this comment

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

Can you move the name changes (e.g. RawFrame stuff) to a different PR

src/server.rs Outdated Show resolved Hide resolved
@benbromhead
Copy link
Member

Another thing to add to the todo is to do a rough benchmark, e.g. redis auth enabled on against the examples/redis-passthrough and maybe examples/redis-cluster using the redis benchmark toolset (e.g. ./src/redis-benchmark -n 10000000 -t get -P 4 -r 10000 -e -c 50).

The real todo is to include the benchmarks in CI/CD...

@XA21X XA21X mentioned this pull request Jun 2, 2021
@XA21X XA21X self-assigned this Jun 2, 2021
@benbromhead
Copy link
Member

Regarding benchmarking this change. There is now a PR for benchmarking on PR via criterion and cargo bench.

In addition, criterion now supports async function benchmarking, which should make writing micro benchs fairly easy.

@XA21X XA21X force-pushed the INS-12991-auth-support branch 2 times, most recently from d408419 to 9348d6c Compare June 17, 2021 18:32
@XA21X XA21X mentioned this pull request Jul 20, 2021
@rukai
Copy link
Member

rukai commented Jul 22, 2021

Can we pull the DockerComposeContext refactor into its own PR?
I think we need those fixes in master asap.

@rukai
Copy link
Member

rukai commented Aug 2, 2021

To resolve the merge conflicts, at this point it might be easier to start from scratch on the latest main branch and copy over the changes manually.
You can then leave out the AsyncContext refactor, its a good idea but such a refactor should go in a separate PR.

shotover-proxy/src/runner.rs Outdated Show resolved Hide resolved
shotover-proxy/src/transforms/redis_transforms/mod.rs Outdated Show resolved Hide resolved
args.get(streams_position + 1)
.and_then(RoutingInfo::for_key)
}
b"AUTH" => Some(RoutingInfo::Other(Command::AUTH)),
Copy link
Member

Choose a reason for hiding this comment

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

I think I'm confused here, wouldn't we want to route the auth command to all upstream redis nodes rather than a random one?

Copy link
Member Author

Choose a reason for hiding this comment

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

AUTH needs special handling (try auth -> switch context -> new connection pool) instead of forwarding to any nodes. The RoutingInfo::Other means this command needs to be handled outside. i.e. it's like Err(command) vs Ok(routes).

let sender = self.get_channels(&message.original).await;
let command = match &message.original {
RawFrame::Redis(Frame::Array(ref command)) => command,
RawFrame::Redis(_) => {
Copy link
Member

Choose a reason for hiding this comment

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

Redis supports some form of inline commands (e.g. so it's easier for telnet clients to interact with). Iirc the codec should error out long before we get here, but it might be worth short circtuiting an error into responses with a helpful error message back to the client.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I only added this to avoid unhandled panics. Not sure what was blocking me from short circuit, will try again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Inline commands are unsupported and therefore blocked by the codec framing so we can't provide a better message from here. The connection gets killed if as much as a single unexpected byte is out of place.

Syntax errors which have valid framing will now report back to the client:

❯ echo -n -e "*1\r\n:1000\r\n" | nc 127.0.0.1 6379
-ERR transform error: syntax error: bad command name

~
❯ echo -n -e ":1000\r\n" | nc 127.0.0.1 6379
-ERR transform error: syntax error: bad command

@rukai
Copy link
Member

rukai commented Aug 18, 2021

I'm really struggling to get my head around this PR.
It seems like theres still a lot of refactoring outside of the actual implementation of authentication.
@benbromhead would it make sense for it to be split again and land these refactors first?

@XA21X XA21X requested a review from rukai September 15, 2021 16:54
redis::cmd("GET").arg("{x}key3").query(&mut connection),
Ok("food".to_string())
);
// To reproduce the auth mixing issue caused by using PoolConnections:
Copy link
Member

Choose a reason for hiding this comment

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

Is this problem solved?
If so lets write a proper test for it instead of this comment.
If not lets raise an issue for us to follow up on it instead of this comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

The underlying problem isn't solved - using the PoolConnections transform will violate assumptions that the auth implementation relies on. I'll raise an issue and remove this comment (but leave the test).

Copy link
Member

Choose a reason for hiding this comment

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

dont forget to raise the issue!

Copy link
Member Author

Choose a reason for hiding this comment

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

Raised #204

Copy link
Member

@rukai rukai left a comment

Choose a reason for hiding this comment

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

LGTM
I would like ben to give the second review as he has the redis domain knowledge.

@benbromhead
Copy link
Member

LGTM

Two minor fixes:
Fix the conflict in drivers test
Remove the unused member strict_close_mode: Option<bool> from the config struct

Sort these out and we can merge :D :D :D

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.

Support Redis password authentication
4 participants