File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ export LAZY_CONNECT_TOTP_QUERY=<name of the issuer>
5656
5757### Warning
5858
59- - The secret key to generate TOTP is stored as plain text in ` ~/.config/lazy-connect/secret `
59+ - The secret key to generate TOTP is stored in Keychain on Mac under default ` login ` keychain. You may need to
60+ enter your login password to allow access to Keychain.
6061- You need to add your Termainal emulator app that invokes the function to ` Security & Privacy -> Accessibility ` . It is
6162 necesssary because the script interacts with the UI. There are other ways via CLI to avoid UI interaction but
6263 they are all broken in OS X 10.12+.
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ function _lazy_connect_init() {
1111 echo -n " Secret Key: "
1212 read -s secret_key
1313 echo " **********"
14- echo $secret_key > $_lazy_connect_config_dir /secret
14+
15+ echo ' Storing secret in keychain.'
16+ security add-generic-password -a lazy-connect -p " $secret_key " -s lazy-connect
1517 ;;
1618 esac
1719 _lazy_connect_vpn_refresh
@@ -171,7 +173,13 @@ function lazy-connect() {
171173 esac
172174 done
173175
174- secret=$( cat $_lazy_connect_config_dir /secret)
176+ local secret=$( security find-generic-password -a lazy-connect -w 2> /dev/null | tr -d ' \n' )
177+ if [ -z " $secret " ];
178+ then
179+ echo " Secret not found in keychain. Initialize lazy-connect and try again."
180+ return 1
181+ fi
182+
175183 vpn_name=$( cat $_lazy_connect_config_dir /vpns \
176184 | fzf --height=10 --ansi --reverse --query " $* " --select-1)
177185 [ -z " $vpn_name " ] || _lazy_connect " $vpn_name " " $secret "
You can’t perform that action at this time.
0 commit comments