NAME

credsman - is a simple Pel extension to work with 'Windows Credential Manager'.

SYNOPSIS

 use strict;
 use warnings;
 use Net::FTP;
 use credsman qw(login);

 # This type of function is necessary to run login, 
 # You need to handle the access or connection and Error messages

 sub Connect_Example {
     my $credentials = shift;
     # Here your code to login or connect using user and password
     if( $credentials->{user} eq 'pepe' and  $credentials->{password} eq 'pepepass' ){
         print "The Target Name is: $credentials->{target}\n";
         print "  User  : $credentials->{user}\n";
         print "  Pass  : $credentials->{password}\n";
         print "Attempt : $credentials->{attempt} of $credentials->{limit}\n"; 
         # Return 0 - Success
         return 0;
     }
     else{
         print "Fail\n";
         # Return to fail
         return 1;
     }
 }

 # In this Example the program will die at the attempt number 10.

 die "No Zero Return" if login( 
     program  => 'credsman',          # The Prefix to Store the credentials in wcm 
     target   => "Test",              # The Target to validate user and password, usually a server
     subref   => \&Connect_Example,   # Reference to a Function (how to validate password)
     limit    => 10,                  # Number of Attempts before the program Finish
 );

 # This Example will connect to FTP and Return the object to the function.
 # Option undefine:   you need to combine with the inherit hash reference

 sub Connect_FTP {
     my $credentials = shift;
     # Here your code to login or connect using user and password
     # The given Parameter has the {inherit} key, if you pass it the function
       will return the inherit to evaluate.
     
     my $ftp = Net::FTP->new("$credentials->{target}", Debug => 0)
         or die "Cannot connect to some.host.name: $@";
     
     my $status = $ftp->login("$credentials->{user}",$credentials->{password});

     if( ! $status ){
         print "Attempt : $credentials->{attempt} of $credentials->{limit}\n"; 
         print "$credentials->{user} cannot login ".$ftp->message ."\n";
         return 1;
     }

     ${$credentials->{inherit}} = $ftp;

     return 0; # Success
 }

 
 my $ftp = Connect_FTP( 
     program  => 'credsman',          # The Prefix to Store the credentials in wcm 
     target   => "Test",              # The Target to validate user and password, usually a server
     subref   => \&Connect_FTP,       # Reference to a Function (how to validate password)
     limit    => 3,                   # Number of Attempts before the program Finish
     undefine => 1,                   # To use with inherit, when you need to pass the object.
 );
 
 die "Fail to Connect" unless defined $ftp; 

DESCRIPTION

Credsman (credential manager)

A small library that interacts with Perl and Windows Credential Manager.

It incorporates Windows Credential GUI. It also uses and is integrated with the status.

The Credentials will be stored with the Following format

- Windows Credential Manager - Generic Credentials
- format:
- *['program name']~['Server name or Address']*

EXPORT

login: Function GuiCred: Windows GUI User and Password Login.

AUTHOR

RODAGU , <rodagu@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2020 by Rodrigo Agurto

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.30.0 or, at your option, any later version of Perl 5 you may have available.