credentials: rename service -> account, 2fa,sfa -> mfa
This commit is contained in:
parent
aa6636e6a5
commit
82b8e95d7e
@ -14,7 +14,7 @@ usage()
|
||||
{
|
||||
cat - <<. >&2
|
||||
Usage:
|
||||
${0##*/} [-2pu] service
|
||||
${0##*/} [-mpu] account
|
||||
.
|
||||
exit 1
|
||||
}
|
||||
@ -42,59 +42,55 @@ get_pass()
|
||||
sekrit cp "$1/pass" && printf "\n"
|
||||
}
|
||||
|
||||
get_2fa()
|
||||
get_mfa()
|
||||
{
|
||||
printf 2fa
|
||||
printf mfa
|
||||
otpcli_opts=
|
||||
case $1 in
|
||||
isnic) otpcli_opts="-H sha512 -d 8"
|
||||
;;
|
||||
esac
|
||||
sekrit get "$1/2fa" | otpcli $otpcli_opts | clip && printf "\n"
|
||||
sekrit get "$1/mfa" | otpcli $otpcli_opts | clip && printf "\n"
|
||||
}
|
||||
|
||||
get_service()
|
||||
get_account()
|
||||
{
|
||||
service=$1
|
||||
account=$1
|
||||
user=$2
|
||||
pass=$3
|
||||
sfa=$4
|
||||
mfa=$4
|
||||
|
||||
if [ $user = no ] && [ $pass = no ] && [ $sfa = no ]; then
|
||||
sekrit has "$service/pass" ||
|
||||
err "unknown service $service"
|
||||
if [ $user = no ] && [ $pass = no ] && [ $mfa = no ]; then
|
||||
sekrit has "$account/pass" || err "unknown account $account"
|
||||
pass=yes
|
||||
sekrit has "$service/user" && user=yes
|
||||
sekrit has "$service/2fa" && sfa=yes
|
||||
sekrit has "$account/user" && user=yes
|
||||
sekrit has "$account/mfa" && mfa=yes
|
||||
fi
|
||||
|
||||
if [ $user = check ]; then
|
||||
sekrit has "$service/user" ||
|
||||
err "service $service has no user"
|
||||
sekrit has "$account/user" || err "account $account has no user"
|
||||
user=yes
|
||||
fi
|
||||
if [ $pass = check ]; then
|
||||
sekrit has "$service/pass" ||
|
||||
err "service $service has no pass"
|
||||
sekrit has "$account/pass" || err "account $account has no pass"
|
||||
pass=yes
|
||||
fi
|
||||
if [ $sfa = check ]; then
|
||||
sekrit has "$service/2fa" ||
|
||||
err "service $service has no 2fa"
|
||||
sfa=yes
|
||||
if [ $mfa = check ]; then
|
||||
sekrit has "$account/mfa" || err "account $account has no MFA"
|
||||
mfa=yes
|
||||
fi
|
||||
|
||||
[ $user = yes ] && get_user "$service"
|
||||
[ $pass = yes ] && get_pass "$service"
|
||||
[ $sfa = yes ] && get_2fa "$service"
|
||||
[ $user = yes ] && get_user "$account"
|
||||
[ $pass = yes ] && get_pass "$account"
|
||||
[ $mfa = yes ] && get_mfa "$account"
|
||||
}
|
||||
|
||||
sfa=no
|
||||
mfa=no
|
||||
pass=no
|
||||
user=no
|
||||
while getopts 2pu flag; do
|
||||
while getopts mpu flag; do
|
||||
case $flag in
|
||||
2) sfa=check
|
||||
m) mfa=check
|
||||
;;
|
||||
p) pass=check
|
||||
;;
|
||||
@ -109,6 +105,6 @@ shift $((OPTIND - 1))
|
||||
[ $# -eq 1 ] && [ -n "$1" ] || usage
|
||||
key=$1
|
||||
|
||||
: ${SEKRIT_DIR:=~/keep/sekrit/services}
|
||||
: ${SEKRIT_DIR:=~/keep/sekrit/accounts}
|
||||
export SEKRIT_DIR
|
||||
get_account "$key" $user $pass $mfa
|
||||
|
Loading…
Reference in New Issue
Block a user