diff --git a/.gitignore b/.gitignore index 70a5aa6..c9ec3f8 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ virtualenv_run/ src/vendor/ src/libusb-1.0.dylib *.pyc +venv diff --git a/src/8486DCAA-AFB7-407D-A0E9-E57E09997B24.png b/8486DCAA-AFB7-407D-A0E9-E57E09997B24.png similarity index 100% rename from src/8486DCAA-AFB7-407D-A0E9-E57E09997B24.png rename to 8486DCAA-AFB7-407D-A0E9-E57E09997B24.png diff --git a/Makefile b/Makefile index 008ee0f..d0ad371 100644 --- a/Makefile +++ b/Makefile @@ -1,51 +1,47 @@ .PHONY: default default: run -# Simple execution of the workflow to see all results -.PHONY: run -run: install-requirements - ./src/main.py +.PHONY: build +build: venv install-ports -# Runs workflow and prompts for Yubikey password -.PHONY: set-password -set-password: install-requirements - ./src/main.py set-password +.PHONY: install +install: venv + ./replace-workflow.sh -.PHONY: install-requirements -install-requirements: src/vendor src/libusb-1.0.dylib - -# Installs libusb from /opt/local, where MacPorts installs it -src/libusb-1.0.dylib: - cp /opt/local/lib/libusb-1.0.dylib ./src/ - -# Installs 3rd party packages into vendor directory -src/vendor: - mkdir -p .pip-cache - pip install -r ./requirements.txt -t ./src/vendor --cache-dir .pip-cache - cp vendor.py src/vendor/__init__.py - -# Creates virtualenv for testing using MacPorts Python -virtualenv: - virtualenv --python=/opt/local/bin/python2.7 virtualenv - ./virtualenv_run/bin/pip install -r ./requirements.txt - -# Runs workflow using virtualenv Python -.PHONY: virtualenv_run -virtualenv_run: virtualenv - ./virtualenv/bin/python src/main.py - -# Clears the virtualenv and other installed files -.PHONY: clean -clean: - rm -fr virtualenv src/vendor src/libusb-1.0.dylib - find . -name '*.pyc' -delete - find . -name '__pycache__' -delete +Yauth.alfredWorkflow: venv + mkdir Yauth.alfredWorkflow + cp -r alfred_yauth Yauth.alfredworkflow/ + cp -r venv Yauth.alfredWorkflow/ + cp info.plist Yauth.alfredWorkflow/ + cp icon.png Yauth.alfredWorkflow/ # Installs required MacPorts .PHONY: install-ports install-ports: sudo port install swig swig-python ykpers libu2f-host libusb +# Creates venv using MacPorts Python (Required for it to refrence libusb) +venv: + virtualenv --python=/opt/local/bin/python2.7 venv + ./venv/bin/pip install -r ./requirements.txt + +# Simple execution of the workflow to see all results +.PHONY: run +run: venv + @./venv/bin/python -m alfred_yauth.main + +# Runs workflow and prompts for Yubikey password +.PHONY: set-password +set-password: venv + @./venv/bin/python -m alfred_yauth.main set-password + +# Clears the virtualenv and other installed files +.PHONY: clean +clean: + rm -fr venv Yauth.alfredWorkflow + find . -name '*.pyc' -delete + find . -name '__pycache__' -delete + # Install precommit hooks .PHONY: intall-hooks install-hooks: diff --git a/README.md b/README.md index ee8167e..7f25b56 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,37 @@ -Alfred Yubico Auth -================== +# Alfred Yubico Auth An Alfred Workflow for auto filling authentication codes stored on your Yubikey. -Notes ------ +## Notes This is definitely a work in progress. There are a lot of rough edges yet to be polished, but here it goes. +* Requires some to be installed with a package manager * There is no way to input your key password through the UI yet. Do that with `make set-password` and then it should work fine. -* Does not bundle dylibs for you. Hanve't quite figured out what needs to be done to make this portable -* Requires MacPorts to install dependencies * Error handling is terrible right now. If things don't work, check the debug log in Alfred -Credits -------- +## Installation + +Clone this repo + +```bash +git clone https://git.iamthefij.com/iamthefij/alfred-yubico-auth.git +``` + +Either install your dependencies manually or, if you have MacPorts, you can use: + +```bash +make install-ports +``` + +Otherwise you need to install `swig swig-python ykpers libu2f-host libusb` some other way. + +Finally up the virtualenv and install to your Alfred with + +```bash +make install +``` + +## Credits Uses the amazing [deanishe/alfred-workflow](https://github.com/deanishe/alfred-workflow) package diff --git a/alfred_yauth/__init__.py b/alfred_yauth/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/controller.py b/alfred_yauth/controller.py similarity index 99% rename from src/controller.py rename to alfred_yauth/controller.py index f8e8c74..d31b514 100644 --- a/src/controller.py +++ b/alfred_yauth/controller.py @@ -13,8 +13,6 @@ from ykman.util import derive_key from ykman.util import parse_b32_key from ykman.util import TRANSPORT -import vendor # noqa - NON_FEATURE_CAPABILITIES = [CAPABILITY.CCID, CAPABILITY.NFC] diff --git a/src/main.py b/alfred_yauth/main.py old mode 100755 new mode 100644 similarity index 98% rename from src/main.py rename to alfred_yauth/main.py index 107648f..0a65d3f --- a/src/main.py +++ b/alfred_yauth/main.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from getpass import getpass @@ -108,7 +107,7 @@ class YubicoAuth(Workflow3): command_action = None if command == 'set-password': command_action = self.ask_yubikey_password - if command == 'list': + elif command == 'list': command_action = self.list_credentials else: command_action = self.refresh_credentials diff --git a/src/version b/alfred_yauth/version similarity index 100% rename from src/version rename to alfred_yauth/version diff --git a/src/icon.png b/icon.png similarity index 100% rename from src/icon.png rename to icon.png diff --git a/src/info.plist b/info.plist similarity index 97% rename from src/info.plist rename to info.plist index 6d2cfe9..23c4076 100644 --- a/src/info.plist +++ b/info.plist @@ -92,6 +92,23 @@ Yubico Auth objects + + config + + autopaste + + clipboardtext + {query} + transient + + + type + alfred.workflow.output.clipboard + uid + 9F48DDE6-BBE7-42ED-ABE5-C9255C92F1CD + version + 2 + config @@ -113,23 +130,6 @@ version 1 - - config - - autopaste - - clipboardtext - {query} - transient - - - type - alfred.workflow.output.clipboard - uid - 9F48DDE6-BBE7-42ED-ABE5-C9255C92F1CD - version - 2 - config @@ -173,6 +173,8 @@ alfredfiltersresults + alfredfiltersresultsmatchmode + 0 argumenttrimmode 0 argumenttype @@ -192,7 +194,7 @@ runningsubtext script - python main.py + ./venv/bin/python -m alfred_yauth.main scriptargtype 1 scriptfile @@ -202,7 +204,7 @@ title Yubikey 2FA type - 8 + 0 withspace diff --git a/replace-workflow.sh b/replace-workflow.sh new file mode 100755 index 0000000..c64aeaf --- /dev/null +++ b/replace-workflow.sh @@ -0,0 +1,8 @@ +#! /bin/bash +set -e + +echo "Warning! This will remove the workflow at the provided path and replace it with a link to this directory" +read -p "Path to workflow to replace: " existing_workflow + +rm -fr "$existing_workflow" +ln -s `pwd` "$existing_workflow" diff --git a/set_version.sh b/set_version.sh index e1b6e84..9b5d69e 100755 --- a/set_version.sh +++ b/set_version.sh @@ -1,4 +1,4 @@ #! /bin/bash -echo "$1" > ./src/version -plutil -replace version -string "$1" ./src/info.plist +echo "$1" > ./alfred_yauth/version +plutil -replace version -string "$1" ./info.plist diff --git a/vendor.py b/vendor.py deleted file mode 100644 index ffe03bf..0000000 --- a/vendor.py +++ /dev/null @@ -1,5 +0,0 @@ -import os -import sys - - -sys.path.append(os.path.basename(__file__))