Skip to content
Snippets Groups Projects
Commit 18f12eed authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[*] Updates

parent c9ec70a9
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ SET( CPACK_GENERATOR "DEB")
SET( CPACK_PACKAGE_NAME "${PROJECT_NAME}")
SET( CPACK_PACKAGE_VERSION_MAJOR 2)
SET( CPACK_PACKAGE_VERSION_MINOR 11)
SET( CPACK_PACKAGE_VERSION_PATCH 1)
SET( CPACK_PACKAGE_VERSION_PATCH 2)
SET( CPACK_SYSTEM_TYPE "debian")
SET( CPACK_SYSTEM_VERSION "10.0")
......
Subproject commit 01e68fc7aaa96cb520524d35f7f76c57d4c4d106
Subproject commit 214f324f5faa30ca6b00bfedae1104b09a0c1e30
Subproject commit af3169c7f9ea0539b4845fa8c01951377ec75278
Subproject commit b11de781617e3137875fbdab281f26a796474657
Subproject commit dde4bb6403957dcbd2e0a983b36661ad303f5756
Subproject commit a831b434bc840cebb1cc6cf1a913bf606286c28d
Subproject commit 829418729fac9af5df9e8e757d5e3bf89cffd19f
Subproject commit 038bc87d14b1f65c13baac8648e695b5f84d1618
Subproject commit c28d683b226c8d39cd898609eb15a4049e74cf4e
Subproject commit 05cd2947d6e3547e3e111b53befeff4b043cb16a
Subproject commit db5a7df2164c4e5a09a15464b8446e8ccb0cb97f
Subproject commit e0f74dbc745a65bb040a41e99460b21b14406a1d
Subproject commit 366011679534b5c960ae618bb6aed1112ab0a5e9
Subproject commit 03f7babcb4376b21580b8109f811f5b2511b6cf0
Subproject commit 1dfccbe81c132d06b8d54d76b65c3e25969f444d
Subproject commit 1688d69223b19de929eed4f8dc61332aaec8dd46
Subproject commit 001b68d44aa11bbeb28b473e1ba41364497a6d6a
Subproject commit 51c01481f87f3ffc1fdad3054292bf910d2c5f31
#!/bin/sh
echo "Creating the new user for dapserver authorization"
if [ $# -eq 1 ]; then
domain=$1
else
read -p "Enter domain name: " domain
if [ -z "$domain" ]; then
echo "[CRITICAL] Need domain name to create new record in the database"
exit 1
fi
fi
mongodomain=`mongo dapDb --eval "db.dap_domains.distinct( \"_id\", { domain : \"$domain\" })"`
mongodomain=`echo "$mongodomain" | tail -1 | tr -d "[] "`
if [ -z $mongodomain ]; then
mongo dapDb --eval "db.dap_domains.insert( {domain:\"$domain\" } )"
else
echo "[CRITICAL] Domain name $domain is already present"
fi
#!/bin/sh
mongo dapDb --eval "db.dap_domains.find()"
#!/bin/sh
echo "Creating the new user for dapserver authorization"
read -p "Enter login: " login
if [ -z "$login" ]; then
echo "[CRITICAL] Need username to create new login record in the database"
exit 1
fi
result=$(mongo dapDb --eval "db.dap_users.find( { login : \"${login}\" } )" | wc -l)
if [ $result -eq 2 ]; then
echo "Login not found in DataBase"
exit 2
fi
read -p "Enter new password: " password
if [ -z "$password" ]; then
echo "[CRITICAL] Need secure password to create new login record in the database"
exit 3
fi
salt=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8; echo '')
echo -n "${password}${salt}" | openssl dgst -sha512 -binary > temp.txt
echo -n "${salt}" | openssl dgst -sha512 -binary >> temp.txt
b64=$(cat temp.txt | base64)
b64urlstring=$(echo $b64 | tr "+/" "-_" | tr -d ' =')
b64salt=$(echo -n ${salt} | base64 | tr "+/" "-_" | tr -d ' =')
rm temp.txt
mongo dapDb --eval "db.dap_users.update( { login : \"${login}\"}, { \$set: { passwordHash : \"${b64urlstring}\", salt : \"${b64salt}\" } } )"
#!/bin/sh
echo "Creating the new user for dapserver authorization"
if [ $# -eq 1 ]; then
echo "Need two parametrs ( email and password )"
exit 5
fi
if [ $# -eq 2 ]; then
email=$1
password=$2
is_correct_email=$(echo $email | grep -E "^.+@.+[.].+$")
if [ -z $is_correct_email ]; then
echo Error! Bad email address. Use first parametr email, second - password
exit 4
fi
else
read -p "Enter login: " login
if [ -z "$login" ]; then
echo "[CRITICAL] Need username to create new login record in the database"
exit 1
fi
read -p "Enter password: " password
if [ -z "$password" ]; then
echo "[CRITICAL] Need secure password to create new login record in the database"
exit 2
fi
read -p "Enter email: " email
if [ -n "$email" ]; then
is_correct_email=$(echo $email | grep -E "^.+@.+[.].+$")
if [ -z $is_correct_email ]; then
echo Error! Bad email address.
exit 4
fi
fi
read -p "Enter first_name ( can skip ): " first_name
read -p "Enter last_name ( can skip ): " last_name
fi
domain=klvn.io
mongodomain=`mongo dapDb --eval "db.dap_domains.distinct( \"_id\", { domain : \"$domain\" })" `
mongodomain=`echo "$mongodomain" | tail -1 | tr -d "[] "`
if [ -z $mongodomain ]; then
echo "domain not find in database"
exit 3
fi
password_hash=$(/opt/cellframe-node/bin/dap_server_http_db_auth_tool password_hash ${password})
echo "Password hash $password_hash"
if [ -z "$login" ]; then
login=$email
fi
if [ -z "$email" ]; then
email=$login
fi
registration_date=$(date -u "+%Y-%m-%d %T")
expired_date=$(date -u -d '+ 3 day' '+%Y-%m-%d %T')
mongo dapDb --eval "db.dap_users.insert( { login : \"${login}\", email : \"${email}\", passwordHash : \"${password_hash}\",\
domainId : ${mongodomain}, profile: { first_name : \"${first_name}\",\
last_name : \"${last_name}\" }, registration_date : ISODate(\"${registration_date}\"), expire_date : ISODate(\"${expired_date}\"), contacts: [] } )"
#!/bin/sh
echo "Update user for dapserver authorization"
if [ $# -lt 3 ] || [ $# -gt 4 ]; then
echo "Need three or four parametrs ( login, first_name, last_name, password ( if want change) )."
exit 1
fi
if [ $# -eq 3 ]; then
mongo dapDb --eval "db.dap_users.update( { login : \"${1}\"}, { \$set: { \"profile.first_name\" : \"${2}\", \"profile.last_name\" : \"${3}\" } } )"
exit 0
fi
password=${4}
password_hash=$(/opt/cellframe-node/bin/dap_server_http_db_auth_tool password_hash ${password})
echo "Password hash $password_hash"
mongo dapDb --eval "db.dap_users.update( { login : \"${1}\"}, { \$set: { passwordHash : \"${password_hash}\", \"profile.first_name\" : \"${2}\", \"profile.last_name\" : \"${3}\" } } )"
#!/bin/sh
: 'Выдача подписки клиенту. Входные данные: логин и количество дней на которое
выписывается/продляется подписка, ( отсчет идет от момента использования скрипта, если
подписка еще активная то продляется на N дней )'
echo "Set user subscription"
if [ $# -ne "2" ]; then
echo "Error! Need two parametrs login(email?) and count day's subscribtion"
exit 1
fi
result=$(mongo dapDb --eval "db.dap_users.find( { login : \"${1}\" } )" | wc -l)
if [ $result -eq 2 ]; then
echo "Login not found in DataBase"
exit 2
fi
iso_date_expire=$(mongo dapDb --eval "db.dap_users.find( { login: \"${1}\" }, { expire_date : 1, _id : 0 } )" )
iso_date_expire=$(echo $iso_date_expire | grep -E -o "ISODate.+)" | grep -E -o "[0-9]+.+Z")
iso_date_expire_in_sec=$(date -d $iso_date_expire "+%s")
now_date_in_sec=$(date "+%s")
date_diff=`expr $iso_date_expire_in_sec - $now_date_in_sec`
if [ $date_diff -lt 0 ]; then
result_date=$(date -u -d '+ '${2}' day' '+%Y-%m-%d %T')
else
result_date=$(date -u -d "$iso_date_expire + ${2} day" "+%Y-%m-%d %T")
fi
mongo dapDb --eval "db.dap_users.update( { login : \"${1}\"}, { \$set: { expire_date : ISODate(\"${result_date}\") }} )"
echo "Subscription update for client to: " $result_date
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment