Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed PLAIN callback, I left out my initial test stuff

  • Loading branch information...
commit 46252c342f91c63eeb3a8b875c8db327b70f1170 1 parent ca9bde6
@yannk yannk authored gbarr committed
Showing with 27 additions and 11 deletions.
  1. +10 −7 lib/Authen/SASL/Perl/PLAIN.pm
  2. +17 −4 t/server/plain.t
View
17 lib/Authen/SASL/Perl/PLAIN.pm
@@ -48,10 +48,12 @@ sub server_start {
my %parts;
@parts{@tokens} = split "\0", $challenge, scalar @tokens;
- for (@tokens) {
- return $self->set_error("Credentials don't match")
- unless (($parts{$_} || "" ) eq ($self->_call($_) || ""));
- }
+ my $expected_pass = $self->_call('pass', $parts{user}, $parts{authname});
+ return $self->set_error("Credentials don't match")
+ unless defined $expected_pass;
+ return $self->set_error("Credentials don't match")
+ unless $expected_pass eq ($parts{pass} || "");
+
$self->set_success;
return 1;
}
@@ -89,15 +91,16 @@ The callbacks used are:
=item authname
-The authorization id to use after successful authentication
+The authorization id to use after successful authentication (client)
=item user
-The username to be used for authentication
+The username to be used for authentication (client)
=item pass
-The user's password to be used for authentication
+The user's password to be used for authentication.
+For the server,
=back
View
21 t/server/plain.t
@@ -5,13 +5,26 @@ use Test::More tests => 42;
use Authen::SASL qw(Perl);
use_ok('Authen::SASL::Perl::PLAIN');
-my $authname;
+my %creds = (
+ default => {
+ yann => "maelys",
+ YANN => "MAELYS",
+ },
+ none => {
+ yann => "maelys",
+ YANN => "MAELYS",
+ },
+);
+
my %params = (
mechanism => 'PLAIN',
callback => {
- user => 'yann',
- pass => 'maelys',
- authname => sub { $authname },
+ pass => sub {
+ my $self = shift;
+ my ($username, $authzid) = @_;
+ return unless $username;
+ return $creds{$autzid || "default"}{$username};
+ },
},
);
Please sign in to comment.
Something went wrong with that request. Please try again.