Skip to content

Commit d06b57c

Browse files
Fix issue and add proxies for multi-oauth scenarios
1 parent 73006ab commit d06b57c

File tree

13 files changed

+401
-4
lines changed

13 files changed

+401
-4
lines changed

deps/oauth2_client/src/oauth2_client.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ ensure_http_client_started(Id) ->
7070
http_post(Id, URL, Header, Type, Body, HTTPOptions, ProxyOptions) ->
7171
http_request(Id, post, {URL, Header, Type, Body}, HTTPOptions, ProxyOptions).
7272
http_get(Id, URL, HTTPOptions, ProxyOptions) ->
73-
ct:log("~p ~p", [Id, URL]),
7473
http_request(Id, get, {URL, []}, HTTPOptions, ProxyOptions).
7574
http_request(Id, Method, Payload, HTTPOptions, ProxyOptions) ->
7675
case ensure_http_client_started(Id) of

deps/oauth2_client/test/system_SUITE.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ get_openid_configuration_http_expectation(TestCaseAtom) ->
184184
nomatch -> ?DEFAULT_OPENID_CONFIGURATION_PATH;
185185
_ -> ?CUSTOM_OPENID_CONFIGURATION_ENDPOINT
186186
end,
187-
ct:log("Expect path: ~p and endpoint: ~p", [Path, Endpoint]),
188187
build_http_mock_behaviour(build_http_get_openid_configuration_request(Endpoint, Path),
189188
build_http_200_json_response(Payload)).
190189

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
HTTPD_DOCKER_IMAGE=httpd:latest
3+
4+
ensure_devkeycloak-proxy() {
5+
if docker ps | grep devkeycloak-proxy &> /dev/null; then
6+
print "devkeycloak-proxy already running ..."
7+
else
8+
start_devkeycloak-proxy
9+
fi
10+
}
11+
init_devkeycloak-proxy() {
12+
HTTPD_CONFIG_DIR=${TEST_CONFIG_DIR}/devkeycloak-proxy
13+
PROXY_HOSTNAME=devkeycloak-proxy
14+
PROXY_PORT=9092
15+
16+
print "> HTTPD_CONFIG: ${HTTPD_CONFIG_DIR}"
17+
print "> PROXY_HOSTNAME: ${PROXY_HOSTNAME}"
18+
print "> PROXY_PORT: ${PROXY_PORT}"
19+
20+
}
21+
22+
start_devkeycloak-proxy() {
23+
begin "Starting devkeycloak-proxy ..."
24+
25+
init_devkeycloak-proxy
26+
kill_container_if_exist devkeycloak-proxy
27+
28+
MOUNT_HTTPD_CONFIG_DIR=$CONF_DIR/httpd
29+
30+
mkdir -p $MOUNT_HTTPD_CONFIG_DIR
31+
${BIN_DIR}/gen-httpd-conf ${HTTPD_CONFIG_DIR} $ENV_FILE $MOUNT_HTTPD_CONFIG_DIR/httpd.conf
32+
print "> EFFECTIVE HTTPD_CONFIG_FILE: $MOUNT_HTTPD_CONFIG_DIR/httpd.conf"
33+
cp ${HTTPD_CONFIG_DIR}/.htpasswd $MOUNT_HTTPD_CONFIG_DIR
34+
35+
docker run \
36+
--detach \
37+
--name devkeycloak-proxy \
38+
--net ${DOCKER_NETWORK} \
39+
--publish 9092:9092 \
40+
--mount "type=bind,source=${MOUNT_HTTPD_CONFIG_DIR},target=/usr/local/apache2/conf" \
41+
${HTTPD_DOCKER_IMAGE}
42+
43+
#wait_for_url $OAUTH_PROVIDER_URL ${FORWARD_PROXY_URL}
44+
end "devkeycloak-proxy is ready"
45+
}

selenium/bin/components/forward-proxy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ init_forward-proxy() {
1414
PROXY_PORT=9092
1515

1616
print "> HTTPD_CONFIG: ${HTTPD_CONFIG_DIR}"
17-
print "> PROXIED_OAUTH_PROVIDER: ${TEST_CONFIG_DIR}/${PROXIED_OAUTH_PROVIDER}"
1817
print "> OAUTH_PROVIDER_URL: ${OAUTH_PROVIDER_URL}"
1918
print "> PROXY_HOSTNAME: ${PROXY_HOSTNAME}"
2019
print "> PROXY_PORT: ${PROXY_PORT}"
2120

22-
# generate-ca-server-client-kpi forward-proxy $HTTPD_CONFIG_DIR
2321
}
2422

2523
start_forward-proxy() {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
HTTPD_DOCKER_IMAGE=httpd:latest
3+
4+
ensure_prodkeycloak-proxy() {
5+
if docker ps | grep prodkeycloak-proxy &> /dev/null; then
6+
print "prodkeycloak-proxy already running ..."
7+
else
8+
start_prodkeycloak-proxy
9+
fi
10+
}
11+
init_prodkeycloak-proxy() {
12+
HTTPD_CONFIG_DIR=${TEST_CONFIG_DIR}/prodkeycloak-proxy
13+
PROXY_HOSTNAME=prodkeycloak-proxy
14+
PROXY_PORT=9091
15+
16+
print "> HTTPD_CONFIG: ${HTTPD_CONFIG_DIR}"
17+
print "> PROXY_HOSTNAME: ${PROXY_HOSTNAME}"
18+
print "> PROXY_PORT: ${PROXY_PORT}"
19+
20+
}
21+
22+
start_prodkeycloak-proxy() {
23+
begin "Starting prodkeycloak-proxy ..."
24+
25+
init_prodkeycloak-proxy
26+
kill_container_if_exist prodkeycloak-proxy
27+
28+
MOUNT_HTTPD_CONFIG_DIR=$CONF_DIR/httpd
29+
30+
mkdir -p $MOUNT_HTTPD_CONFIG_DIR
31+
${BIN_DIR}/gen-httpd-conf ${HTTPD_CONFIG_DIR} $ENV_FILE $MOUNT_HTTPD_CONFIG_DIR/httpd.conf
32+
print "> EFFECTIVE HTTPD_CONFIG_FILE: $MOUNT_HTTPD_CONFIG_DIR/httpd.conf"
33+
cp ${HTTPD_CONFIG_DIR}/.htpasswd $MOUNT_HTTPD_CONFIG_DIR
34+
35+
docker run \
36+
--detach \
37+
--name prodkeycloak-proxy \
38+
--net ${DOCKER_NETWORK} \
39+
--publish 9091:9092 \
40+
--mount "type=bind,source=${MOUNT_HTTPD_CONFIG_DIR},target=/usr/local/apache2/conf" \
41+
${HTTPD_DOCKER_IMAGE}
42+
43+
end "prodkeycloak-proxy is ready"
44+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guest:{SHA}NWdeaPS1r3uZXZIFrQ/EOELxZFA=
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#
2+
# This is the main Apache HTTP server configuration file. It contains the
3+
# configuration directives that give the server its instructions.
4+
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
5+
# In particular, see
6+
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
7+
# for a discussion of each configuration directive.
8+
#
9+
# Do NOT simply read the instructions in here without understanding
10+
# what they do. They're here only as hints or reminders. If you are unsure
11+
# consult the online docs. You have been warned.
12+
#
13+
# Configuration and logfile names: If the filenames you specify for many
14+
# of the server's control files begin with "/" (or "drive:/" for Win32), the
15+
# server will use that explicit path. If the filenames do *not* begin
16+
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
17+
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
18+
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
19+
# will be interpreted as '/logs/access_log'.
20+
21+
#
22+
# ServerRoot: The top of the directory tree under which the server's
23+
# configuration, error, and log files are kept.
24+
#
25+
# Do not add a slash at the end of the directory path. If you point
26+
# ServerRoot at a non-local disk, be sure to specify a local disk on the
27+
# Mutex directive, if file-based mutexes are used. If you wish to share the
28+
# same ServerRoot for multiple httpd daemons, you will need to change at
29+
# least PidFile.
30+
#
31+
ServerRoot "/usr/local/apache2"
32+
33+
#
34+
# Mutex: Allows you to set the mutex mechanism and mutex file directory
35+
# for individual mutexes, or change the global defaults
36+
#
37+
# Uncomment and change the directory if mutexes are file-based and the default
38+
# mutex file directory is not on a local disk or is not appropriate for some
39+
# other reason.
40+
#
41+
# Mutex default:logs
42+
43+
#
44+
# Listen: Allows you to bind Apache to specific IP addresses and/or
45+
# ports, instead of the default. See also the <VirtualHost>
46+
# directive.
47+
#
48+
# Change this to Listen on specific IP addresses as shown below to
49+
# prevent Apache from glomming onto all bound IP addresses.
50+
#
51+
#Listen 12.34.56.78:80
52+
Listen 9092
53+
54+
#
55+
# Dynamic Shared Object (DSO) Support
56+
#
57+
# To be able to use the functionality of a module which was built as a DSO you
58+
# have to place corresponding `LoadModule' lines at this location so the
59+
# directives contained in it are actually available _before_ they are used.
60+
# Statically compiled modules (those listed by `httpd -l') do not need
61+
# to be loaded here.
62+
#
63+
# Example:
64+
# LoadModule foo_module modules/mod_foo.so
65+
#
66+
67+
LoadModule mpm_event_module modules/mod_mpm_event.so
68+
LoadModule access_compat_module modules/mod_access_compat.so
69+
LoadModule log_config_module modules/mod_log_config.so
70+
LoadModule auth_basic_module modules/mod_auth_basic.so
71+
LoadModule authn_core_module modules/mod_authn_core.so
72+
LoadModule authz_core_module modules/mod_authz_core.so
73+
LoadModule authn_file_module modules/mod_authn_file.so
74+
LoadModule authz_user_module modules/mod_authz_user.so
75+
LoadModule proxy_module modules/mod_proxy.so
76+
LoadModule proxy_connect_module modules/mod_proxy_connect.so
77+
LoadModule proxy_http_module modules/mod_proxy_http.so
78+
LoadModule ssl_module modules/mod_ssl.so
79+
LoadModule unixd_module modules/mod_unixd.so
80+
81+
<IfModule unixd_module>
82+
User www-data
83+
Group www-data
84+
</IfModule>
85+
86+
87+
ServerAdmin [email protected]
88+
89+
ServerName devkeycloak-proxy
90+
91+
ErrorLog /proc/self/fd/2
92+
93+
LogLevel warn
94+
95+
<IfModule log_config_module>
96+
#
97+
# The following directives define some format nicknames for use with
98+
# a CustomLog directive (see below).
99+
#
100+
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
101+
LogFormat "%h %l %u %t \"%r\" %>s %b" common
102+
103+
<IfModule logio_module>
104+
# You need to enable mod_logio.c to use %I and %O
105+
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
106+
</IfModule>
107+
108+
#
109+
# The location and format of the access logfile (Common Logfile Format).
110+
# If you do not define any access logfiles within a <VirtualHost>
111+
# container, they will be logged here. Contrariwise, if you *do*
112+
# define per-<VirtualHost> access logfiles, transactions will be
113+
# logged therein and *not* in this file.
114+
#
115+
CustomLog logs/access_log common
116+
117+
#
118+
# If you prefer a logfile with access, agent, and referer information
119+
# (Combined Logfile Format) you can use the following directive.
120+
#
121+
#CustomLog "logs/access_log" combined
122+
</IfModule>
123+
124+
<IfModule proxy_module>
125+
ProxyRequests On
126+
ProxyVia On
127+
<Proxy *>
128+
Allow from all
129+
</Proxy>
130+
</IfModule>
131+
132+
133+
<VirtualHost *:9092>
134+
AllowCONNECT 8443
135+
136+
ProxyRequests On
137+
ProxyVia On
138+
LogLevel debug
139+
ErrorLog /dev/stderr
140+
CustomLog /dev/stdout combined
141+
142+
<Proxy "*">
143+
Allow from all
144+
145+
146+
</Proxy>
147+
</VirtualHost>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export DEVKEYCLOAK_PROXY_HOST=devkeycloak-proxy
2+
export DEVKEYCLOAK_PROXY_PORT=9092
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export PRODKEYCLOAK_PROXY_HOST=prodkeycloak-proxy
2+
export PRODKEYCLOAK_PROXY_PORT=9091
3+
export PRODKEYCLOAK_PROXY_USERNAME=guest
4+
export PRODKEYCLOAK_PROXY_PASSWORD=guest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guest:{SHA}NWdeaPS1r3uZXZIFrQ/EOELxZFA=

0 commit comments

Comments
 (0)