FAQ | This is a LIVE service | Changelog

Commit 92a4b4ff authored by Tony Finch's avatar Tony Finch

ReGPG::Login: helper option for HTTP basic auth

parent 775f12d4
regpg release notes and change summary
* HTTP Basic authorization convenience helper in ReGPG::Login.
2019-09-27 - regpg-1.10
......@@ -8,6 +8,7 @@ use Exporter qw(import);
use File::Basename;
use File::Slurp;
use IPC::System::Simple qw(capturex);
use MIME::Base64;
use YAML;
our $regpg-1.10;
......@@ -33,10 +34,22 @@ sub read_login {
chomp $login->{$k};
for (@_) {
croak "$yml: missing key $_\n"
unless defined $login->{$_};
my $check = sub {
for (@_) {
croak "$yml: missing key $_\n"
unless defined $login->{$_};
if (ref $_[-1]) {
my $opt = pop @_;
if (my $basic = $opt->{basic}) {
my $auth = join ':', @$login{@$basic};
$login->{authorization} =
'Basic ' . encode_base64 $auth, '';
return $login;
......@@ -111,6 +124,27 @@ Any trailing arguments to C<read_login> are a list of keys that muct
be present in the top-level object after adding the decrypted files.
If any are missing, C<read_login> will croak.
=head2 Login post-processing options
The last argument to C<read_login> can be a hash ref containing options.
=head3 basic
The only option defined so far is C<basic>. The value of the option is
an array ref containing username and password login field names. These
field names are included in the check list. The corresponding login
field values are used to create an HTTP Basic C<Authorization> header
For example,
my $login = read_login "login.yml", qw(url),
{ basic => [qw[username password]] };
my $r = LWP::UserAgent->new()->post($login->{url},
Authorization => $login->{authorization},
=head1 VERSION
This is regpg-1.10 <https://dotat.at/prog/regpg/>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment