GithubHelp home page GithubHelp logo

nathanielks / aws_redis_elasticache_proxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonty/aws_redis_elasticache_proxy

0.0 1.0 0.0 14 KB

Prototype of an multi-tenant TLS-enabled AWS Redis Elasticache proxy

Shell 6.91% Go 93.09%

aws_redis_elasticache_proxy's Introduction

Redis elasticache proxy

This is a prototype of a multi-user proxy to be placed in front of many AWS Redis Elasticache instances.

Elasticache does not support authentication or TLS - the AWS recommendation is that the security group containing the Elasticache should only be attached to instances that are permitted to access it, however this does not work when you have shared instances with mixed tenants on them.

YOU SHOULD NOT USE THIS PROXY AS IS. It has not been validated in production, and is a proof of concept more than anything else.

How it works

  • The proxy runs in the security group attached to all the Elasticache instances that have been started by tenants and is the only way to access them.
  • Tenants are given a token via some means (such as a PaaS broker that also creates the Elasticache instance) along with the hostname and port of the proxy.
  • The token is actually a base64 encoded value that looks like ELASTICACHE_HOST:PORT HASH, where the host/port are the ones belonging to their ES instance, and HASH is sha256(ELASTICACHE_HOST:PORT SHARED_SECRET). The SHARED_SECRET is only known to the proxy and whatever issues the token.
  • The tenant configures their Redis client to connect to the host:port they have been given, and uses the token as the redis server password. If the proxy is running in TLS mode they must also configure their client for TLS.
  • The server parses and validates the token, connects to the Elasticache instance the token is valid for, then uses a Linux socket splice to attach the tenant and Elasticache sockets to one another.
  • At this point all packet proxying is being handled by the Linux kernel and the proxy code sits back with an iced tea.

How does one proxy

  1. This should be running on an instance with access to the elasticache instances, but nothing else should be in that security group.
  2. It can operate both in TLS and non-TLS modes, but assuming non TLS...
  3. Start the proxy ./proxy 0.0.0.0:6379 SHARED_SECRET - SHARED_SECRET is a shared secret that is used to issue tokens
  4. Generate a token for the proxy using ./generate_token.sh ELASTICACHE_HOST:ELASTICACHE_PORT SHARED_SECRET
  5. Configure your redis client to point at the proxy host and use the token generated in (4) as the redis server password

Use of TLS mode is left as an excercise for the reader. As is writing some kind of broker to issue the tokens and create Elasticache instances to tenants.

aws_redis_elasticache_proxy's People

Contributors

jonty avatar nathanielks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.