Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit 3f1e90e

Browse files
committed
Merge branch 'dev' of https://github.com/PhysiciansDataCollaborative/auth into refactor/interface
2 parents 817bf0a + 377742f commit 3f1e90e

File tree

4 files changed

+123
-19
lines changed

4 files changed

+123
-19
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN ( \
2424
echo "set -e -o nounset"; \
2525
echo ""; \
2626
echo ""; \
27-
echo "# If jurisdiction folder doesn't exist, then initialize DACS"; \
27+
echo "# Prepare DACS"; \
2828
echo "#"; \
2929
echo "if [ ! -d \${DACS_STOREDIR}/federations/\${DACS_FEDERATION}/\${DACS_JURISDICTION}/ ]"; \
3030
echo "then"; \
@@ -34,24 +34,24 @@ RUN ( \
3434
echo " cp /app/federations/site.conf \${DACS_STOREDIR}/federations/"; \
3535
echo " touch \${DACS_STOREDIR}/federations/\${DACS_FEDERATION}/roles"; \
3636
echo " touch \${DACS_STOREDIR}/federations/\${DACS_FEDERATION}/federation_keyfile"; \
37-
echo " dacskey -uj \${DACS_JURISDICTION} -v \${DACS_STOREDIR}/federations/\${DACS_FEDERATION}/federation_keyfile"; \
3837
echo " )||("; \
3938
echo " ERROR: DACS initialization unsuccessful >&2"; \
4039
echo " )"; \
4140
echo "fi"; \
4241
echo "chown -R app:app \${DACS_STOREDIR}/"; \
42+
echo "/sbin/setuser app dacskey -uj \${DACS_JURISDICTION} -v \${DACS_STOREDIR}/federations/\${DACS_FEDERATION}/federation_keyfile"; \
4343
echo ""; \
4444
echo ""; \
4545
echo "# Start service"; \
4646
echo "#"; \
47-
echo "export BRANCH=\${BRANCH_AUTH}"; \
4847
echo "export CONTROLPORT=\${PORT_AUTH_C}"; \
4948
echo "export MAINPORT=\${PORT_AUTH_M}"; \
49+
echo "export DACS=\${DACS_STOREDIR}"; \
5050
echo "export FEDERATION=\${DACS_FEDERATION}"; \
5151
echo "export JURISDICTION=\${DACS_JURISDICTION}"; \
5252
echo "export ROLEFILE=\${DACS_ROLEFILE}"; \
53+
echo "export KEYFILE=\${DACS_KEYFILE}"; \
5354
echo "export SECRET=\${NODE_SECRET}"; \
54-
echo "export DACS=\${DACS_STOREDIR}"; \
5555
echo "#"; \
5656
echo "cd /app/"; \
5757
echo "/sbin/setuser app npm start"; \

auth.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

dacs_add.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
#
3+
# Exit on errors or unitialized variables
4+
#
5+
set -o nounset
6+
7+
8+
# Expected input
9+
#
10+
# $0 this script
11+
# $1 Endpoint number
12+
# $2 Clinician number
13+
# $3 Visualizer login name [optional]
14+
# $4 Jurisdiction [optional]
15+
# $5 Password [optional]
16+
17+
18+
# Check parameters
19+
#
20+
if([ $# -lt 3 ] || [ $# -gt 6 ])
21+
then
22+
echo ""
23+
echo "Unexpected number of parameters."
24+
echo ""
25+
echo "Usage: dacs_add.sh [userName] [userRole] [doctorID] [clinicID] [optional:jurisdiction] [optional:password]"
26+
echo ""
27+
exit
28+
fi
29+
30+
31+
# Set variables from parameters, prompt when password not provided
32+
#
33+
export U_NAME=${1}
34+
export U_ROLE=${2}
35+
export DOCTOR=${3}
36+
export CLINIC=${4}
37+
export JURISDICTION=${5:-TEST}
38+
#
39+
if [ $# -eq 5 ]
40+
then
41+
echo "Please provide a password for user "${U_NAME}":"
42+
read -s PASSWORD
43+
echo ""
44+
else
45+
PASSWORD=${6}
46+
fi
47+
48+
49+
# Add user to DACS
50+
#
51+
if( dacspasswd -uj ${JURISDICTION} -l | grep ${U_NAME})
52+
then
53+
echo "Existing DACS user replaced"
54+
/usr/bin/dacspasswd -uj ${JURISDICTION} -d ${U_NAME}
55+
fi
56+
/usr/bin/dacspasswd -uj ${JURISDICTION} -p ${PASSWORD} -a ${U_NAME}
57+
58+
59+
# Add user to DACS_ROLEFILE, notify if overwriting
60+
#
61+
if ( cat ${DACS_ROLEFILE} | grep -io ^${U_NAME}: )
62+
then
63+
echo "Existing user role replaced"
64+
sed -i /${U_NAME}:/d ${DACS_ROLEFILE}
65+
fi
66+
echo ${U_NAME}:admin | tee -a ${DACS_ROLEFILE}
67+
68+
69+
# Set private data
70+
#
71+
( dacspasswd -uj ${JURISDICTION} -pds '{ "clinician" : "'${DOCTOR}'", "clinic" : "'${CLINIC}'" }' ${U_NAME} )|| \
72+
echo "ERROR: Failed to add private data."

dacs_remove.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
#
3+
# Exit on errors or unitialized variables
4+
#
5+
set -e -o nounset
6+
7+
8+
# Expected input
9+
#
10+
# $0 this script
11+
# $1 Endpoint number
12+
# $2 Jurisdiction [optional]
13+
14+
15+
# Check parameters
16+
#
17+
if([ $# -eq 0 ]||[ $# -gt 2 ])
18+
then
19+
echo ""
20+
echo "Unexpected number of parameters."
21+
echo ""
22+
echo "Usage: dacs_remove.sh [userName] [optional:jurisdiction]"
23+
echo ""
24+
exit
25+
fi
26+
27+
28+
# Set variables from parameters
29+
#
30+
export U_NAME=${1}
31+
export JURISDICTION=${2:-$DACS_JURISDICTION}
32+
33+
34+
# Remove user from DACS
35+
#
36+
( /usr/bin/dacspasswd -uj ${JURISDICTION} -d ${U_NAME} )|| \
37+
echo "ERROR: Failed on Auth remove."
38+
39+
40+
# Remove user from DACS_ROLEFILE
41+
#
42+
if ( cat ${DACS_ROLEFILE} | grep -io ^${U_NAME}: )
43+
then
44+
sed -i /${U_NAME}:/d ${DACS_ROLEFILE}
45+
else
46+
echo "ERROR: Not found in ROLEFILE"
47+
fi

0 commit comments

Comments
 (0)