Skip to content
This repository was archived by the owner on Nov 10, 2018. It is now read-only.

Commit 63f8841

Browse files
committed
Initial open source commit.
0 parents  commit 63f8841

File tree

8 files changed

+1019
-0
lines changed

8 files changed

+1019
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/radshift

Gopkg.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
#
7+
# required = ["github.com/user/thing/cmd/thing"]
8+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9+
#
10+
# [[constraint]]
11+
# name = "github.com/user/project"
12+
# version = "1.0.0"
13+
#
14+
# [[constraint]]
15+
# name = "github.com/user/project2"
16+
# branch = "dev"
17+
# source = "github.com/myfork/project2"
18+
#
19+
# [[override]]
20+
# name = "github.com/x/y"
21+
# version = "2.4.0"
22+
23+
24+
[[constraint]]
25+
branch = "master"
26+
name = "github.com/lib/pq"
27+
28+
[[constraint]]
29+
branch = "master"
30+
name = "github.com/uhoh-itsmaciek/femebe"
31+
32+
[[constraint]]
33+
name = "gopkg.in/alecthomas/kingpin.v2"
34+
version = "~2.2.0"

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright 2017 Simple Finance Technology Corp
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Radshift
2+
A custom authentication proxy for [AWS Redshift](https://aws.amazon.com/redshift/). Radshift accepts Postgres connections, authenticates users using [LinOTP](https://www.linotp.org/), then proxies through to Redshift. Appropriate Redshift database users are created/updated automatically on-demand.
3+
4+
It uses [femebe](https://github.com/uhoh-itsmaciek/femebe) to do the heavy lifting of the Postgres protocol.
5+
6+
## Motivation
7+
At the time we developed Radshift, AWS Redshift only supported username/password authentication (no certificate or LDAP-based authentication). We wanted to hook into other internal auth systems, so Radshift was born as a temporary solution. There is nothing Redshift-specific about the project except our initial use case.
8+
9+
## Caveats
10+
This code should not be considered production-ready, but may be useful as an example for how to implement similar forms of Postgres proxy functionality. It is meant primarily for human users and has some race conditions if a single user creates multiple concurrent connections in quick succession.
11+
12+
You may want to look at [PgBouncer](https://pgbouncer.github.io/) for a more production-ready proxy.
13+
14+
## How it works
15+
![](diagram.png)
16+
17+
## Building
18+
Building from source requires a working Go environment, but no other special tricks. Vendored dependencies are managed with [dep](https://github.com/golang/dep).
19+
20+
```
21+
go get -u github.com/SimpleFinance/radshift/...
22+
```
23+
24+
## Usage
25+
```
26+
usage: radshift --ssl-cert=<path/to/ssl.crt> --ssl-key=<path/to/ssl.key> --redshift=<[...].redshift.amazonaws.com:5439> --redshift-ca-bundle=<path/to/redshift-ssl-ca-cert.pem> --redshift-user=<user> --redshift-password=<password> --linotp=<https://linotp/auth> --linotp-ca-bundle=<path/to/ca_bundle.pem> [<flags>]
27+
28+
An authenticating proxy for Redshift.
29+
30+
Flags:
31+
--help Show context-sensitive help (also try
32+
--help-long and --help-man).
33+
-v, --verbose enable verbose output.
34+
--insecure Disable authentication and weaken/disable SSL
35+
(dangerous!).
36+
--listen=127.0.0.1:5432 Interface/port on which to listen.
37+
--ssl-cert=<path/to/ssl.crt>
38+
Path to SSL certificate in PEM format (default:
39+
$SSL_CRT_PATH).
40+
--ssl-key=<path/to/ssl.key>
41+
Path to SSL private key in PEM format (default:
42+
$SSL_KEY_PATH).
43+
--redshift=<[...].redshift.amazonaws.com:5439>
44+
Hostname/IP and port of backend Redshift
45+
cluster.
46+
--redshift-ca-bundle=<path/to/redshift-ssl-ca-cert.pem>
47+
Path to Redshift Certificate Authority bundle
48+
in PEM format (see
49+
https://docs.aws.amazon.com/redshift/latest/mgmt/connecting-ssl-support.html).
50+
--redshift-user=<user> Username for the radshift superuser on the
51+
backend Redshift cluster (default
52+
$REDSHIFT_USER).
53+
--redshift-password=<password>
54+
Password for the radshift superuser on the
55+
backend Redshift cluster (default:
56+
$REDSHIFT_PASSWORD).
57+
--user=<username> ... Allow <username> to connect (after
58+
authenticating to LinOTP).
59+
--superuser=<username> ...
60+
Treat <username> as a superuser on the backend.
61+
--linotp=<https://linotp/auth>
62+
URL of LinOTP endpoint for verifying user OTPs
63+
--linotp-realm="radshift" LinOTP realm for verifying user OTPs
64+
--linotp-ca-bundle=<path/to/ca_bundle.pem>
65+
Path to CA bundle for LinOTP in PEM format
66+
(default: $SSL_CA_BUNDLE_PATH).
67+
--version Show application version.
68+
```

diagram.png

70.3 KB
Loading

diagram.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# sequence diagram built on https://www.websequencediagrams.com/
2+
participant Client
3+
participant Radshift
4+
participant Redshift
5+
participant LinOTP
6+
7+
Client->+Radshift: connect
8+
Radshift-->Client: prompt for username/OTP
9+
Client->Radshift: username/OTP
10+
Radshift->+LinOTP: check OTP using LinOTP
11+
LinOTP-->-Radshift: return success
12+
Radshift-->Client: return success
13+
Radshift->+Redshift: authenticate as superuser
14+
Radshift->Redshift: create/update "[...]_radshift" user
15+
Radshift->Redshift: set "[...]_radshift" password to random token
16+
Redshift-->-Radshift: return success
17+
18+
Radshift->+Redshift: connect
19+
Redshift-->Radshift: prompt for username/password
20+
Radshift->Redshift: "[...]_radshift"/random token
21+
Redshift-->Radshift: return success
22+
23+
Client->Radshift: query
24+
Radshift->Redshift: query (proxied)
25+
Redshift-->Radshift: result (proxied)
26+
Radshift-->Client: result

0 commit comments

Comments
 (0)