Skip to content

Commit fc46b79

Browse files
authored
add environment variables for MAS secrets (#48)
* set the same secret as tchap-docker-integration * add MAS clients variables to be able to use the tchap docker integration tool
1 parent 80e9f40 commit fc46b79

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

tchap/.env.sample

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
#Copy synapse secret from `element-docker-demo/data/mas/config.yaml`
2-
HOMESERVER_SECRET=
1+
#Copy matrix.secret from `element-docker-demo/data/mas/config.yaml`
2+
HOMESERVER_SECRET=
3+
#Copy synapse client id from `element-docker-demo/data/mas/config.yaml`
4+
SYNAPSE_CLIENT_ID=
5+
#Copy synapse client secret from `element-docker-demo/data/mas/config.yaml`
6+
SYNAPSE_CLIENT_SECRET=
7+
#Copy admin client id from `element-docker-demo/data/mas/config.yaml`
8+
ADMIN_CLIENT_ID=
9+
#Copy admin client secret from `element-docker-demo/data/mas/config.yaml`
10+
ADMIN_CLIENT_SECRET=

tchap/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ For building the Docker image, the [`build` github action](../.github/workflows/
3737

3838
If Synapse integration is needed, install the environment from element-docker-demo and run it (see README.md)
3939

40-
Copy synapse secret from `element-docker-demo/data/mas/config.yaml` to .env file : HOMESERVER_SECRET=
40+
Copy matrix.secret from `element-docker-demo/data/mas/config.yaml` to .env file : HOMESERVER_SECRET=
41+
Copy synapse client id from `element-docker-demo/data/mas/config.yaml` to .env file : SYNAPSE_CLIENT_ID=
42+
Copy synapse client secret from `element-docker-demo/data/mas/config.yaml` to .env file : SYNAPSE_CLIENT_SECRET=
43+
Copy admin client id from `element-docker-demo/data/mas/config.yaml` to .env file : ADMIN_CLIENT_ID=
44+
Copy admin client secret from `element-docker-demo/data/mas/config.yaml` to .env file : ADMIN_CLIENT_SECRET=
4145

4246

4347
# Important knowledge

tchap/build_conf.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,40 @@ if [ -n "${HOMESERVER_SECRET+x}" ] && [ -n "$HOMESERVER_SECRET" ]; then
5454
# HOMESERVER_SECRET is defined and not empty
5555
sed -i '' -E "s|secret: 'TO BE COPY'|secret: '$HOMESERVER_SECRET'|" "$yaml_file"
5656
else
57-
sed -i '' -E "s|secret: 'TO BE COPY'|secret: 'WARNING NO HOMESERVER SECRET DEFINED'|" "$yaml_file"
57+
sed -i '' -E "s|secret: 'TO BE COPY'|secret: 'WARNING NO HOMESERVER_SECRET DEFINED'|" "$yaml_file"
5858
echo "WARNING: HOMESERVER_SECRET is not defined or empty. Using warning message instead."
5959
fi
6060

61+
if [ -n "${SYNAPSE_CLIENT_ID+x}" ] && [ -n "$SYNAPSE_CLIENT_ID" ]; then
62+
# SYNAPSE_CLIENT_ID is defined and not empty
63+
sed -i '' -E "s|client_id: 'SYNAPSE_CLIENT_ID'|client_id: '$SYNAPSE_CLIENT_ID'|" "$yaml_file"
64+
else
65+
sed -i '' -E "s|client_id: 'SYNAPSE_CLIENT_ID'|client_id: 'WARNING NO SYNAPSE_CLIENT_ID DEFINED'|" "$yaml_file"
66+
echo "WARNING: SYNAPSE_CLIENT_ID is not defined or empty. Using warning message instead."
67+
fi
68+
69+
if [ -n "${SYNAPSE_CLIENT_SECRET+x}" ] && [ -n "$SYNAPSE_CLIENT_SECRET" ]; then
70+
# SYNAPSE_CLIENT_SECRET is defined and not empty
71+
sed -i '' -E "s|client_secret: 'SYNAPSE_CLIENT_SECRET'|client_secret: '$SYNAPSE_CLIENT_SECRET'|" "$yaml_file"
72+
else
73+
sed -i '' -E "s|client_secret: 'SYNAPSE_CLIENT_SECRET'|client_secret: 'WARNING NO SYNAPSE_CLIENT_SECRET DEFINED'|" "$yaml_file"
74+
echo "WARNING: SYNAPSE_CLIENT_SECRET is not defined or empty. Using warning message instead."
75+
fi
76+
77+
if [ -n "${ADMIN_CLIENT_ID+x}" ] && [ -n "$ADMIN_CLIENT_ID" ]; then
78+
# ADMIN_CLIENT_ID is defined and not empty
79+
sed -i '' -E "s|client_id: 'ADMIN_CLIENT_ID'|client_id: '$ADMIN_CLIENT_ID'|" "$yaml_file"
80+
else
81+
sed -i '' -E "s|client_id: 'ADMIN_CLIENT_ID'|client_id: 'WARNING NO ADMIN_CLIENT_ID DEFINED'|" "$yaml_file"
82+
echo "WARNING: ADMIN_CLIENT_ID is not defined or empty. Using warning message instead."
83+
fi
84+
85+
if [ -n "${ADMIN_CLIENT_SECRET+x}" ] && [ -n "$ADMIN_CLIENT_SECRET" ]; then
86+
# ADMIN_CLIENT_SECRET is defined and not empty
87+
sed -i '' -E "s|client_secret: 'ADMIN_CLIENT_SECRET'|client_secret: '$ADMIN_CLIENT_SECRET'|" "$yaml_file"
88+
else
89+
sed -i '' -E "s|client_secret: 'ADMIN_CLIENT_SECRET'|client_secret: 'WARNING NO ADMIN_CLIENT_SECRET DEFINED'|" "$yaml_file"
90+
echo "WARNING: ADMIN_CLIENT_SECRET is not defined or empty. Using warning message instead."
91+
fi
92+
6193
echo "Configuration build completed successfully!"

tchap/conf/config.template.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,17 @@ matrix:
118118
endpoint: https://matrix.tchapgouv.com/
119119

120120
clients:
121-
- client_id: 0000000000000000000SYNAPSE
121+
- client_id: 'SYNAPSE_CLIENT_ID'
122122
client_auth_method: client_secret_basic
123-
client_secret: '/DjWc4D3yyqgjYN8tum65g'
123+
client_secret: 'SYNAPSE_CLIENT_SECRET'
124124

125125
# for api admin calls
126-
- client_id: 01J44RKQYM4G3TNVANTMTDYTX6
126+
- client_id: 'ADMIN_CLIENT_ID'
127127
client_auth_method: client_secret_basic
128-
client_secret: phoo8ahneir3ohY2eigh4xuu6Oodaewi
128+
client_secret: 'ADMIN_CLIENT_SECRET'
129+
# List of authorized redirect URIs
130+
redirect_uris:
131+
- https://auth.tchapgouv.com/api/doc/oauth2-callback
129132

130133

131134
policy:

0 commit comments

Comments
 (0)