Skip to content

Commit

Permalink
Add database credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
dasscheman committed Jun 24, 2024
1 parent d22373a commit 441f655
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
12 changes: 6 additions & 6 deletions openshift/config/06_sample-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ spec:
ports:
- containerPort: 9000
env:
- name: LARAVEL_DATABASE_TYPE
- name: DB_CONNECTION
valueFrom:
configMapKeyRef:
name: sample-config
key: database-type
- name: LARAVEL_DATABASE_HOST
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: sample-config
key: database-host
- name: LARAVEL_DATABASE_PORT_NUMBER
- name: DB_PORT
valueFrom:
configMapKeyRef:
name: sample-config
key: database-port-number
- name: LARAVEL_DATABASE_NAME
- name: DB_DATABASE
valueFrom:
configMapKeyRef:
name: sample-config
key: database-name
- name: LARAVEL_DATABASE_USER
- name: DB_USERNAME
valueFrom:
configMapKeyRef:
name: mariadb-config
key: mariadb-user
- name: LARAVEL_DATABASE_PASSWORD
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-secret
Expand Down
3 changes: 3 additions & 0 deletions openshift/openshift.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mariadb-sample
DB_PORT=3306
DB_DATABASE=development
DB_USERNAME=development
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand Down
27 changes: 25 additions & 2 deletions openshift/scripts/sample-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,31 @@ create_app() {
search_dir=../config
for entry in "$search_dir"/*
do
echo "$entry"
oc apply -f $entry
filename=$(basename -- "$entry")
if [ -f ../temp/"$filename" ]; then
echo "Use previously made file with credentials"
oc apply -f ../temp/"$filename"
continue
fi

echo "Check for file with credential"
match=$(grep -o \<.*\> "$entry" | wc -l)
if [ "$match" -ne "0" ]; then
echo "Found credentials in file"
# TODO: Create loop and ceck ninimal length of password
word1=$(shuf -n1 /usr/share/dict/american-english | sed "s/'//g")
word2=$(shuf -n1 /usr/share/dict/american-english | sed "s/'//g")
word3=$(shuf -n1 /usr/share/dict/american-english | sed "s/'//g")
word="${word1}-${word2}-${word3}"
echo "used password: $word for $filename"
hash="$(echo -n $word | base64)"
echo $hash
sed "s/<.*>/"$hash"/g" "$entry" > ../temp/"$filename"
oc apply -f ../temp/"$filename"
continue
fi
echo "$entry"
oc apply -f "$entry"
done
}

Expand Down

0 comments on commit 441f655

Please sign in to comment.