Skip to content

Commit 8aa03d0

Browse files
DEV-527: Make all CAS variables configurable via the environment with default values set by init script (#3)
1 parent 316f961 commit 8aa03d0

File tree

5 files changed

+56
-20
lines changed

5 files changed

+56
-20
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ RUN yum -y update && \
1111

1212
USER root
1313
COPY files/etc/httpd /etc/httpd
14+
COPY files/pre-init /usr/share/container-scripts/httpd/pre-init
1415
COPY files/var/www /var/www

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
# Apache w/mod-auth-cas docker image
22

3-
A simple Debian-based Apache 2.4 image with mod-auth-cas installed. Customize the CAS configuration by setting environment variables:
3+
A Red Hat 8 Universal Base Image running Apache with a few helpful extras:
44

5-
- `CAS_LOGIN_URL`
6-
- `CAS_VALIDATE_URL`
7-
- `CAS_PROXY_VALIDATE_URL`
8-
- `CAS_ROOT_PROXIED_AS`
5+
1. mod_auth_cas, configurable at runtime by setting environment variables.
6+
2. A RemoteIP configuration suitable for running behind NGINX, Traefik, etc.
7+
3. Our branded auto-index pages.
98

10-
The environment variables are named after the corresponding CAS configuration directives. See the [mod-auth-cas documentation](https://github.com/apereo/mod_auth_cas).
9+
Listens on 8080/tcp.
10+
11+
## CAS Configuration
12+
13+
The CAS configuration works for localhost and auth.berkeley.edu out-of-the-box. You can override any of the options defined in [files/etc/httpd/conf.d/auth_cas.conf](files/etc/httpd/conf.d/auth_cas.conf) by setting environment variables of the form `CAS_OPTION_NAME`.
14+
15+
**Example 1:** Using auth-test instead of auth.
16+
17+
```
18+
CAS_DOMAIN=auth-test.berkeley.edu
19+
```
20+
21+
**Example 2:** Setting a production return URL.
22+
23+
```
24+
CAS_ROOT_PROXIED_AS=https://mysite.lib.berkeley.edu
25+
```
26+
27+
The environment variables are named after the corresponding CAS configuration directives. See the [mod-auth-cas documentation](https://github.com/apereo/mod_auth_cas). The only exception is `CAS_DOMAIN`, which is a helper variable for setting all of the other CAS URLs to a specific domain.
28+
29+
## Trusted Proxies
30+
31+
See [files/etc/httpd/conf.d/trusted_proxies.conf](files/etc/httpd/conf.d/trusted_proxies.conf) for the list of trusted proxies. This must be updated if/when a new ingress point is added.
32+
33+
## Branded Index Pages
34+
35+
This image bakes in custom branding and styling for Apache-generated index pages. See [files/var/www/autoindex](files/var/www/autoindex) for details.

docker-compose.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
services:
44
app:
55
build: .
6-
environment:
7-
- CAS_LOGIN_URL=https://auth.berkeley.edu/cas/
8-
- CAS_VALIDATE_URL=https://auth.berkeley.edu/cas/serviceValidate
9-
- CAS_PROXY_VALIDATE_URL=https://auth.berkeley.edu/cas/proxyValidate
10-
- CAS_ROOT_PROXIED_AS=http://localhost
116
ports:
127
- 80:8080
138
volumes:
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<IfModule auth_cas_module>
2-
CASVersion 2
3-
CASDebug Off
2+
CASVersion ${CAS_VERSION}
3+
CASDebug ${CAS_DEBUG}
44
CASLoginURL ${CAS_LOGIN_URL}
55
CASValidateURL ${CAS_VALIDATE_URL}
66
CASProxyValidateURL ${CAS_PROXY_VALIDATE_URL}
7-
CASTimeout 7200
8-
CASIdleTimeout 3600
9-
CASCacheCleanInterval 1800
10-
CASCookiePath /var/cache/httpd/mod_auth_cas/
11-
CASCookieEntropy 32
12-
13-
# You must set CAS_ROOT_PROXIED_AS in the environment
7+
CASTimeout ${CAS_TIMEOUT}
8+
CASIdleTimeout ${CAS_IDLE_TIMEOUT}
9+
CASCacheCleanInterval ${CAS_CACHE_CLEAN_INTERVAL}
10+
CASCookieEntropy ${CAS_COOKIE_ENTROPY}
1411
CASRootProxiedAs ${CAS_ROOT_PROXIED_AS}
12+
CASCookiePath ${CAS_COOKIE_PATH}
1513
</IfModule>

files/pre-init/50-cas-variables.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# For option definitions:
2+
# @see https://github.com/apereo/mod_auth_cas
3+
4+
# Special helper variable that allows setting all the CAS URLs at once.
5+
export CAS_DOMAIN=${CAS_DOMAIN:-auth.berkeley.edu}
6+
7+
export CAS_CACHE_CLEAN_INTERVAL="${CAS_CACHE_CLEAN_INTERVAL:-1800}"
8+
export CAS_COOKIE_ENTROPY="${CAS_COOKIE_ENTROPY:-32}"
9+
export CAS_COOKIE_PATH="${CAS_COOKIE_PATH:-/var/cache/httpd/mod_auth_cas/}"
10+
export CAS_DEBUG="${CAS_DEBUG:-off}"
11+
export CAS_IDLE_TIMEOUT="${CAS_IDLE_TIMEOUT:-3600}"
12+
export CAS_LOGIN_URL="${CAS_LOGIN_URL:-https://$CAS_DOMAIN/cas/}"
13+
export CAS_PROXY_VALIDATE_URL="${CAS_PROXY_VALIDATE_URL:-https://$CAS_DOMAIN/cas/proxyValidate}"
14+
export CAS_ROOT_PROXIED_AS="${CAS_ROOT_PROXIED_AS:-http://localhost}"
15+
export CAS_TIMEOUT="${CAS_TIMEOUT:-7200}"
16+
export CAS_VALIDATE_URL="${CAS_VALIDATE_URL:-https://$CAS_DOMAIN/cas/serviceValidate}"
17+
export CAS_VERSION="${CAS_VERSION:-2}"

0 commit comments

Comments
 (0)