commit - 6efe800d1e123a24bb10bfa8c79a388e08aafd6b
commit + ca6188079b04727f9c0d2bcd0585b0e5f3753744
blob - e0699a903ae0de79d93b7c2ad0964570cbc981e1 (mode 755)
blob + /dev/null
--- bin/knocknocauth
+++ /dev/null
-#!/bin/sh
-
-usage="usage: knocknocauth [-c] host ..."
-
-jsonheader="Content-Type: application/json"
-
-args=`getopt c $*`
-if test $? -ne 0
-then
- echo "$usage" >&2
- exit 2
-fi
-set -- $args
-while test $# -ne 0
-do
- case "$1"
- in
- -c)
- close="$1"; shift;;
- --)
- shift; break;;
- esac
-done
-
-if test "$#" -eq 0
-then
- echo "$usage" >&2
- exit 2
-fi
-
-configdir="$HOME/.config/knocknoc"
-
-cachedir="$HOME/.cache/knocknoc"
-mkdir -p "$cachedir"
-
-for host in $@
-do
- if test "$close"
- then
- if ! test -f "$cachedir/$host"
- then
- echo "no session cookie for $host" >&2
- continue
- fi
- echo "closing sessions not implemented yet"
- exit 1
- # curl -v -X POST -b "$cachedir/$host" "https://$host/logout"
- continue
- fi
-
- if test -f "$configdir/$host"
- then
- file="$configdir/$host"
- username=`sed -n 1p $file`
- password=`sed -n 2p $file`
- else
- # read in bash(1)
- # read -p "$host username: " username
- # read -p "$username's password: " password
- # for read on ksh(1) e.g. OpenBSD
- read username?"$host username: "
- read password?"$username's password: "
- fi
- body="{\"UserName\": \"$username\", \"Password\": \"$password\"}"
- curl -s -H "$jsonheader" -d "$body" -c "$cachedir/$host" "https://$host/login"
-done
blob - 10cd803e066344581ea6e901695ab08bfa3a591e (mode 644)
blob + /dev/null
--- man/knocknocauth.1
+++ /dev/null
-.Dd
-.Dt KNOCKNOCAUTH 1
-.Os
-.Sh NAME
-.Nm knocknocauth
-.Nd create and close knocknoc sessions
-.Sh SYNOPSIS
-.Nm knocknocauth
-.Op -c
-.Ar host ...
-.Sh DESCRIPTION
-.Nm
-authenticates and creates a new session with each Knocknoc
-.Ar host .
-.Pp
-Credentials for
-.Ar host
-may be provided in a credentials file.
-Credentials files consists of two lines.
-The first line is a knocknoc username,
-and the second line is their password.
-.Nm
-searches the default user configuration directory
-for a file with the same name as
-.Ar host .
-.Pp
-If no matching credentials file can be found,
-.Nm
-prompts for a username and password.
-.Pp
-The -c flag can be set to close any existing sessions with
-.Ar host .
-.Sh EXIT STATUS
-.Ex
-.Sh EXAMPLES
-Create sessions with
-.Ar login.example.com
-and
-.Ar vendoraccess.example.net :
-.Pp
-.Dl knocknocauth login.example.com vendoraccess.example.net
-.Pp
-A credentials file for the user oliver.lowe@company.example at login.example.com
-would be at
-.Pa $HOME/.config/knocknoc/login.example.com
-with the following contents:
-.Bd -literal -offset indent
-oliver.lowe@company.example
-SecretPassword1234
-.Ed