Commits

Marcin Kasperski committed 71c8f41

More or less ready, at least using simple testing

Comments (0)

Files changed (6)

     build_requires => {
         'Module::Build' => '0.19', # xs
         'Test::More' => 0,
-        'Test::Pod::Coverage' => '1.0.8',
+        'Test::Pod::Coverage' => '1.0',
     },
     configure_requires => {
         'Module::Build' => '0.36',
 Changes
 INSTALL
 lib/Passwd/Keyring/OSXKeychain.pm
-lib/Passwd/Keyring/OSXKeychain.xs
 Makefile.PL
 MANIFEST			This list of files
 META.json
 t/06-recovering-with-app-change.t
 t/07-ugly-chars.t
 t/08-verylong-params.t
+t/11-parse_password_out_of_output.t
 t/boilerplate.t
 t/cpan-meta-json.t
 t/cpan-meta.t
 ^version_hook\.py
 ^ignore\.txt
 ^make_release\.pl
+^devel_notes
 
 # Produced
 ^lib/Passwd/Keyring/OSXKeychain\.[co]$
+NAME
+    Passwd::Keyring::OSXKeychain - Password storage implementation based on
+    OSX/Keychain.
+
+VERSION
+    Version 0.2502
+
+WARNING
+    I do not have Mac. I wrote the library mimicking actions of some python
+    libraries and tested using mocks, but help of somebody able to test it
+    on true Mac is really needed.
+
+SYNOPSIS
+    OSXKeychain Keyring based implementation of Keyring. Provide secure
+    storage for passwords and similar sensitive data.
+
+        use Passwd::Keyring::OSXKeychain;
+
+        my $keyring = Passwd::Keyring::OSXKeychain->new(
+             app=>"blahblah scraper",
+             group=>"Johnny web scrapers",
+        );
+
+        my $username = "John";  # or get from .ini, or from .argv...
+
+        my $password = $keyring->get_password($username, "blahblah.com");
+        unless( $password ) {
+            $password = <somehow interactively prompt for password>;
+
+            # securely save password for future use
+            $keyring->set_password($username, "blahblah.com");
+        }
+
+        login_somewhere_using($username, $password);
+        if( password_was_wrong ) {
+            $keyring->clear_password($username, "blahblah.com");
+        }
+
+    Note: see Passwd::Keyring::Auto::KeyringAPI for detailed comments on
+    keyring method semantics (this document is installed with
+    `Passwd::Keyring::Auto' package).
+
+SUBROUTINES/METHODS
+  new(app=>'app name', group=>'passwords folder')
+    Initializes the processing. Croaks if osxkeychain keyring does not seem
+    to be available.
+
+    Handled named parameters:
+
+    - app - symbolic application name (not used at the moment, but can be
+    used in future as comment and in prompts, so set sensibly)
+
+    - group - name for the password group (will be visible in seahorse so
+    can be used by end user to manage passwords, different group means
+    different password set, a few apps may share the same group if they need
+    to use the same passwords set)
+
+    (OSXKeychain-specific)
+
+    - security_prog - location of security program (/usr/bin/security by
+    default, possibility to overwrite is mostly needed for testing)
+
+    - keychain - keychain to use (if not default)
+
+  set_password(username, password, realm)
+    Sets (stores) password identified by given realm for given user
+
+  get_password($user_name, $realm)
+    Reads previously stored password for given user in given app. If such
+    password can not be found, returns undef.
+
+  clear_password($user_name, $realm)
+    Removes given password (if present)
+
+    Returns how many passwords actually were removed
+
+  is_persistent
+    Returns info, whether this keyring actually saves passwords
+    persistently.
+
+    (true in this case)
+
+AUTHOR
+    Marcin Kasperski
+
+BUGS
+    Please report any bugs or feature requests to issue tracker at
+    https://bitbucket.org/Mekk/perl-keyring-osxkeychain.
+
+SUPPORT
+    You can find documentation for this module with the perldoc command.
+
+        perldoc Passwd::Keyring::OSXKeychain
+
+    You can also look for information at:
+
+    http://search.cpan.org/~mekk/Passwd-Keyring-OSXKeychain/
+
+    Source code is tracked at:
+
+    https://bitbucket.org/Mekk/perl-keyring-osxkeychain
+
+LICENSE AND COPYRIGHT
+    Copyright 2012 Marcin Kasperski.
+
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of either: the GNU General Public License as published
+    by the Free Software Foundation; or the Artistic License.
+
+    See http://dev.perl.org/licenses/ for more information.
+

lib/Passwd/Keyring/OSXKeychain.pm

         return $1;
     }
     elsif($text =~ /^ *password: *\$([0-9A-Fa-f]*)/m) {
-        return unpack("h*", $1);
+        return pack("H*", $1);
     }
     elsif($text =~ /^ *password: *$/m)  {
         return "";

t/11-parse_password_out_of_output.t

 
 use strict;
 use warnings;
-use Test::More tests => 11;
+use Test::More tests => 5;
 
 use Passwd::Keyring::OSXKeychain;
 
     "scrp"<sint32>=<NULL>
     "svce"<blob>="server.com"
     "type"<uint32>=<NULL>
-password: $FEA0997321"lalala"
+password: $4AC3BC7267C485"lalala"
 END
-    "to write what is there",
+    "Jürgą",
     "hexified password parse");
 
 is(
     "scrp"<sint32>=<NULL>
     "svce"<blob>="server.com"
     "type"<uint32>=<NULL>
-password: $1234abcdef
+password: $616c61206d61206b6f7461
 END
-    "to write what is there",
+    "ala ma kota",
     "hexified password parse");