| 1 |
NAME |
| 2 |
Config::Identity - Load (and optionally decrypt via GnuPG) user/pass |
| 3 |
identity information |
| 4 |
|
| 5 |
VERSION |
| 6 |
version 0.0019 |
| 7 |
|
| 8 |
SYNOPSIS |
| 9 |
PAUSE: |
| 10 |
|
| 11 |
use Config::Identity::PAUSE; |
| 12 |
|
| 13 |
# 1. Find either $HOME/.pause-identity or $HOME/.pause |
| 14 |
# 2. Decrypt the found file (if necessary), read, and parse it |
| 15 |
# 3. Throw an exception unless %identity has 'user' and 'password' defined |
| 16 |
|
| 17 |
my %identity = Config::Identity::PAUSE->load_check; |
| 18 |
print "user: $identity{user} password: $identity{password}\n"; |
| 19 |
|
| 20 |
GitHub API: |
| 21 |
|
| 22 |
use Config::Identity::GitHub; |
| 23 |
|
| 24 |
# 1. Find either $HOME/.github-identity or $HOME/.github |
| 25 |
# 2. Decrypt the found file (if necessary) read, and parse it |
| 26 |
# 3. Throw an exception unless %identity has 'login' and 'token' defined |
| 27 |
|
| 28 |
my %identity = Config::Identity::PAUSE->load_check; |
| 29 |
print "login: $identity{login} token: $identity{token}\n"; |
| 30 |
|
| 31 |
DESCRIPTION |
| 32 |
Config::Identity is a tool for loading (and optionally decrypting via |
| 33 |
GnuPG) user/pass identity information |
| 34 |
|
| 35 |
For GitHub API access, an identity is a "login"/"token" pair |
| 36 |
|
| 37 |
For PAUSE access, an identity is a "user"/"password" pair |
| 38 |
|
| 39 |
USAGE |
| 40 |
%identity = Config::Identity->load_best( <stub> ) |
| 41 |
First attempt to load an identity from $HOME/.<stub>-identity |
| 42 |
|
| 43 |
If that file does not exist, then attempt to load an identity from |
| 44 |
$HOME/.<stub> |
| 45 |
|
| 46 |
The file may be optionally GnuPG encrypted |
| 47 |
|
| 48 |
%identity will be populated like so: |
| 49 |
|
| 50 |
<key> <value> |
| 51 |
|
| 52 |
For example: |
| 53 |
|
| 54 |
username alice |
| 55 |
password hunter2 |
| 56 |
|
| 57 |
If an identity file can't be found or read, the method croaks. |
| 58 |
|
| 59 |
%identity = Config::Identity->load_check( <stub>, <checker> ) |
| 60 |
Works like "load_best" but also checks for required keys. The "checker" |
| 61 |
argument must be an array reference of required keys or a code reference |
| 62 |
that takes a hashref of key/value pairs from the identity file and |
| 63 |
returns a list of missing keys. For convenience, the hashref will also |
| 64 |
be placed in $_. |
| 65 |
|
| 66 |
If any keys are found missing, the method croaks. |
| 67 |
|
| 68 |
Using a custom "gpg" or passing custom arguments |
| 69 |
You can specify a custom "gpg" executable by setting the CI_GPG |
| 70 |
environment variable |
| 71 |
|
| 72 |
export CI_GPG="$HOME/bin/gpg" |
| 73 |
|
| 74 |
You can pass custom arguments by setting the CI_GPG_ARGUMENTS |
| 75 |
environment variable |
| 76 |
|
| 77 |
export CI_GPG_ARGUMENTS="--no-secmem-warning" |
| 78 |
|
| 79 |
Encrypting your identity information with GnuPG |
| 80 |
If you've never used GnuPG before, first initialize it: |
| 81 |
|
| 82 |
# Follow the prompts to create a new key for yourself |
| 83 |
gpg --gen-key |
| 84 |
|
| 85 |
To encrypt your GitHub identity with GnuPG using the above key: |
| 86 |
|
| 87 |
# Follow the prompts, using the above key as the "recipient" |
| 88 |
# Use ^D once you've finished typing out your authentication information |
| 89 |
gpg -ea > $HOME/.github |
| 90 |
|
| 91 |
Caching your GnuPG secret key via gpg-agent |
| 92 |
Put the following in your .*rc |
| 93 |
|
| 94 |
if which gpg-agent 1>/dev/null |
| 95 |
then |
| 96 |
if test -f $HOME/.gpg-agent-info && \ |
| 97 |
kill -0 `cut -d: -f 2 $HOME/.gpg-agent-info` 2>/dev/null |
| 98 |
then |
| 99 |
. "${HOME}/.gpg-agent-info" |
| 100 |
export GPG_AGENT_INFO |
| 101 |
else |
| 102 |
eval `gpg-agent --daemon --write-env-file "${HOME}/.gpg-agent-info"` |
| 103 |
fi |
| 104 |
else |
| 105 |
fi |
| 106 |
|
| 107 |
PAUSE identity format |
| 108 |
user <user> |
| 109 |
password <password> |
| 110 |
|
| 111 |
"username" can also be used as alias for "user" |
| 112 |
|
| 113 |
GitHub identity format |
| 114 |
login <login> |
| 115 |
token <token> |
| 116 |
|
| 117 |
SUPPORT |
| 118 |
Bugs / Feature Requests |
| 119 |
Please report any bugs or feature requests through the issue tracker at |
| 120 |
<http://rt.cpan.org/Public/Dist/Display.html?Name=Config-Identity>. You |
| 121 |
will be notified automatically of any progress on your issue. |
| 122 |
|
| 123 |
Source Code |
| 124 |
This is open source software. The code repository is available for |
| 125 |
public review and contribution under the terms of the license. |
| 126 |
|
| 127 |
<https://github.com/dagolden/Config-Identity> |
| 128 |
|
| 129 |
git clone https://github.com/dagolden/Config-Identity.git |
| 130 |
|
| 131 |
AUTHOR |
| 132 |
Robert Krimen <[email protected]> |
| 133 |
|
| 134 |
CONTRIBUTOR |
| 135 |
David Golden <[email protected]> |
| 136 |
|
| 137 |
COPYRIGHT AND LICENSE |
| 138 |
This software is copyright (c) 2010 by Robert Krimen. |
| 139 |
|
| 140 |
This is free software; you can redistribute it and/or modify it under |
| 141 |
the same terms as the Perl 5 programming language system itself. |
| 142 |
|