view release on metacpan or search on metacpan
examples/eval.pl view on Meta::CPAN
my $cv = AE::cv();
my $redis = AnyEvent::Redis::RipeRedis->new(
host => 'localhost',
port => 6379,
password => 'redis_pass',
on_connect => sub {
print "Connected to Redis server\n";
},
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Riak.pm view on Meta::CPAN
=item user
required, string
=item password
required, string
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/RipeRedis/Cluster.pm view on Meta::CPAN
$self->{on_node_disconnect} = $params{on_node_disconnect};
$self->{on_node_error} = $params{on_node_error};
$self->on_error( $params{on_error} );
my %node_params;
foreach my $name ( qw( password utf8 connection_timeout read_timeout
reconnect reconnect_interval handle_params ) )
{
next unless defined $params{$name};
$node_params{$name} = $params{$name};
}
lib/AnyEvent/RipeRedis/Cluster.pm view on Meta::CPAN
startup_nodes => [
{ host => 'localhost', port => 7000 },
{ host => 'localhost', port => 7001 },
{ host => 'localhost', port => 7002 },
],
password => 'yourpass',
connection_timeout => 5,
read_timeout => 5,
refresh_interval => 5,
lazy => 1,
reconnect_interval => 5,
lib/AnyEvent/RipeRedis/Cluster.pm view on Meta::CPAN
contain C<host> and C<port> elements. The client will try to connect to random
node from the list to retrieve information about all cluster nodes and slots
mapping. If the client could not connect to first selected node, it will try
to connect to another random node from the list.
=item password => $password
If the password is specified, the C<AUTH> command is sent to all nodes
of the cluster after connection.
=item allow_slaves => $boolean
If enabled, the client will try to send read-only commands to slave nodes.
view all matches for this distribution
view release on metacpan or search on metacpan
examples/eval.pl view on Meta::CPAN
my $cv = AE::cv;
my $redis = AnyEvent::RipeRedis->new(
host => 'localhost',
port => 6379,
password => 'redis_pass',
on_connect => sub {
print "Connected to Redis server\n";
},
view all matches for this distribution
view release on metacpan or search on metacpan
t/08_register_with_auth.t view on Meta::CPAN
my ($lsock,$laddr,$peer) = @_;
my $ua = Simple->new( leg => $lsock );
my $auth = Authorize->new(
dispatcher => $ua->{dispatcher},
user2a1 => { '007' => md5_hex('007:REALM.example.com:secret') },
user2pass => sub { $_[0] eq 'wolf' ? 'lobo' : 'no-useful-password' },
realm => 'REALM.example.com',
opaque => 'HumptyDumpty',
i_am_proxy => 0,
);
my $auth_chain = ReceiveChain->new(
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/SOCKS/Client.pm view on Meta::CPAN
};
sub _parse_uri{
my $re = qr!socks(4|4a|5)://(?:([^\s:]+):([^\s@]*)@)?(\[[0-9a-f:.]+\]|[^\s:]+):(\d+)!i ;
if( $_[0] =~ m/$re/gi ){
my $p = {v => $1, login => $2, password => $3, host => $4, port => $5};
$p->{host} =~ s/^\[|\]$//g;
return $p;
}
undef ;
}
lib/AnyEvent/SOCKS/Client.pm view on Meta::CPAN
sub handshake{
my( $self ) = @_;
my $that = $self->{chain}->[0] ;
my @auth_methods = 0 ;
if($that->{login} and $that->{password}){
push @auth_methods, AUTH_LOGIN ;
}
$self->{hd}->push_write(
pack('CC', 5, scalar @auth_methods ) . join( "", map( pack( 'C', $_ ), @auth_methods ))
);
lib/AnyEvent/SOCKS/Client.pm view on Meta::CPAN
}
sub auth{
my( $self, $method ) = @_;
my $that = $self->{chain}->[0] ;
if( $method == AUTH_LOGIN and $that->{login} and $that->{password}){
$self->{hd}->push_write(
pack('CC', 5, length $that->{login} ) . $that->{login}
. pack('C', length $that->{password}) . $that->{password}
);
$self->{hd}->push_read( chunk => 2, sub{
my $status = unpack('xC', $_[1]) ;
if( $status == 0 ){
$self->connect_cmd ;
return ;
}
AE::log "error" => "Bad login or password";
});
return ;
}
AE::log "error" => "Auth method $method not implemented!";
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/SSH2.pm view on Meta::CPAN
unless ($ssh->{config}->get('protocol')) {
$ssh->{config}->set('protocol',
PROTOCOL_SSH1 | PROTOCOL_SSH2 | PROTOCOL_SSH1_PREFERRED);
}
unless (defined $ssh->{config}->get('password_prompt_login')) {
$ssh->{config}->set('password_prompt_login', 1);
}
unless (defined $ssh->{config}->get('password_prompt_host')) {
$ssh->{config}->set('password_prompt_host', 1);
}
unless (defined $ssh->{config}->get('number_of_password_prompts')) {
$ssh->{config}->set('number_of_password_prompts', 3);
}
# login
if (!defined $ssh->{config}->get('user')) {
$ssh->{config}->set('user',
defined $arg{user} ? $arg{user} : _current_user());
}
if (!defined $arg{pass} && exists $CONFIG->{ssh_password}) {
$arg{pass} = $CONFIG->{ssh_password};
}
$ssh->{config}->set('pass', $arg{pass});
#my $suppress_shell = $_[2];
}
lib/AnyEvent/SSH2.pm view on Meta::CPAN
unless (my $if = $ssh->{config}->get('identity_files')) {
defined $home or croak "Cannot determine home directory, please set the environment variable HOME";
$ssh->{config}->set('identity_files', [ "$home/.ssh/id_dsa" ]);
}
for my $a (qw( password dsa kbd_interactive )) {
$ssh->{config}->set("auth_$a", 1)
unless defined $ssh->{config}->get("auth_$a");
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Stomper.pm view on Meta::CPAN
The user identifier used to authenticate against a secured STOMP server.
=item passcode => $passcode
The password used to authenticate against a secured STOMP server.
=item vhost => $vhost
The name of a virtual host that the client wishes to connect to.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Subprocess.pm view on Meta::CPAN
arbitrary file descriptor number in the child. You have an infinite
number of these, so you can capture the child's stdout and stderr,
write to its stdin, and also share a socket for out-of-band
communication. You can also open a pipe to the child's fd #5 and
write to it. (This is nice if you are invoking something like C<gpg>
that wants the password written on an arbitrary fd other than 1.)
(This is all done with the included C<Handle> delegate. See
L<AnyEvent::Subprocess::Job::Delegate::Handle>.)
You can then build upon this; instead of writing your own code to
view all matches for this distribution
view release on metacpan or search on metacpan
eg/import-opml.pl view on Meta::CPAN
use strict;
use AnyEvent::Superfeedr;
use XML::OPML::LibXML;
my($opml, $jid, $pass) = @ARGV;
$opml && $jid && $pass or die "Usage: $0 OPML JID password";
my $parser = XML::OPML::LibXML->new;
my $doc = $parser->parse_file($opml);
my @feeds;
$doc->walkdown(sub { push @feeds, $_[0]->xml_url if defined $_[0]->xml_url });
my $superfeedr = AnyEvent::Superfeedr->new(
debug => $ENV{ANYEVENT_SUPERFEEDR_DEBUG},
jid => $jid,
password => $pass,
);
my $end = AnyEvent->condvar;
$end->begin for @feeds;
$superfeedr->connect( sub {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Task.pm view on Meta::CPAN
$checkout->hash('secret',
sub {
my ($checkout, $crypted) = @_;
print "Hashed password is $crypted\n";
$checkout->verify($crypted, 'secret',
sub {
my ($checkout, $result) = @_;
print "Verify result is $result\n";
lib/AnyEvent/Task.pm view on Meta::CPAN
$cv->recv;
=head2 Output
Hashed password is $2a$10$NwTOwxmTlG0Lk8YZMT29/uysC9RiZX4jtWCx.deBbb2evRjCq6ovi
Verify result is 1
lib/AnyEvent/Task.pm view on Meta::CPAN
};
if ($@) {
say "hash failed: $@";
} else {
say "hashed password is $crypted";
}
But in an asynchronous program, typically C<hash> would initiate some kind of asynchronous operation and then return immediately, allowing the program to go about other tasks while waiting for the result. Since the error might come back at any time i...
AnyEvent::Task accomplishes this mapping with L<Callback::Frame>.
lib/AnyEvent/Task.pm view on Meta::CPAN
frame(code => sub {
$client->checkout->hash('secret', sub {
my ($checkout, $crypted) = @_;
say "Hashed password is $crypted";
});
}, catch => sub {
my $back_trace = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
eg/track.pl view on Meta::CPAN
$AnyEvent::Twitter::Stream::STREAMING_SERVER = $ENV{FIREHOSE_SERVER};
}
my $done = AE::cv;
my($user, $password, $method, %args) = @ARGV;
binmode STDOUT, ":utf8";
my $streamer = AnyEvent::Twitter::Stream->new(
username => $user,
password => $password,
method => $method || "sample",
%args,
use_compression => 1,
on_tweet => sub {
my $tweet = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/WebService/ImKayac.pm view on Meta::CPAN
=head1 SYNOPSIS
use AnyEvent::WebService::ImKayac;
my $im = AnyEvent::WebService::ImKayac->new(
type => 'password',
user => '...',
password => '...'
);
$im->send( message => 'Hello! test send!!', cb => sub {
my ($hdr, $json, $reason) = @_;
lib/AnyEvent/WebService/ImKayac.pm view on Meta::CPAN
=head2 METHODS
=head3 new
You must pass C<< type >> and C<< user >> parameter to new method. And type should be
secret, password or none.
=over 3
=item type is secret
You should pass secret_key parameter.
=item type is password
You should pass password parameter.
=item type is none
You dond need to pass other parameter.
lib/AnyEvent/WebService/ImKayac.pm view on Meta::CPAN
my %args = ($_[1]) ? @_ : %{$_[1]};
croak "missing require parameter 'user'" unless defined $args{user};
croak "missing require parameter 'type'" unless defined $args{type};
$args{type} = 'none' if $args{type} !~ /^(none|password|secret)$/;
if ($args{type} eq 'password' && ! defined $args{password}) {
croak "require password";
}
if ($args{type} eq 'secret' && ! defined $args{secret_key}) {
croak "require secret_key";
}
lib/AnyEvent/WebService/ImKayac.pm view on Meta::CPAN
sub _param_none {
my ($self, %args) = @_;
%args;
}
sub _param_password {
my ($self, %args) = @_;
(
%args,
password => $self->{password},
);
}
sub _param_secret {
my ($self, %args) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
my ( $class, %params ) = @_;
return bless {
url => URI->new($params{url}),
username => $params{username},
password => $params{password},
}, $class;
}
sub parse_datetime {
my ( $self, $str ) = @_;
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
}
sub do_request {
my ( $self, $http_method, $uri, $params, $method, $cb ) = @_;
my ( $username, $password ) = @{$self}{qw/username password/};
my $auth_token = encode_base64(join(':', $username, $password), '');
$params->{'headers'} = {
Authorization => "Basic $auth_token",
Accept => 'application/xml',
Referer => undef,
};
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
use AnyEvent::WebService::Tracks;
my $tracks = AnyEvent::WebService::Tracks->new(
url => 'http://my.tracks.instance/',
username => 'user',
password => 'pa55w0rd',
);
$tracks->projects(sub {
my ( $projects ) = @_;
lib/AnyEvent/WebService/Tracks.pm view on Meta::CPAN
=head1 METHODS
=head2 AnyEvent::WebService::Tracks->new(%params)
Creates a new AnyEvent::WebService::Tracks object. C<%params> must contain
the url, username, and password parameters.
=head2 $tracks->projects($callback)
Retrieves the list of projects in the given Tracks installation and provides
them to the given callback. If the call fails, then a falsy value and the
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/XMPP.pm view on Meta::CPAN
someone who sends the bot a 'send <filename>' message.
=item B<samples/simple_register_example>
This is a example script which allows you to register, unregister and change
your password for accounts. Execute it without arguments for more details.
=item B<samples/disco_info>
This is a small example tool that allows you to fetch the software version,
disco info and disco items information about a JID.
lib/AnyEvent/XMPP.pm view on Meta::CPAN
=item B<samples/retrieve_roster>
This is a simple example script that will retrieve the roster
for an account and print it to stdout. You start it like this:
samples/# ./retrieve_roster <jid> <password>
=item B<samples/display_avatar>
This is just a small example which should display the avatar
of the account you connect to. It can be used like this:
samples/# ./display_avatar <jid> <password>
=back
For others, which the author might forgot or didn't want to
list here see the C<samples/> directory.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyMerchant.pm view on Meta::CPAN
version 0.0002
=head1 SYNOPSIS
my $gateway = AnyMerchant->gateway('Balanced', password => 'abc123');
=head1 DESCRIPTION
AnyMerchant is a generic and consistent interface for online payment services.
It is an alternative to L<Business::OnlinePayment>.
lib/AnyMerchant.pm view on Meta::CPAN
=head1 METHODS
=head2 gateway
my $gateway = AnyMerchant->gateway('Balanced', password => 'abc123');
This is a static factory method that creates an AnyMerchant::Gateway::* object,
validates its interface, and returns it.
In the above example, an AnyMerchant::Gateway::Balanced object is returned.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyMongo/Connection.pm view on Meta::CPAN
is => 'rw',
isa => 'Str',
required => 0,
);
has password => (
is => 'rw',
isa => 'Str',
required => 0,
);
lib/AnyMongo/Connection.pm view on Meta::CPAN
eval "use ${_}" # no Any::Moose::load_class becase the namespaces already have symbols from the xs bootstrap
for qw/AnyMongo::Database AnyMongo::Cursor AnyMongo::BSON::OID/;
$self->_parse_servers();
if ($self->auto_connect) {
$self->connect;
# if (defined $self->username && defined $self->password) {
# $self->authenticate($self->db_name, $self->username, $self->password);
# }
}
}
lib/AnyMongo/Connection.pm view on Meta::CPAN
name => $database_name,
);
}
sub authenticate {
my ($self, $dbname, $username, $password, $is_digest) = @_;
my $hash = $password;
# create a hash if the password isn't yet encrypted
if (!$is_digest) {
$hash = Digest::MD5::md5_hex("${username}:mongo:${password}");
}
# get the nonce
my $db = $self->get_database($dbname);
my $result = $db->run_command({getnonce => 1});
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnySan/Provider/IRC.pm view on Meta::CPAN
# connect server
$con->connect ($host, $port, {
nick => $nickname,
user => $config{user},
password => $config{password},
});
return $self;
}
lib/AnySan/Provider/IRC.pm view on Meta::CPAN
my $irc = irc
'chat.example.net', # irc servername *required
port => 6667, # default is 6667
enable_ssl => 0, # 1 = use ssl socket, default is no use ssl
password => 'server_password',
key => 'example1', # you can write, unique key *required
nickname => 'AnySan1', # irc nickname *required
recive_commands => [ 'PRIVMSG', 'NOTICE' ], # default is [ 'PRIVMSG' ]
interval => 2, # default is 2(sec), defence of Excess Flood
wait_queue_size => 100, # default is 100, for send message buffer size
view all matches for this distribution
view release on metacpan or search on metacpan
the child httpd init cost of StatINC. Documented.
+Made Apache::ASP Basic Authorization friendly so authentication
can be handled by ASP scripts. If AuthName and AuthType Apache
config directives are set, and a $Response->{Status} is set to
401, a user will be prompted for username/password authentication
and the entered data will show up in ServerVariables as:
$env = $Request->ServerVariables
$env->{REMOTE_USER} = $env->{AUTH_USER} = username
$env->{AUTH_PASSWD} = password
$env->{AUTH_NAME} = your realm
$env->{AUTH_TYPE} = 'Basic'
This is the same place to find auth data as if Apache had some
authentication handler deal with the auth phase separately.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Admin/Config.pm view on Meta::CPAN
anonymous CVS repository:
CVS_RSH=ssh cvs -d anonymous@cvs.rhapsodyk.net:/devel co Apache-Admin-Config
(supply an empty string as password)
CVS repository on the web:
http://www.rhapsodyk.net/cgi-bin/cvsweb/Apache-Admin-Config/
view all matches for this distribution
view release on metacpan or search on metacpan
examples/htdocs/login.pl view on Meta::CPAN
my $serverkey = '';
if (exists($dirconfig->{$auth_name . "SessionServerPass"})) {
my $serverpass = $dirconfig->{$auth_name . "SessionServerPass"};
($serverpass =~ s/^\s*([[:print:]]{8,}?)\s*$/$1/s) ||
die('error', "login.pl(): Invalid ${auth_name}SessionServerPass (must be use at least 8 printable characters\n");
($serverpass =~ /^(password|serverkey|serverpass|12345678)$/i) &&
die("login.pl: ${auth_name}SessionServerPass is $1... That is too lousy\n");
($serverkey = HashPass($serverpass)) || die("login.pl: Problem computing server key hash for $auth_name");
} elsif (exists($dirconfig->{$auth_name . "SessionServerKey"})) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/Auth/User.pm view on Meta::CPAN
##############################################################################
sub new;
sub name;
sub password;
sub password_digest;
# Implementation:
##############################################################################
sub new {
lib/Apache/Auth/User.pm view on Meta::CPAN
my ($self, @value) = @_;
$self->{name} = $value[0] if @value;
return $self->{name};
}
sub password {
my ($self, @value) = @_;
if (@value) {
$self->{password} = $value[0];
$self->{password_digest} = undef;
}
return $self->{password};
}
sub password_digest {
my ($self, @value) = @_;
if (@value) {
$self->{password_digest} = $value[0];
}
elsif (not defined($self->{password_digest})) {
$self->{password_digest} = $self->_build_password_digest();
}
return $self->{password_digest};
}
TRUE;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/AuthCAS.pm view on Meta::CPAN
my $PROD_DB_PGTIOU_TABLE = "cas_pgtiou_to_pgt";
# the user to connnect to the database with
my $DB_USER = "";
my $DEVEL_DB_USER = "develuser";
my $PROD_DB_USER = "produser";
# the password to connect to the databse with
my $DB_PASS = "";
my $DEVEL_DB_PASS = "develpass";
my $PROD_DB_PASS = "prodpass";
# whether or not we want redirect magic to remove service ticket from URL
my $DEFAULT_REMOVE_TICKET = "0";
lib/Apache/AuthCAS.pm view on Meta::CPAN
$DB_USER = $DEVEL_DB_USER;
Apache->warn("$$: CAS: initialize(): setting database user to $DB_USER") unless ($LOG_LEVEL < $LOG_INFO);
}
if ($tmp = $r->dir_config("CASDatabasePass")) {
$DB_PASS = $tmp;
Apache->warn("$$: CAS: initialize(): setting database password to $DB_PASS") unless ($LOG_LEVEL < $LOG_INFO);
} elsif ($PRODUCTION) {
$DB_PASS = $PROD_DB_PASS;
Apache->warn("$$: CAS: initialize(): setting database password to $DB_PASS") unless ($LOG_LEVEL < $LOG_INFO);
} else {
# default
$DB_PASS = $DEVEL_DB_PASS;
Apache->warn("$$: CAS: initialize(): setting database password to $DB_PASS") unless ($LOG_LEVEL < $LOG_INFO);
}
if (!$DB_HOST or !$DB_PORT or !$DB_NAME or !$DB_USER or !$DB_PASS) {
Apache->warn("$$: CAS: initialize(): database not properly configured. Please specify: 'CASDatabaseHost', 'CASDatabasePort', 'CASDatabaseName', 'CASDatabaseUser', 'CASDatabasePassword'");
}
lib/Apache/AuthCAS.pm view on Meta::CPAN
with PerlSetVar params (see below for examples).
You can configure this module by placing the devel/production settings in the
module itself. This is particular handy if you would like to make
authentication with this module available via .htaccess to users whom you would
rather not share the database username/password with.
Any options that are not set in the Apache configuration will default to the
values preconfigured in the Apache::AuthCAS module. Either explicitly override
those options that do not match your environment or set them in the module
itself.
lib/Apache/AuthCAS.pm view on Meta::CPAN
PerlSetVar CASDatabaseName "cas"
# the user to connnect to the database with
PerlSetVar CASDatabaseUser "dbuser"
# the password to connect to the databse with
PerlSetVar CASDatabasePass "dbpass"
# the name of the session table
PerlSetVar CASDatabaseSessionTable "cas_sessions"
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/AuthCASSimple.pm view on Meta::CPAN
=head1 DESCRIPTION
Apache::AuthCASSimple is a module for Apache/mod_perl. It allow you to
authentificate users trough a CAS server. It means you don't need
to give login/password if you've already be authentificate by the CAS
server, only tickets are exchanged between Web client, Apache server
and CAS server. If you not're authentificate yet, you'll be redirect
on the CAS server login form.
=head1 SYNOPSIS
view all matches for this distribution
view release on metacpan or search on metacpan
AuthChecker.pm view on Meta::CPAN
require valid-user
Parameters:
AuthUserFile - path to your passwords htpasswd-made file (REQUIRED).
MaxFailedAttempts - Maximum attempts we give user to mistype password
(OPTIONAL, default - 8).
RedirectURI - URI (not URL!) to redirect attacker then he runs out
attempts limit ((OPTIONAL, default - /).
For example: /you_are_blocked.html
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Apache/AuthCookie.pm view on Meta::CPAN
=over 4
=item 1.
The client doesn't *have* to pass the user credentials on every
subsequent access. If you're using passwords, this means that the
password can be sent on the first request only, and subsequent
requests don't need to send this (potentially sensitive) information.
This is known as "ticket-based" authentication.
=item 2.
lib/Apache/AuthCookie.pm view on Meta::CPAN
( session key cookie) ) | current request and creates sub |
(-----------------------) | request for the error document. |<-+
| Error document is a script that | |
| generates a form where the user | |
return | enters authentication | |
^------------------->| credentials (login & password). | |
/ \ False +---------------------------------+ |
/ \ | |
/ \ | |
/ \ V |
/ \ +---------------------------------+ |
lib/Apache/AuthCookie.pm view on Meta::CPAN
(---------------------)
* The session key that the client gets can be anything you want. For
example, encrypted information about the user, a hash of the
username and password (similar in function to Digest
authentication), or the user name and password in plain text
(similar in function to HTTP Basic authentication).
The only requirement is that the authen_ses_key function that you
create must be able to determine if this session_key is valid and
map it back to the originally authenticated user ID.
lib/Apache/AuthCookie.pm view on Meta::CPAN
server configuration as handled by the ->login() method - see example
in the SYNOPSIS section).
=item 2.
The various user input fields (username, passwords, etc.) must be
named 'credential_0', 'credential_1', etc. on the form. These will
get passed to your authen_cred() method.
=item 3.
lib/Apache/AuthCookie.pm view on Meta::CPAN
=back
In addition, you might want your login page to be able to tell why
the user is being asked to log in. In other words, if the user sent
bad credentials, then it might be useful to display an error message
saying that the given username or password are invalid. Also, it
might be useful to determine the difference between a user that sent
an invalid auth cookie, and a user that sent no auth cookie at all. To
cope with these situations, B<AuthCookie> will set
C<$r-E<gt>subprocess_env('AuthCookieReason')> to one of the following values.
lib/Apache/AuthCookie.pm view on Meta::CPAN
requires user programmør
=head1 ABOUT SESSION KEYS
Unlike the sample AuthCookieHandler, you have you verify the user's
login and password in C<authen_cred()>, then you do something
like:
my $date = localtime;
my $ses_key = MD5->hexhash(join(';', $date, $PID, $PAC));
view all matches for this distribution
view release on metacpan or search on metacpan
AuthCookieDBI.pm view on Meta::CPAN
PerlSetVar WhatEverDBI_DSN "DBI:mysql:database=test"
PerlSetVar WhatEverDBI_SecretKey "489e5eaad8b3208f9ad8792ef4afca73598ae666b0206a9c92ac877e73ce835c"
# These are optional, the module sets sensible defaults.
PerlSetVar WhatEverDBI_User "nobody"
PerlSetVar WhatEverDBI_Password "password"
PerlSetVar WhatEverDBI_UsersTable "users"
PerlSetVar WhatEverDBI_UserField "user"
PerlSetVar WhatEverDBI_PasswordField "password"
PerlSetVar WhatEverDBI_CryptType "none"
PerlSetVar WhatEverDBI_GroupsTable "groups"
PerlSetVar WhatEverDBI_GroupField "grp"
PerlSetVar WhatEverDBI_GroupUserField "user"
PerlSetVar WhatEverDBI_EncryptionType "none"
AuthCookieDBI.pm view on Meta::CPAN
=head1 DESCRIPTION
This module is an authentication handler that uses the basic mechanism provided
by Apache::AuthCookie with a DBI database for ticket-based protection. It
is based on two tokens being provided, a username and password, which can
be any strings (there are no illegal characters for either). The username is
used to set the remote user as if Basic Authentication was used.
On an attempt to access a protected location without a valid cookie being
provided, the module prints an HTML login form (produced by a CGI or any
other handler; this can be a static file if you want to always send people
to the same entry page when they log in). This login form has fields for
username and password. On submitting it, the username and password are looked
up in the DBI database. The supplied password is checked against the password
in the database; the password in the database can be plaintext, or a crypt()
or md5_hex() checksum of the password. If this succeeds, the user is issued
a ticket. This ticket contains the username, an issue time, an expire time,
and an MD5 checksum of those and a secret key for the server. It can
optionally be encrypted before returning it to the client in the cookie;
encryption is only useful for preventing the client from seeing the expire
time. If you wish to protect passwords in transport, use an SSL-encrypted
connection. The ticket is given in a cookie that the browser stores.
After a login the user is redirected to the location they originally wished
to view (or to a fixed page if the login "script" was really a static file).
AuthCookieDBI.pm view on Meta::CPAN
$c{DBI_user} = _dir_config_var( $r, 'DBI_User' )
|| undef;
=item C<WhatEverDBI_Password>
The password to use to access the database. This is not required
and defaults to undef.
=cut
$c{DBI_password} = _dir_config_var( $r, 'DBI_Password' )
|| undef;
=item C<WhatEverDBI_UsersTable>
The table that user names and passwords are stored in. This is not
required and defaults to 'users'.
=cut
$c{DBI_userstable} = _dir_config_var( $r, 'DBI_UsersTable' )
AuthCookieDBI.pm view on Meta::CPAN
$c{DBI_userfield} = _dir_config_var( $r, 'DBI_UserField' )
|| 'user';
=item C<WhatEverDBI_PasswordField>
The field in the above table that has the password. This is not
required and defaults to 'password'.
=cut
$c{DBI_passwordfield} = _dir_config_var( $r, 'DBI_PasswordField' )
|| 'password';
=item C<WhatEverDBI_CryptType>
What kind of hashing is used on the password field in the database. This can
be 'none', 'crypt', or 'md5'. This is not required and defaults to 'none'.
=cut
$c{DBI_crypttype} = _dir_config_var( $r, 'DBI_CryptType' )
AuthCookieDBI.pm view on Meta::CPAN
=item C<WhatEverDBI_EncryptionType>
What kind of encryption to use to prevent the user from looking at the fields
in the ticket we give them. This is almost completely useless, so don't
switch it on unless you really know you need it. It does not provide any
protection of the password in transport; use SSL for that. It can be 'none',
'des', 'idea', 'blowfish', or 'blowfish_pp'.
This is not required and defaults to 'none'.
=cut
AuthCookieDBI.pm view on Meta::CPAN
# a new session key for this user that can be stored in the cookie.
# If there is a problem, return a bogus session key.
sub authen_cred {
my ( $self, $r, @credentials ) = @_;
my ( $user, $password, @extra_credentials ) = @credentials;
my $auth_name = $r->auth_name;
( $user, $password ) = _defined_or_empty( $user, $password );
if ( !length $user ) {
$r->log_reason(
"Apache::AuthCookieDBI: no username supplied for auth realm $auth_name",
$r->uri
);
return;
}
if ( !length $password ) {
$r->log_reason(
"Apache::AuthCookieDBI: no password supplied for auth realm $auth_name",
$r->uri
);
return;
}
# get the configuration information.
my %c = _dbi_config_vars $r;
# get the crypted password from the users database for this user.
my $dbh = DBI->connect( $c{DBI_DSN}, $c{DBI_user}, $c{DBI_password} );
unless ( defined $dbh ) {
$r->log_reason(
"Apache::AuthCookieDBI: couldn't connect to $c{ DBI_DSN } for auth realm $auth_name",
$r->uri
);
return;
}
my $sth = $dbh->prepare( <<"EOS" );
SELECT $c{ DBI_passwordfield }
FROM $c{ DBI_userstable }
WHERE $c{ DBI_userfield } = ?
EOS
$sth->execute($user);
my ($crypted_password) = $sth->fetchrow_array;
unless ( defined $crypted_password ) {
$r->log_reason(
"Apache::AuthCookieDBI: couldn't select password from $c{ DBI_DSN }, $c{ DBI_userstable }, $c{ DBI_userfield } for user $user for auth realm $auth_name",
$r->uri
);
return;
}
# now return unless the passwords match.
if ( lc $c{DBI_crypttype} eq 'none' ) {
unless ( $password eq $crypted_password ) {
$r->log_reason(
"Apache::AuthCookieDBI: plaintext passwords didn't match for user $user for auth realm $auth_name",
$r->uri
);
return;
}
}
elsif ( lc $c{DBI_crypttype} eq 'crypt' ) {
my $salt = substr $crypted_password, 0, 2;
unless ( crypt( $password, $salt ) eq $crypted_password ) {
$r->log_reason(
"Apache::AuthCookieDBI: crypted passwords didn't match for user $user for auth realm $auth_name",
$r->uri
);
return;
}
}
elsif ( lc $c{DBI_crypttype} eq 'md5' ) {
unless ( md5_hex($password) eq $crypted_password ) {
$r->log_reason(
"Apache::AuthCookieDBI: MD5 passwords didn't match for user $user for auth realm $auth_name",
$r->uri
);
return;
}
}
AuthCookieDBI.pm view on Meta::CPAN
my %c = _dbi_config_vars $r;
my $user = $r->connection->user;
# See if we have a row in the groups table for this user/group.
my $dbh = DBI->connect( $c{DBI_DSN}, $c{DBI_user}, $c{DBI_password} );
unless ( defined $dbh ) {
$r->log_reason(
"Apache::AuthCookieDBI: couldn't connect to $c{ DBI_DSN } for auth realm $auth_name",
$r->uri
);
AuthCookieDBI.pm view on Meta::CPAN
=head1 DATABASE SCHEMAS
For this module to work, the database tables must be laid out at least somewhat
according to the following rules: the user field must be a primary key
so there is only one row per user; the password field must be NOT NULL. If
you're using MD5 passwords the password field must be 32 characters long to
allow enough space for the output of md5_hex(). If you're using crypt()
passwords you need to allow 13 characters.
An minimal CREATE TABLE statement might look like:
CREATE TABLE users (
user VARCHAR(16) PRIMARY KEY,
password VARCHAR(32) NOT NULL
)
For the groups table, the access table is actually going to be a join table
between the users table and a table in which there is one row per group
if you have more per-group data to store; if all you care about is group
view all matches for this distribution
view release on metacpan or search on metacpan
AuthCookie.pm view on Meta::CPAN
}
} else {
#$r->subprocess_env('AuthCookieReason', 'no_cookie');
# Instead of 'no_cookie, let's return something more useful.
$r->subprocess_env('AuthCookieReason', 'Please enter your user name and password.');
}
# They aren't authenticated, and they tried to get a protected
# document. Send them the authen form.
return $auth_type->login_form;
AuthCookie.pm view on Meta::CPAN
=over 4
=item 1.
The client doesn't *have* to pass the user credentials on every
subsequent access. If you're using passwords, this means that the
password can be sent on the first request only, and subsequent
requests don't need to send this (potentially sensitive) information.
This is known as "ticket-based" authentication.
=item 2.
AuthCookie.pm view on Meta::CPAN
( session key cookie) ) | current request and creates sub |
(-----------------------) | request for the error document. |<-+
| Error document is a script that | |
| generates a form where the user | |
return | enters authentication | |
^------------------->| credentials (login & password). | |
/ \ False +---------------------------------+ |
/ \ | |
/ \ | |
/ \ V |
/ \ +---------------------------------+ |
AuthCookie.pm view on Meta::CPAN
(---------------------)
* The session key that the client gets can be anything you want. For
example, encrypted information about the user, a hash of the
username and password (similar in function to Digest
authentication), or the user name and password in plain text
(similar in function to HTTP Basic authentication).
The only requirement is that the authen_ses_key function that you
create must be able to determine if this session_key is valid and
map it back to the originally authenticated user ID.
AuthCookie.pm view on Meta::CPAN
server configuration as handled by the ->login() method - see example
in the SYNOPSIS section).
=item 2.
The various user input fields (username, passwords, etc.) must be
named 'credential_0', 'credential_1', etc. on the form. These will
get passed to your authen_cred() method.
=item 3.
AuthCookie.pm view on Meta::CPAN
you, you have to handle it yourself.
=head1 ABOUT SESSION KEYS
Unlike the sample AuthCookieHandler, you have you verify the user's
login and password in C<authen_cred()>, then you do something
like:
my $date = localtime;
my $ses_key = MD5->hexhash(join(';', $date, $PID, $PAC));
view all matches for this distribution
view release on metacpan or search on metacpan
AuthCookieLDAP.pm view on Meta::CPAN
=head1 DESCRIPTION
This module is an authentication handler that uses the basic mechanism provided
by Apache::AuthCookie with a LDAP database for ticket-based protection. It
is based on two tokens being provided, a username and password, which can
be any strings (there are no illegal characters for either). The username is
used to set the remote user as if Basic Authentication was used.
On an attempt to access a protected location without a valid cookie being
provided, the module prints an HTML login form (produced by a CGI or any
other handler; this can be a static file if you want to always send people
to the same entry page when they log in). This login form has fields for
username and password. On submitting it, the username and password are looked
up in the LDAP database. If this succeeds, the user is issued
a ticket. This ticket contains the username, an issue time, an expire time,
and an MD5 checksum of those and a secret key for the server. It can
optionally be encrypted before returning it to the client in the cookie;
encryption is only useful for preventing the client from seeing the expire
time. If you wish to protect passwords in transport, use an SSL-encrypted
connection. The ticket is given in a cookie that the browser stores.
After a login the user is redirected to the location they originally wished
to view (or to a fixed page if the login "script" was really a static file).
AuthCookieLDAP.pm view on Meta::CPAN
=item C<WhatEverLDAP_EncryptionType>
What kind of encryption to use to prevent the user from looking at the fields
in the ticket we give them. This is almost completely useless, so don't
switch it on unless you really know you need it. It does not provide any
protection of the password in transport; use SSL for that. It can be 'none',
'des', 'idea', 'blowfish', or 'blowfish_pp'.
This is not required and defaults to 'none'.
=cut
AuthCookieLDAP.pm view on Meta::CPAN
$c{ DBI_user } = _dir_config_var( $r, 'DBI_User')
|| undef;
=item C<WhatEverDBI_Password>
The password to use to access the database. This is not required
and defaults to undef.
=cut
$c{ DBI_password } = _dir_config_var( $r, 'DBI_Password' )
|| undef;
=item C<WhatEverDBI_GroupsTable>
AuthCookieLDAP.pm view on Meta::CPAN
unless ( $user =~ /^.+$/ ) {
$r->log_reason( "Apache::AuthCookieLDAP: no username supplied for auth realm $auth_name", $r->uri );
return 'bad';
}
# Password goes in credential_1
my $password = $credentials[ 1 ];
unless ( $password =~ /^.+$/ ) {
$r->log_reason( "Apache::AuthCookieLDAP: no password supplied for auth realm $auth_name", $r->uri );
return 'bad';
}
# get the configuration information.
my %c = _dbi_config_vars $r;
AuthCookieLDAP.pm view on Meta::CPAN
# Take the first user
my $entry = $mess->first_entry;
my $dn = $entry->dn;
# Bind as the user we're authenticating
$mess = $con->bind($dn, password => $password);
unless ($mess->code == LDAP_SUCCESS) {
$r->log_reason("User $user har wrong password", $r->uri);
return 'bad';
}
$con->unbind;
AuthCookieLDAP.pm view on Meta::CPAN
my $user = $r->connection->user;
# See if we have a row in the groups table for this user/group.
my $dbh = DBI->connect( $c{ DBI_DSN },
$c{ DBI_user }, $c{ DBI_password } );
unless ( defined $dbh ) {
$r->log_reason( "Apache::AuthCookieDBI: couldn't connect to $c{ DBI_DSN } for auth realm $auth_name", $r->uri );
return undef;
}
view all matches for this distribution