Passwd-Keyring-Auto

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.2601  2012-11-08

        Small documentation fixes, more info in CPAN metadata

0.26    2012-11-08

        Updated location of KeyringAPI document.

0.25    2012-11-08

        Added support for KDEWallet as alternative for Linux desktops.

0.24    2012-11-08

        Clarifying meaning of app and group parameters.

0.23    2012-11-08

        Documented keyring backends API (L<Passwd::Keyring::KeyringAPI>).
        Tests properly clean created passwords.

README  view on Meta::CPAN

    Version 1.0000

SYNOPSIS

    Passwd::Keyring is about securely preserving passwords and other
    sensitive data (for example API keys, OAuth tokens etc) in backends
    like Gnome Keyring, KDE Wallet, OSX/Keychain etc.

    While modules like Passwd::Keyring::Gnome handle specific backends,
    Passwd::Keyring::Auto tries to pick the best backend available,
    considering the current desktop environment, program options, and user
    configuration.

        use Passwd::Keyring::Auto;  # get_keyring
    
        my $keyring = get_keyring(app=>"My super scraper", group=>"Social passwords");
    
        my $username = "someuser";
        my $password = $keyring->get_password($username, "mylostspace.com");
        unless($password) {
            # ... somehow interactively prompt for password

README.md  view on Meta::CPAN

Version 1.0000

# SYNOPSIS

Passwd::Keyring is about securely preserving passwords and other
sensitive data (for example API keys, OAuth tokens etc) in backends
like Gnome Keyring, KDE Wallet, OSX/Keychain etc.

While modules like Passwd::Keyring::Gnome handle specific backends,
Passwd::Keyring::Auto tries to pick the best backend available,
considering the current desktop environment, program options, and user
configuration.

    use Passwd::Keyring::Auto;  # get_keyring

    my $keyring = get_keyring(app=>"My super scraper", group=>"Social passwords");

    my $username = "someuser";
    my $password = $keyring->get_password($username, "mylostspace.com");
    unless($password) {
        # ... somehow interactively prompt for password

lib/Passwd/Keyring/Auto.pm  view on Meta::CPAN

our $VERSION = '1.0000';

=head1 SYNOPSIS

Passwd::Keyring is about securely preserving passwords and other
sensitive data (for example API keys, OAuth tokens etc) in backends
like Gnome Keyring, KDE Wallet, OSX/Keychain etc.

While modules like Passwd::Keyring::Gnome handle specific backends,
Passwd::Keyring::Auto tries to pick the best backend available,
considering the current desktop environment, program options, and user
configuration.

    use Passwd::Keyring::Auto;  # get_keyring

    my $keyring = get_keyring(app=>"My super scraper", group=>"Social passwords");

    my $username = "someuser";
    my $password = $keyring->get_password($username, "mylostspace.com");
    unless($password) {
        # ... somehow interactively prompt for password

t/21-finds_proper_keyring_envs.t  view on Meta::CPAN

    local $ENV{PASSWD_KEYRING_FORBID} = 'Gnome';

    my $ring = get_keyring(app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto");
    ok($ring, "Got some keyring");

    unlike(ref($ring), qr/::Gnome$/, "We should respect FORBID under Gnome");
}

# Under KDE we should get KDE Wallet
SKIP: {
    skip "Not a KDE desktop session", 3
      unless ($ENV{DESKTOP_SESSION} || '') =~ /^kde/;
    skip "Running as root", 3
      unless $>;
    eval { require Passwd::Keyring::KDEWallet };
    skip "Passwd::Keyring::KDEWallet not installed", 3
      if $@;

    local $ENV{PASSWD_KEYRING_FORBID} = 'Gnome';

    my $ring = get_keyring(app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto");
    ok($ring, "Got some keyring");

    ok($ring->is_persistent, "Under Linux desktop we should get persistent keyring");

    isa_ok($ring, "Passwd::Keyring::KDEWallet", "Under KDE we should get KDE keyring");
}

# ... unless forbidden
SKIP: {
    skip "Not a KDE desktop session", 3 
      unless ($ENV{DESKTOP_SESSION} || '') =~ /^kde/;
    eval { require Passwd::Keyring::KDEWallet };
    skip "Passwd::Keyring::KDEWallet not installed", 3
      if $@;

    local $ENV{PASSWD_KEYRING_FORBID} = 'KDEWallet';

    my $ring = get_keyring(app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto");
    ok($ring, "Got some keyring");

    ok($ring->is_persistent, "Under Linux desktop we should get persistent keyring");

    unlike(ref($ring), qr/::KDEWallet/, "We should respect FORBID under KDE");
}

SKIP: {
    skip "Not a desktop session", 3 
      unless ($ENV{DESKTOP_SESSION});
    skip "Running as root", 3
      unless $>;

    local $ENV{PASSWD_KEYRING_FORBID} = 'KDEWallet Gnome';

    my $ring = get_keyring(app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto");
    ok($ring, "Got some keyring");

    unlike(ref($ring), qr/::KDEWallet/, "We should respect FORBID");

t/22-finds_proper_keyring_params.t  view on Meta::CPAN


    my $ring = get_keyring(app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto",
                           forbid=>"Gnome");
    ok($ring, "Got some keyring");

    unlike(ref($ring), qr/::Gnome$/, "We should respect forbid=Gnome");
}

# Under KDE we should get KDE Wallet
SKIP: {
    skip "Not a KDE desktop session", 3 
      unless ($ENV{DESKTOP_SESSION} || '') =~ /^kde/;
    skip "Running as root", 3
      unless $>;
    eval { require Passwd::Keyring::KDEWallet };
    skip "Passwd::Keyring::KDEWallet not installed", 3 if $@;

    my $ring = get_keyring(
        app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto",
        forbid=>["Gnome"]);
    ok($ring, "Got some keyring");

    ok($ring->is_persistent, "Under Linux desktop we should get persistent keyring");

    isa_ok($ring, "Passwd::Keyring::KDEWallet", "Under KDE we should get KDE keyring");
}

# ... unless forbidden
SKIP: {
    skip "Not a KDE desktop session", 3 
      unless ($ENV{DESKTOP_SESSION} || '') =~ /^kde/;
    eval { require Passwd::Keyring::KDEWallet };
    skip "Passwd::Keyring::KDEWallet not installed", 3
      if $@;

    my $ring = get_keyring(
        app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto",
        forbid=>["KDEWallet"]);
    ok($ring, "Got some keyring");

    ok($ring->is_persistent, "Under Linux desktop we should get persistent keyring");

    unlike(ref($ring), qr/::KDEWallet/, "We should respect forbid under KDE");
}

SKIP: {
    skip "Not a desktop session", 3 
      unless ($ENV{DESKTOP_SESSION});

    my $ring = get_keyring(
        app_name=>"Passwd::Keyring::Auto unit tests", group=>"Passwd::Keyring::Auto",
        "forbid"=>["KDEWallet", "Gnome"]);
    ok($ring, "Got some keyring");

    unlike(ref($ring), qr/::KDEWallet/, "We should respect forbid");
    unlike(ref($ring), qr/::Gnome/, "We should respect forbid");
}



( run in 0.689 second using v1.01-cache-2.11-cpan-299005ec8e3 )