Add the aap-passwd utility and the AAP_ROOTDIR environment variable 0.002
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 11 Aug 2013 13:08:42 +0000 (16:08 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 11 Aug 2013 13:09:01 +0000 (16:09 +0300)
Changes
MANIFEST
Makefile.PL
README
aap-passwd [new file with mode: 0644]
lib/Apache2/Authen/Passphrase.pm
t/Apache2-Authen-Passphrase.t

diff --git a/Changes b/Changes
index f93cd705ad72b670814dd13984565a7171bc1303..383c9c999f4e3a94b47ecdacb81f3d2e86eeeb44 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,11 @@
 Revision history for Perl extension Apache2::Authen::Passphrase.
 
+0.002 Sun 11 Aug 16:05:32 EEST 2013
+       - Add the aap-passwd utility
+       - Talk about the rootdir in the documentation
+       - Support setting the rootdir via an evironment variable
+0.001001 Sun  4 Aug 20:10:24 EEST 2013
+       - Fix the broken previous release
+
 0.001 Sun  4 Aug 19:47:54 EEST 2013
        - Initial Release
-0.001001 Sun  4 Aug 20:10:24 EEST 2013
-       - Fix the broken previous release
\ No newline at end of file
index 757c28172d4ce290f6fd9e6a79bb082540a4626f..fe6f2077df961ba09cbec9d729395abadc0c489c 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2,5 +2,6 @@ Changes
 Makefile.PL
 MANIFEST
 README
+aap-passwd
 t/Apache2-Authen-Passphrase.t
 lib/Apache2/Authen/Passphrase.pm
index bb06469ecc2ea46d11473d97e34d6df4cea1f6bf..3ac11e8d4e8380891d8e6bcb1bc5525ecb46355f 100644 (file)
@@ -7,12 +7,14 @@ WriteMakefile(
        AUTHOR           => 'Marius Gavrilescu <marius@ieval.ro>',
        MIN_PERL_VERSION => '5.14.0',
        LICENSE          => 'perl',
+       EXE_FILES        => [ 'aap-passwd' ],
     PREREQ_PM        => {
          Apache2::RequestRec => 0,
          Apache2::Access => 0,
          Apache2::Const => 0,
          Authen::Passphrase => 0,
          Authen::Passphrase::BlowfishCrypt => 0,
+         IO::Prompter => 0,
          YAML::Any => 0,
        },
 );
diff --git a/README b/README
index 26e3bf90e2efb59b8dae54bf86fe40ddc285e965..286257e06fb3939d60c1ae6704d99608e205d793 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache2-Authen-Passphrase version 0.001001
+Apache2-Authen-Passphrase version 0.002
 ==========================================
 
 Apache2::Authen::Passphrase is a perl module which provides easy-to-use Apache2 authentication. It exports some utility functions and it contains a PerlAuthenHandler.
@@ -21,6 +21,7 @@ This module requires these other modules and libraries:
 * mod_perl2
 * Authen::Passphrase
 * YAML::Any
+* IO::Prompter
 
 COPYRIGHT AND LICENCE
 
diff --git a/aap-passwd b/aap-passwd
new file mode 100644 (file)
index 0000000..68dee6b
--- /dev/null
@@ -0,0 +1,85 @@
+#!/usr/bin/perl -wT
+use v5.14;
+use strict;
+
+use Apache2::Authen::Passphrase qw/pwset USER_REGEX/;
+
+use IO::Prompter [qw/-e* -stdio/];
+
+die "Usage: aap-passwd [rootdir] username\n" unless $#ARGV >= 0 && $#ARGV <= 1;
+($Apache2::Authen::Passphrase::rootdir) = (shift =~ /(.*)/) if $#ARGV == 1;
+
+my $username = shift;
+die "Invalid username" unless $username =~ USER_REGEX;
+($username) = ($username =~ /(.*)/);
+
+my $passwd = prompt 'Enter new Apache2::Authen::Passphrase password: ';
+my $confirm = prompt 'Retype new Apache2::Authen::Passphrase password: ';
+
+die "Sorry, passwords do not match\n" unless $passwd eq $confirm;
+pwset $username, $passwd;
+say "Password updated successfully";
+
+__END__
+
+=head1 NAME
+
+aap-passwd - passwd utility for Apache2::Authen::Passphrase
+
+=head1 SYNOPSIS
+
+  user@hostname:~$ aap-passwd /path/to/rootdir marius
+  Enter new Apache2::Authen::Passphrase password: ***
+  Retype new Apache2::Authen::Passphrase password: ***
+  Password updated successfully
+
+=head1 DESCRIPTION
+
+aap-passwd updates the password of an Apache2::Authen::Passphrase user.
+
+It is used like this:
+
+    aap-passwd /path/to/rootdir username
+
+where the C<rootdir> is the first argument and the username whose password is to be changed is the second argument, or like this:
+
+    aap-passwd username
+
+where the C<rootdir> is taken from the environment and the username is the only argument.
+
+=head1 ENVIRONMENT
+
+=over
+
+=item AAP_ROOTDIR
+
+The default Apache2::Authen::Passphrase C<rootdir>, used if the C<rootdir> is not explicitly given.
+
+=back
+
+=head1 AUTHOR
+
+Marius Gavrilescu C<< <marius@ieval.ro> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2013 Marius Gavrilescu
+
+This file is part of fonbotd.
+
+fonbotd is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+fonbotd is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with fonbotd.  If not, see <http://www.gnu.org/licenses/>
+
+
+=cut
+
index 4beea0e0e8e10160a55465c48cbbb1ea7a923122..bea2bca35a2fb3e1728ac4cc4a4c2c5e1f9ffc49 100644 (file)
@@ -1,4 +1,6 @@
-package Apache2::Authen::Passphrase 0.001001;
+package Apache2::Authen::Passphrase;
+
+our $VERSION = 0.002;
 
 use 5.014000;
 use strict;
@@ -23,7 +25,7 @@ our @EXPORT_OK = qw/pwset pwcheck pwhash USER_REGEX PASSPHRASE_VERSION INVALID_U
 
 ##################################################
 
-our $rootdir;
+our $rootdir //= $ENV{AAP_ROOTDIR};
 
 sub pwhash{
   my ($pass)=@_;
@@ -103,6 +105,14 @@ Apache2::Authen::Passphrase - basic authentication with Authen::Passphrase
 
 Apache2::Authen::Passphrase is a perl module which provides easy-to-use Apache2 authentication. It exports some utility functions and it contains a PerlAuthenHandler.
 
+The password hashes are stored in YAML files in an directory (called the C<rootdir>), one file per user.
+
+Set the C<rootdir> like this:
+
+  $Apache2::Authen::Passphrase::rootdir = '/path/to/rootdir';
+
+or by setting the C<AAP_ROOTDIR> enviroment variable to the desired value.
+
 =head1 FUNCTIONS
 
 =over
@@ -149,6 +159,16 @@ Uses C<Authen::Passphrase::BlowfishCrypt> with a cost factor of 10
 
 =back
 
+=head1 ENVIRONMENT
+
+=over
+
+=item AAP_ROOTDIR
+
+If the C<rootdir> is not explicitly set, it is taken from this environment variable.
+
+=back
+
 =head1 AUTHOR
 
 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
index 0ebf90d4c1419926ddb68a32f7f5c3b3d68ce254..7b545189397df5c93dfba42e8dc7b062d98f47af 100644 (file)
@@ -4,10 +4,9 @@ use warnings;
 
 use File::Temp qw/tempdir/;
 use Test::More tests => 7;
+BEGIN { $ENV{AAP_ROOTDIR} = tempdir CLEANUP => 1 }
 BEGIN { use_ok('Apache2::Authen::Passphrase', qw/pwset pwcheck/) };
 
-$Apache2::Authen::Passphrase::rootdir = tempdir CLEANUP => 1;
-
 sub pw_ok {
   my ($user, $pass, $testname) = @_;
   eval { pwcheck $user, $pass };
This page took 0.016627 seconds and 4 git commands to generate.