Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Vad1mo committed Sep 18, 2018
1 parent 7f38fe9 commit 722e9db
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,19 @@
[![Docker Stars](https://img.shields.io/docker/stars/8gears/keycloak-auth-proxy.svg?style=flat-square)](https://hub.docker.com/r/8gears/keycloak-auth-proxy/)
[![MicroBadger Size](https://img.shields.io/microbadger/image-size/8gears/keycloak-auth-proxy.svg?style=flat-square)](https://hub.docker.com/r/8gears/keycloak-auth-proxy/)



The Reverse Auth Proxy in a Docker Container the provides OpenID Connect/OAuth authentication and authorization for HTTP services that that can't or won't do it themself.

This Auth Proxy Service uses [Keycloak Proxy][kcp], which is a Java/Undertow solution designed for Keycloak. However it should also work with any other OpenID Connect Provider.

What makes this project special is, that it can be configured with environment variables and can be easily deployed to Docker, Kubernetes or OpenShift.
This Auth Proxy Service uses [gambol99/keycloak-proxy](https://github.com/gambol99/keycloak-proxy), which is a Java/Undertow solution designed for Keycloak. However it should also work with any other OpenID Connect Provider.

## Note

We are migrating the Java Proxy Version (that comes with Keycloak) to [gambol99/keycloak-proxy](https://github.com/gambol99/keycloak-proxy). You can switch to the branch [goproxy](/tree/goproxy).
The new Go Proxy implementation is more general purpose, needs less resources and has some usefull options that are missing in the Keycloak version. (Let's Encrypt Support, Login/Logout and Forward Signing Proxy). A Working version is availible on Docker Hub as `docker pull 8gears/keycloak-auth-proxy:goproxy`
What makes this project special is, that it can be configured with environment variables and can be easily deployed to Docker, Kubernetes or OpenShift.

## Mode of operation

![How reverse auth proxy works][prx_diag]

1. External traffic is directed to the auth proxy. The Auth proxy decides based on it configuration if the destination needs authentication.
2. The Auth Proxy work together with the IAM (Keycloak) and redirects the user to the IAM so the user can login.
3. After a successful login the proxy forwards the user to the protected content. According to proxy configuration setting the proxy checks if the user is allowed to access the path.
3. After a successful login the proxy forwards the user to the protected content. According to proxy configuration setting the proxy checks if the user is allowed to access the path.

## Typical Use cases

Expand All @@ -34,12 +27,12 @@ It is recommended that every service that needs authentication has a dedicated a

- Protect static websites from unauthorized access, allowing only authenticated users to see the content.
This is useful in combination with static website generator or other generated documentation.
- Outsource the authentication/authorization step to Keycloak Auth Proxy and just relay on the forward HTTP headers with username/grants in the upstream application.
This approach can be handy if you have an application, where there are no OpenID Connect library or if you don't won't perform to many changes in the application.
- Outsource the authentication/authorization step to Keycloak Auth Proxy and just relay on the forward HTTP headers with username/grants in the upstream application.
This approach can be handy if you have an application, where there are no OpenID Connect library or if you don't won't perform to many changes in the application.

## Usage

There are three ways how the proxy can be configured.
There are three ways how the proxy can be configured.
The proxy configuration settings can be set with environment variables,environment variables plus config template or with the file `proxy.json` mounted as a volume to `/app/proxy.json`.

The option that you choose depend on the use case. For simple static website auth the default proxy template is sufficient. For more complex scenarios the custom Proxy Config Template is able cover all possible options.
Expand All @@ -48,7 +41,7 @@ The option that you choose depend on the use case. For simple static website aut

In the simplest case the only thing you need to do is to set the mandatory environment variables. Prior the execution the variables merged with the default proxy config and then the proxy application is started.

```
```sh
docker run -ti \
-e TARGET_URL=asdf \
-e REALM="realm" \
Expand All @@ -57,13 +50,15 @@ docker run -ti \
8gears/keycloak-auth-proxy
```

With Docker Compose download the default docker-compose.yml
```
wget https://raw.githubusercontent.com/8gears/keycloak-auth-proxy/master/docker-compose.yml
With Docker Compose download the default docker-compose.yml

```sh
wget https://raw.githubusercontent.com/8gears/keycloak-auth-proxy/master/docker-compose.yml
```

Adapt the mandatory env variables in `docker-compose.yml` and hit:
```

```sh
docker-compose - up
```

Expand All @@ -74,7 +69,7 @@ In order to combine the simplicity of the environment variables with the flexibi
Take the existing `proxy.tmpl` from this repository and extended it to your need.
When you are done with the template minfy the content and set the variable ??`PROXY_TMPL` with the content.

```
```sh
docker run -ti \
-e PROXY_TMPL={"target-url": "http:https://172.17.0.2:2015","bind-address": "0.0.0.0", ....
-e TARGET_URL=asdf \
Expand All @@ -84,17 +79,18 @@ docker run -ti \
8gears/keycloak-auth-proxy
```

### Running with custom Proxy Config
### Running with custom Proxy Config

Write your `proxy.json` file and mount it to `/app/proxy.json`. Prior start the Auth proxy startup script will check if the file exist and start the proxy with the provided file ignoring the template or any provided environment variables.

Instead of mapping you can provide the content via environment variable ?`PROXY_JSON` just like in the template example above.

```
docker run -v proxy.json:/app/proxy.json 8gears/keycloak-auth-proxy
```sh
docker run -v proxy.json:/app/proxy.json 8gears/keycloak-auth-proxy
```

## Environment Variables

Can be used if you want to auth one service.

See the file [proxy.tmpl](proxy.tmpl)
Expand All @@ -106,7 +102,7 @@ Variables without default values are mandatory.
- `BASE_PATH` (default `/` )
- `REALM` Adapter config realm
- `REALM_PUBLIC_KEY` Realm public key
- `AUTH_SERVER_URL` The auth server URL
- `AUTH_SERVER_URL` The auth server URL
- `RESOURCE` (default `account`) The resource to request aka client id
- `SECRET` Credential secret
- `CONSTRAINT_PATH` (default `/*`) You can define multiple path but they must be separated with an `;`
Expand All @@ -116,45 +112,42 @@ Variables without default values are mandatory.

In OpenShift you can create the service from the template `openshift_template.yml` by using the Web UI or CLI.

Copy the content of `openshift_template.yml` and paste it to the *Import YAML / JSON* tab in the service catalog.
Copy the content of `openshift_template.yml` and paste it to the _Import YAML / JSON_ tab in the service catalog.
The OpenShift has a [detailed tutorial]([create_from_ui]) that covers the manual template instantiation.

From the CLI execute the first command with the `--parameter` argument to get a list of all the possible parameters.
Next in the second command add all the needed parameters and pipe it to create.

```
```sh
oc process --parameter -f https://raw.githubusercontent.com/8gears/keycloak-auth-proxy/master/openshift_template.yml

oc process -f https://raw.githubusercontent.com/8gears/keycloak-auth-proxy/master/openshift_template.yml \
-p TARGET_URL=http:https://service-name:123 \
-p REALM=app42 \
| oc create -f -
```

### OpenShift Service Catalog import

Import the template to the current namespace service catalog.

```
```sh
oc create -f https://raw.githubusercontent.com/8gears/keycloak-auth-proxy/master/openshift_template.yml
```

Import template to global service catalog, so all users in all namespaces can use that template.

```
```sh
oc create -f https://raw.githubusercontent.com/8gears/keycloak-auth-proxy/master/openshift_template.yml -n openshift
```


## Alternatives

Despite the uniqueness of _keycloak-auth-proxy_ there are other project that solve the similar problem differently.



- [OpenID / Keycloak Proxy service](https://github.com/gambol99/keycloak-proxy) This in Golang written proxy should work nicely with Keycloak and might be a value alternative to the current jvm proxy.
- [OAuth2 Proxy](https://github.com/bitly/oauth2_proxy)
- [Lua Resty OpenID/Connect](https://github.com/pingidentity/lua-resty-openidc) This library is designed for Nginx/OpenResty.
- [Lua Resty OpenID/Connect](https://github.com/pingidentity/lua-resty-openidc) This library is designed for Nginx/OpenResty.

<!-- Links -->

Expand Down

0 comments on commit 722e9db

Please sign in to comment.