FAQ | This is a LIVE service | Changelog

Commit 30c3fd70 authored by Tony Finch's avatar Tony Finch

ReGPG::Login: simplified basic auth support

The trailing options argument to `read_login` was kind of ugly, and
for code that needs options it isn't much harder to use the `new`
constructor. So, get rid of options support in `read_login` (leaving
only the check list) and also remove the `basic` alias for
`auth_basic` to make it more clear what is the purpose of the option.

This is a breaking change, but ipreg is the only user at the moment,
and I have refactored the ipreg code to use `new` where it needed the
`auth_basic` option.
parent ba264fab
......@@ -57,7 +57,6 @@ sub new {
chomp $self->{$k};
}
bless $self, $class;
$opt{auth_basic} //= $opt{basic};
for my $option (qw(auth_basic check)) {
if (my $args = $opt{$option}) {
$self->$option(@$args);
......@@ -68,10 +67,10 @@ sub new {
sub read_login {
my $yml = shift;
my $opt = ref $_[-1] ? pop @_ : {};
$opt->{filename} = $yml;
$opt->{check} = [@_];
return ReGPG::Login->new(%$opt);
return ReGPG::Login->new(
filename => $yml,
check => [@_],
);
}
1;
......@@ -168,8 +167,6 @@ The YAML file to load. (required)
Shortcut for calling C<$login-E<gt>check(@fields)>
=item basic => [@fields]
=item auth_basic => [@fields]
Shortcut for calling C<$login-E<gt>auth_basic(@fields)>
......@@ -192,8 +189,8 @@ For example,
my $login = ReGPG::Login->new(
filename => "login.yml",
check => [qw[url]],
basic => [qw[username password]]
check => [qw[ url ]],
auth_basic => [qw[ username password ]],
);
my $r = LWP::UserAgent->new()->post($login->{url},
Authorization => $login->{authorization},
......@@ -208,15 +205,14 @@ ReGPG::Login exports one subroutine.
=over
=item read_login $filename, @check, { ...opt... }
=item read_login $filename, @check
The @check and/or hash ref arguments are optional.
A simplified constructor. The @check list is optional optional.
This is equivalent to
ReGPG::Login->new(
filename => $filename,
check => [@check],
...opt...
);
=back
......
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