alfred-workflow-gauth
alfred-workflow-gauth copied to clipboard
Implemented Apple Keychain support (with migration procedure)
Implementation details:
Added
- [management] store secrets in a separate easily lockable
alfred-gauthkeychain (not theloginkeychain) - [security] using
securitycommand to manage keychain, which results in the following behavior:- a user is asked for a password at keychain creation/unlock time
- the Alfred itself isn't aware of the that password
- [performance] using
security dump-keychaincommand to get all accounts with their passwords in a plain text format - an internal method for removing accounts (could be connected to UI later)
- an internal method for generating a QRCode from an account (could be connected to UI later), that could be scanned in the Google Authenticator app
Changed
- removed dead code for
key/hexkeyhandling in the "~/.gauth" file (otp.get_hotp_key,AlfredGAuth. config_get_account_token), becausegauth addcommand only populates thesecretkey - replaced
'... {} ...'.format(...)notation withf'... {...} ...'notation - changed the visibility of methods that were used as protected but declared as public
- simplified workflow configuration:
- used
Junctionworkflow element to join copy-to-clipboard and show notification actions together (previously an action was used that printed out what was given to it)
- used
- integrated:
- #45
- #46
- #48
- #49
- #50
Fixed
- when attempting to add a first account (the config file is empty) using
gauth add account,secret, then you're seeingGAuth is not yet configuredscript filter XML entry in the notification prior to anA new account was added...text - when a config file was empty in used used
gauthcommand, then he was seeingGAuth is not yet configuredentry (correct), but the workflow also created a 2ndAccount not foundentry, which Alfred didn't show, because of invalid XML (e.g.<items>...entry for missing config...</items><items>...entry for account not found...</items>)
User-facing changes:
- added these extra flows:
- if a keychain is missing, then a user is informed about that and asked to create one
- if a keychain exists but it is locked, then a user is informed about that and asked to unlock it
- if an unlocked empty keychain exists and there is a non-empty
~/.gauthfile, then the user is informed about that and asked to migrate the data
- the notification title about an added/non-added account is now dynamic (e.g.
Account creation succeededandAccount creation failed) instead of staticGoogle Authenticator
Test Plan
Part 1
- backup:
- your existing workflow
- your
~/.gauthfile
- install the workflow from this PR ( https://github.com/moul/alfred-workflow-gauth/raw/0f01cfd654d6572e3f1d83b7e9df3a93283dee66/Google%20Authenticator.alfredworkflow )
Part 2
- open the Alfred Search Bar
- type
gauth(keyword to activate this workflow) - follow the instructions for Apple Keychain creation/unlocking
- if you're using workflow from this PR for the first time, then follow the instructions for Apple Keychain data migration
- if you had a non-empty
~/.gauthfile, then:- confirm that
~/.gauthfile was deleted - all accounts from the
~/.gauthfile are shown in the workflow
- confirm that
Part 3
- open the Alfred Search Bar
- type
gauth(keyword to activate this workflow) - select the
Add a new secretentry and hit ENTER - you'll be presented with
gauth addprompt - add an account
- confirm that account was added
Workflow screenshots
Before this PR:
After this PR:
When Apple Keychain is missing:
When Apple Keychain is locked:
When Apple Keychain is present/unlocked + file ~/.gauth is missing:
When Apple Keychain is present/unlocked + file ~/.gauth is present:
- Replaces #11
- Closes #41