Skip to content

Commit dfd4e5d

Browse files
authored
Merge pull request #9 from Identicum/feature/child-dir-demoapp-confs
Support for handling demoapp .conf files multi-directory-level
2 parents cf799b6 + e7142a9 commit dfd4e5d

11 files changed

Lines changed: 70 additions & 23 deletions

File tree

conf/nginx.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ http {
5252

5353
lua_package_path '/var/ipax/lua/?.lua;;';
5454

55-
include /var/ipax/conf/lua_shared_dict/*.conf;
55+
include /var/ipax/conf/lua_shared_dict/**/*.conf;
5656

5757
# bigger (chunked) cookie size to accomodate 'member_of' Claim
5858
large_client_header_buffers 8 32k;

conf/server/demoapps.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
server {
22
include /var/ipax/conf/default_vhost.conf;
33

4-
include /var/ipax/conf/location_conf.d/*.conf;
4+
include /var/ipax/conf/location_conf.d/**/*.conf;
55
}

entrypoint.sh

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
#!/bin/bash
22

33
get_demoapps_list() {
4-
local demoapps_list=""
5-
for demoapp_conf_file in ${DEMOAPPS_VARIABLES_CONFIG_PATH}/*.conf; do
6-
demoapp_name=$(basename "$demoapp_conf_file" .conf)
7-
demoapps_list+="$demoapp_name "
8-
done
9-
# Trim trailing space and print
10-
echo "${demoapps_list%% }"
4+
find "${DEMOAPPS_VARIABLES_CONFIG_PATH}" -name "*.conf" -type f
115
}
126

137
delete_lua_shared_dict() {
14-
echo "Deleting existing ${LUA_SHARED_DICT_PATH}/*.conf"
15-
rm -f ${LUA_SHARED_DICT_PATH}/*.conf
8+
echo "Deleting existing ${LUA_SHARED_DICT_PATH}/**/*.conf"
9+
find "${LUA_SHARED_DICT_PATH}" -name "*.conf" -type f -delete
1610
}
1711

1812
create_lua_shared_dict_file() {
1913
local demoapp_name="$1"
20-
local lua_shared_dict_path="${LUA_SHARED_DICT_PATH}/${demoapp_name}.conf"
14+
local demoapp_conf_file="$2"
15+
local relative_path="${demoapp_conf_file#${DEMOAPPS_VARIABLES_CONFIG_PATH}/}"
16+
local subdir
17+
subdir=$(dirname "$relative_path")
18+
local lua_shared_dict_path
19+
if [ "$subdir" = "." ]; then
20+
lua_shared_dict_path="${LUA_SHARED_DICT_PATH}/${demoapp_name}.conf"
21+
else
22+
lua_shared_dict_path="${LUA_SHARED_DICT_PATH}/${subdir}/${demoapp_name}.conf"
23+
fi
24+
2125
echo "Creating ${lua_shared_dict_path}"
26+
mkdir -p "$(dirname "$lua_shared_dict_path")"
2227
echo "lua_shared_dict ${demoapp_name}_jwks 1m;" > ${lua_shared_dict_path}
2328
echo "lua_shared_dict ${demoapp_name}_discovery 1m;" >> ${lua_shared_dict_path}
2429
echo "lua_shared_dict ${demoapp_name}_oidc_state 1m;" >> ${lua_shared_dict_path}
@@ -28,16 +33,25 @@ create_lua_shared_dict_file() {
2833
}
2934

3035
delete_multi_configs() {
31-
echo "Deleting existing ${DEMOAPPS_CONFIG_PATH}/*.conf"
32-
rm -f ${DEMOAPPS_CONFIG_PATH}/*.conf
36+
echo "Deleting existing ${DEMOAPPS_CONFIG_PATH}/**/*.conf"
37+
find "${DEMOAPPS_CONFIG_PATH}" -name "*.conf" -type f -delete
3338
}
3439

3540
create_multi_config_file() {
3641
local demoapp_name="$1"
37-
local demoapps_config_path="${DEMOAPPS_CONFIG_PATH}/${demoapp_name}.conf"
42+
local demoapp_conf_file="$2"
43+
local relative_path="${demoapp_conf_file#${DEMOAPPS_VARIABLES_CONFIG_PATH}/}"
44+
local subdir=$(dirname "$relative_path")
45+
local demoapps_config_path
46+
if [ "$subdir" = "." ]; then
47+
demoapps_config_path="${DEMOAPPS_CONFIG_PATH}/${demoapp_name}.conf"
48+
else
49+
demoapps_config_path="${DEMOAPPS_CONFIG_PATH}/${subdir}/${demoapp_name}.conf"
50+
fi
3851
echo "Creating ${demoapps_config_path}"
52+
mkdir -p "$(dirname "$demoapps_config_path")"
3953
cat /var/ipax/conf/demoapp_template.conf > ${demoapps_config_path}
40-
sed -i "s#include /var/ipax/conf/default_variables.conf;#include /var/ipax/conf/default_variables.conf;\n include ${DEMOAPPS_VARIABLES_CONFIG_PATH}/${demoapp_name}.conf;#g" ${demoapps_config_path}
54+
sed -i "s#include /var/ipax/conf/default_variables.conf;#include /var/ipax/conf/default_variables.conf;\n include ${demoapp_conf_file};#g" "${demoapps_config_path}"
4155
sed -i "s#location /#location /${demoapp_name}/#g" ${demoapps_config_path}
4256
sed -i "s#root /var/ipax/html/#alias /var/ipax/html/#g" ${demoapps_config_path}
4357
}
@@ -64,12 +78,12 @@ if [ "$IPAX_MODE" = "demoapps" ]; then
6478
cp /var/ipax/conf/server/demoapps.conf /usr/local/openresty/nginx/conf/server.conf
6579
delete_lua_shared_dict
6680
delete_multi_configs
67-
demoapps_list=$(get_demoapps_list)
68-
for demoapp_name in $demoapps_list; do
69-
echo "Processing demoapp: '${demoapp_name}'"
70-
create_lua_shared_dict_file "${demoapp_name}"
71-
create_multi_config_file "${demoapp_name}"
72-
done
81+
while IFS= read -r demoapp_conf_file; do
82+
demoapp_name=$(basename "$demoapp_conf_file" .conf)
83+
echo "Processing demoapp: '${demoapp_conf_file}'"
84+
create_lua_shared_dict_file "${demoapp_name}" "${demoapp_conf_file}"
85+
create_multi_config_file "${demoapp_name}" "${demoapp_conf_file}"
86+
done < <(get_demoapps_list)
7387
echo "Finished processing demoapps"
7488
fi
7589

localhost/demoapps/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: ipax-demoapps
33
services:
44
idp:
55
container_name: idp
6-
image: ghcr.io/identicum/keycloak:26.3
6+
image: ghcr.io/identicum/keycloak:26.1.0
77
restart: always
88
pull_policy: always
99
ports:
File renamed without changes.
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set $ipax_app_name 'demoapp4';
2+
set $ipax_display_name 'DemoApp4';
3+
set $ipax_base_url 'http://demoapps/demoapp4';
4+
5+
set $oidc_discovery 'http://idp:8080/realms/demorealm/.well-known/openid-configuration';
6+
set $oidc_client_id 'demoapp4_client_id';
7+
set $oidc_use_pkce 'true';
8+
set $oidc_scope 'openid profile email';
9+
set $oidc_prompt 'none';
10+
11+
set $kc_delete_account_action 'delete_account';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set $ipax_app_name 'demoapp1';
2+
set $ipax_display_name 'DemoApp1';
3+
set $ipax_base_url 'http://demoapps/demoapp1';
4+
5+
set $oidc_discovery 'http://idp:8080/realms/demorealm/.well-known/openid-configuration';
6+
set $oidc_client_id 'demoapp1_client_id';
7+
set $oidc_client_secret 'demoapp1_client_secret';
8+
9+
set $kc_update_password_action 'UPDATE_PASSWORD';
10+
set $kc_update_email_action 'UPDATE_EMAIL';
11+
12+
set $kc_add_passkey_action 'webauthn-register-passwordless';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set $ipax_app_name 'demoapp2';
2+
set $ipax_display_name 'DemoApp2';
3+
set $ipax_base_url 'http://demoapps/demoapp2';
4+
5+
set $oidc_discovery 'http://idp:8080/realms/demorealm/.well-known/openid-configuration';
6+
set $oidc_client_id 'demoapp2_client_id';
7+
set $oidc_use_pkce 'true';
8+
set $oidc_scope 'openid profile email';
9+
10+
set $kc_delete_account_action 'delete_account';
File renamed without changes.

0 commit comments

Comments
 (0)