-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f8321af
Showing
8 changed files
with
808 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
passff-host | ||
=========== | ||
|
||
[![Join the chat at https://gitter.im/jvenant/passff](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jvenant/passff?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
|
||
Host app for the WebExtension **[PassFF](https://addons.mozilla.org/firefox/addon/passff)** | ||
|
||
### Overview | ||
This piece of software wraps around the **[zx2c4 pass](http://www.zx2c4.com/projects/password-store/)** shell command. It has to be installed for the PassFF browser extension to work properly. | ||
|
||
### Installation | ||
Download the `install_host_app.sh` script from [our releases page](https://github.com/passff/passff-host/releases) and execute it. You can do this in one line like so: | ||
|
||
``` | ||
$ curl -sSL https://github.com/passff/passff-host/releases/download/1.0/install_host_app.sh | bash -s -- [firefox|chrome|opera|chromium|vivaldi] | ||
``` | ||
|
||
This script will download the host application (a small python script) and the add-on's manifest file (a JSON config file) and put them in the right place. | ||
If you're concerned about executing a script that downloads files from the web, you can download the files yourself and run the script with the `--local` option instead or link the files yourself. Details below. | ||
|
||
#### Windows | ||
Download the `install_host_app.bat` script from [our releases page](https://github.com/passff/passff-host/releases) and execute it from within a shell with a correct PATH. | ||
*The rule of thumb is: if you can execute pass and python from your shell, then your host application will be installed correctly.* | ||
|
||
``` | ||
> install_host_app.bat [firefox|chrome|opera|chromium|vivaldi] | ||
``` | ||
|
||
Note: Older Windows versions might require powershell to be installed manually as the install script uses powershell internally. Windows 10 users should be fine out of the box. | ||
|
||
#### Latest from GitHub | ||
This is not recommended! Only for developers and for testing purposes! | ||
|
||
Clone the repository. Then, from the project's `src/` directory, run `make` and execute the installation script in `bin/testing` for your desired browser (`firefox`, `chrome`, `opera`, `chromium`, or `vivaldi`): | ||
|
||
``` | ||
$ cd ./src | ||
$ make | ||
$ cd ../bin/testing | ||
$ ./install_host_app.sh --local [firefox|chrome|opera|chromium|vivaldi] | ||
``` | ||
|
||
This will copy the host application and manifest files to the right place for your browser. The `--local` option makes the script use the files on disk rather than downloading them from GitHub. | ||
|
||
If this doesn't work, you can link the files yourself. First, change the `path` value in the `passff.json` file to be the absolute path to the project's `bin/testing/passff.py` file. Then symlink (or copy) the file `bin/testing/passff.json` to the appropriate location for your browser and OS: | ||
|
||
- Firefox | ||
- Linux | ||
- Per-user: `~/.mozilla/native-messaging-hosts/passff.json` | ||
- System-wide: `/usr/{lib,lib64,share}/mozilla/native-messaging-hosts/passff.json` | ||
- OS X | ||
- `/Library/Application Support/Mozilla/NativeMessagingHosts/passff.json` | ||
- Windows | ||
- Per-user: `Path contained in registry key HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts\passff` | ||
- System-wide: `Path contained in registry key HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\passff` | ||
- Chrome | ||
- Linux | ||
- Per-user: `~/.config/google-chrome/NativeMessagingHosts/passff.json` | ||
- System-wide: `/etc/opt/chrome/native-messaging-hosts/passff.json` | ||
- OS X | ||
- Per-user: `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/passff.json` | ||
- System-wide: `/Library/Google/Chrome/NativeMessagingHosts/passff.json` | ||
- Windows | ||
- Per-user: `HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\NativeMessagingHosts\passff` | ||
- System-wide: `HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\passff` | ||
- Chromium | ||
- Linux | ||
- Per-user: `~/.config/chromium/NativeMessagingHosts/passff.json` | ||
- System-wide: `/etc/chromium/native-messaging-hosts/passff.json` | ||
- OS X | ||
- Per-user: `~/Library/Application Support/Chromium/NativeMessagingHosts/passff.json` | ||
- System-wide: `/Library/Application Support/Chromium/NativeMessagingHosts/passff.json` | ||
- Opera | ||
- Same as Chrome | ||
- Vivaldi | ||
- Linux | ||
- Per-user: `~/.config/vivaldi/NativeMessagingHosts/passff.json` | ||
- System-wide: `/etc/vivaldi/native-messaging-hosts/passff.json` | ||
- OS X | ||
- Per-user: `~/Library/Application Support/Vivaldi/NativeMessagingHosts/passff.json` | ||
- System-wide: `/Library/Application Support/Vivaldi/NativeMessagingHosts/passff.json` | ||
|
||
### Preferences | ||
By modifying the `preferences section` in `passff.py` you will be able to set | ||
- the path to the `pass` script, | ||
- additional command line arguments that are passed to `pass`, | ||
- the shell `stdout` charset, | ||
- additional environment variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
VERSION := testing | ||
|
||
SRC_DIR := . | ||
TARGET_DIR := ../bin/$(VERSION) | ||
|
||
INSTALL_WIN_FILE := install_host_app.bat | ||
INSTALL_WIN_SRC := $(SRC_DIR)/$(INSTALL_WIN_FILE) | ||
INSTALL_WIN_TARGET := $(TARGET_DIR)/$(INSTALL_WIN_FILE) | ||
|
||
INSTALL_UNIX_FILE := install_host_app.sh | ||
INSTALL_UNIX_SRC := $(SRC_DIR)/$(INSTALL_UNIX_FILE) | ||
INSTALL_UNIX_TARGET := $(TARGET_DIR)/$(INSTALL_UNIX_FILE) | ||
|
||
HOST_APP_FILES := passff.py passff.json | ||
HOST_APP_SRC := $(addprefix $(SRC_DIR)/,$(HOST_APP_FILES)) | ||
HOST_APP_TARGET := $(addprefix $(TARGET_DIR)/,$(HOST_APP_FILES)) | ||
|
||
HOST_TARGETS := $(INSTALL_WIN_TARGET) $(INSTALL_UNIX_TARGET) $(HOST_APP_TARGET) | ||
|
||
all: $(HOST_TARGETS) | ||
|
||
%/.d: | ||
mkdir -p $(@D) | ||
@touch $@ | ||
|
||
$(HOST_TARGETS): $(TARGET_DIR)/%: $(SRC_DIR)/% $(TARGET_DIR)/.d | ||
cp $(SRC_DIR)/$* $@ | ||
sed -i "s/_VERSIONHOLDER_/$(VERSION)/g" $@ | ||
|
||
clean: | ||
rm -rf $(TARGET_DIR) | ||
|
||
.PRECIOUS: %/.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
@ECHO OFF | ||
SETLOCAL | ||
|
||
SET "APP_NAME=passff" | ||
SET "VERSION=_VERSIONHOLDER_" | ||
SET "HOST_URL=https://github.com/passff/passff-host/releases/download/%VERSION%/passff.py" | ||
SET "MANIFEST_URL=https://github.com/passff/passff-host/releases/download/%VERSION%/passff.json" | ||
|
||
SET "TARGET_DIR=%APPDATA%\%APP_NAME%" | ||
SET "HOST_MANIFEST=%APP_NAME%.json" | ||
SET "HOST_SCRIPT=%APP_NAME%.py" | ||
SET "HOST_BATCH=%APP_NAME%.bat" | ||
|
||
SET "HOST_MANIFEST_FULL=%TARGET_DIR%\%HOST_MANIFEST%" | ||
SET "HOST_SCRIPT_FULL=%TARGET_DIR%\%HOST_SCRIPT%" | ||
SET "HOST_BATCH_FULL=%TARGET_DIR%\%HOST_BATCH%" | ||
|
||
SET "USE_LOCAL_FILES=" | ||
SET "TARGET_REG=" | ||
|
||
REM check prerequisites: is python installed & in path? | ||
python --version >NUL 2> NUL || ( | ||
ECHO "python not found in PATH. Please execute this command in a shell where python is in PATH" | ||
EXIT /B | ||
) | ||
|
||
:loop | ||
IF NOT "%1"=="" ( | ||
IF "%1"=="--local" ( | ||
SET "USE_LOCAL_FILES=true" | ||
SHIFT | ||
) ELSE IF "%1"=="--help" ( | ||
GOTO :help | ||
) ELSE IF "%1"=="firefox" ( | ||
SET "TARGET_REG=HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\%APP_NAME%" | ||
SHIFT | ||
) ELSE IF "%1"=="chrome" ( | ||
SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" | ||
SHIFT | ||
) ELSE IF "%1"=="chromium" ( | ||
ECHO Chromium registry key location for Native Messaging Hosts is undocumented. Assuming key for Chrome. Please provide feedback if this worked: https://github.com/passff/passff/issues/202 | ||
SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" | ||
SHIFT | ||
) ELSE IF "%1"=="opera" ( | ||
ECHO Opera registry key location for Native Messaging Hosts is undocumented. Assuming key for Chrome. Please provide feedback if this worked: https://github.com/passff/passff/issues/202 | ||
SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" | ||
SHIFT | ||
) ELSE IF "%1"=="vivaldi" ( | ||
ECHO Vivaldi registry key location for Native Messaging Hosts is undocumented. Assuming key for Chrome. Please provide feedback if this worked: https://github.com/passff/passff/issues/202 | ||
SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" | ||
SHIFT | ||
) ELSE ( | ||
SHIFT | ||
) | ||
GOTO :loop | ||
) | ||
|
||
IF "%TARGET_REG%"=="" ( | ||
GOTO :help | ||
) | ||
|
||
IF EXIST "%TARGET_DIR%" ( | ||
dir /AD "%TARGET_DIR%" > nul || ( | ||
ECHO "%TARGET_DIR%" is not a directory | ||
EXIT /B | ||
) | ||
) ELSE ( | ||
MKDIR "%TARGET_DIR%" 2> nul | ||
) | ||
|
||
IF "%USE_LOCAL_FILES%"=="true" ( | ||
IF NOT EXIST "%~dp0%HOST_MANIFEST%" ( | ||
ECHO local file "%~dp0%HOST_MANIFEST%" not found | ||
EXIT /B | ||
) | ||
IF NOT EXIST "%~dp0%HOST_SCRIPT%" ( | ||
ECHO local file "%~dp0%HOST_SCRIPT%" not found | ||
EXIT /B | ||
) | ||
COPY /Y "%~dp0%HOST_MANIFEST%" "%HOST_MANIFEST_FULL%" | ||
COPY /Y "%~dp0%HOST_SCRIPT%" "%HOST_SCRIPT_FULL%" | ||
) ELSE ( | ||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%HOST_URL%', '%HOST_SCRIPT_FULL%')" | ||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%MANIFEST_URL%', '%HOST_MANIFEST_FULL%')" | ||
) | ||
|
||
powershell -Command "(Get-Content '%HOST_MANIFEST_FULL%') -replace 'PLACEHOLDER', '%HOST_BATCH_FULL:\=/%' | Set-Content '%HOST_MANIFEST_FULL%'" | ||
|
||
( | ||
ECHO @ECHO OFF | ||
ECHO SET "PATH=%PATH%" | ||
ECHO SET "GNUPGHOME=%GNUPGHOME%" | ||
ECHO python "%HOST_SCRIPT_FULL%" %%* | ||
)>"%HOST_BATCH_FULL%" | ||
|
||
REG ADD "%TARGET_REG%" /ve /d "%HOST_MANIFEST_FULL%" /f || ( | ||
ECHO Adding key to registry failed - maybe you need Administrator rights for this. Please run | ||
ECHO REG ADD "%TARGET_REG%" /ve /d "%HOST_MANIFEST_FULL%" /f | ||
ECHO manually in an administrative shell. | ||
) | ||
EXIT /B | ||
|
||
:help | ||
ECHO Usage: %0 [OPTION] [chrome^|chromium^|firefox^|opera^|vivaldi] | ||
ECHO | ||
ECHO Options: | ||
ECHO --local Install files from disk instead of downloading them | ||
ECHO --help Show this message" | ||
EXIT /B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is derived from `install.sh` in Danny van Kooten's "browserpass": | ||
# https://github.com/dannyvankooten/browserpass | ||
|
||
set -e | ||
|
||
APP_NAME="passff" | ||
VERSION="_VERSIONHOLDER_" | ||
HOST_URL="https://github.com/passff/passff-host/releases/download/$VERSION/passff.py" | ||
MANIFEST_URL="https://github.com/passff/passff-host/releases/download/$VERSION/passff.json" | ||
|
||
# Find target dirs for various browsers & OS'es | ||
# https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location | ||
# https://wiki.mozilla.org/WebExtensions/Native_Messaging | ||
if [ $(uname -s) == 'Darwin' ]; then | ||
if [ "$(whoami)" == "root" ]; then | ||
TARGET_DIR_CHROME="/Library/Google/Chrome/NativeMessagingHosts" | ||
TARGET_DIR_CHROMIUM="/Library/Application Support/Chromium/NativeMessagingHosts" | ||
TARGET_DIR_FIREFOX="/Library/Application Support/Mozilla/NativeMessagingHosts" | ||
TARGET_DIR_VIVALDI="/Library/Application Support/Vivaldi/NativeMessagingHosts" | ||
else | ||
TARGET_DIR_CHROME="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" | ||
TARGET_DIR_CHROMIUM="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" | ||
TARGET_DIR_FIREFOX="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts" | ||
TARGET_DIR_VIVALDI="$HOME/Library/Application Support/Vivaldi/NativeMessagingHosts" | ||
fi | ||
else | ||
if [ "$(whoami)" == "root" ]; then | ||
TARGET_DIR_CHROME="/etc/opt/chrome/native-messaging-hosts" | ||
TARGET_DIR_CHROMIUM="/etc/chromium/native-messaging-hosts" | ||
TARGET_DIR_FIREFOX="/usr/lib/mozilla/native-messaging-hosts" | ||
TARGET_DIR_VIVALDI="/etc/vivaldi/native-messaging-hosts" | ||
else | ||
TARGET_DIR_CHROME="$HOME/.config/google-chrome/NativeMessagingHosts" | ||
TARGET_DIR_CHROMIUM="$HOME/.config/chromium/NativeMessagingHosts" | ||
TARGET_DIR_FIREFOX="$HOME/.mozilla/native-messaging-hosts" | ||
TARGET_DIR_VIVALDI="$HOME/.config/vivaldi/NativeMessagingHosts" | ||
fi | ||
fi | ||
|
||
function usage { | ||
echo "Usage: $0 [OPTION] [chrome|chromium|firefox|opera|vivaldi] | ||
Options: | ||
-l, --local Install files from disk instead of downloading them | ||
-h, --help Show this message" | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
chrome) | ||
BROWSER_NAME="Chrome" | ||
TARGET_DIR="$TARGET_DIR_CHROME" | ||
;; | ||
chromium) | ||
BROWSER_NAME="Chromium" | ||
TARGET_DIR="$TARGET_DIR_CHROMIUM" | ||
;; | ||
firefox) | ||
BROWSER_NAME="Firefox" | ||
TARGET_DIR="$TARGET_DIR_FIREFOX" | ||
;; | ||
opera) | ||
BROWSER_NAME="Opera" | ||
TARGET_DIR="$TARGET_DIR_VIVALDI" | ||
;; | ||
vivaldi) | ||
BROWSER_NAME="Vivaldi" | ||
TARGET_DIR="$TARGET_DIR_VIVALDI" | ||
;; | ||
-l|--local) | ||
USE_LOCAL_FILES=true | ||
;; | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
PYTHON3_PATH="$(which python3)" | ||
if [ -x "$PYTHON3_PATH" ]; then | ||
echo "Python 3 executable located at $PYTHON3_PATH" | ||
else | ||
echo "Python 3 executable not found, but Python 3 is required for PassFF to work!" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$TARGET_DIR" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
HOST_FILE_PATH="$TARGET_DIR/$APP_NAME.py" | ||
MANIFEST_FILE_PATH="$TARGET_DIR/$APP_NAME.json" | ||
ESCAPED_HOST_FILE_PATH="${HOST_FILE_PATH////\\/}" | ||
|
||
echo "Installing $BROWSER_NAME host config" | ||
|
||
# Create config dir if not existing | ||
mkdir -p "$TARGET_DIR" | ||
|
||
if [ "$USE_LOCAL_FILES" = true ]; then | ||
DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
cp "$DIR/passff.py" "$HOST_FILE_PATH" | ||
cp "$DIR/passff.json" "$MANIFEST_FILE_PATH" | ||
else | ||
# Download native host script and manifest | ||
curl -sSL "$HOST_URL" > "$HOST_FILE_PATH" | ||
curl -sSL "$MANIFEST_URL" > "$MANIFEST_FILE_PATH" | ||
fi | ||
|
||
# Replace path to host | ||
sed -i -e "s/PLACEHOLDER/$ESCAPED_HOST_FILE_PATH/" "$MANIFEST_FILE_PATH" | ||
|
||
# Replace path to python3 executable | ||
sed -i "1c#\!${PYTHON3_PATH}" "$HOST_FILE_PATH" | ||
|
||
# Set permissions for the manifest so that all users can read it. | ||
chmod a+x "$HOST_FILE_PATH" | ||
chmod o+r "$MANIFEST_FILE_PATH" | ||
|
||
echo "Native messaging host for $BROWSER_NAME has been installed to $TARGET_DIR." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "passff", | ||
"description": "Host for communicating with zx2c4 pass", | ||
"path": "PLACEHOLDER", | ||
"type": "stdio", | ||
"allowed_extensions": [ "passff@invicem.pro" ] | ||
} |
Oops, something went wrong.