Skip to content
Browse files

Trying different logic for LOGIN in the client.

I'm still not sure about this change.
I'm also pondering about renaming set_success to something less ambiguous.
We might need better semantic in the client, where success of a negotiation
is communicated to the client thru specific protocol means sometimes.
  • Loading branch information...
1 parent dd52c33 commit 9af51b5b61af0fe7cf0c57a5dd22f51bcf08b167 @yannk yannk committed with gbarr Jan 16, 2009
Showing with 25 additions and 7 deletions.
  1. +4 −0 lib/Authen/SASL/Perl.pm
  2. +19 −5 lib/Authen/SASL/Perl/LOGIN.pm
  3. +2 −2 t/login.t
View
4 lib/Authen/SASL/Perl.pm
@@ -70,6 +70,10 @@ sub need_step {
return $self->{need_step};
}
+## I think I need to rename that to end()?
+## It doesn't mean that SASL is successful, but that
+## that the negotiation is over, no more step necessary
+## at least for the client
sub set_success {
my $self = shift;
$self->{need_step} = 0;
View
24 lib/Authen/SASL/Perl/LOGIN.pm
@@ -24,17 +24,31 @@ sub mechanism { 'LOGIN' }
sub client_start {
my $self = shift;
+ $self->{stage} = 0;
'';
}
sub client_step {
my ($self, $string) = @_;
- $string =~ /password/i
- ? do { $self->set_success; $self->_call('pass') }
- : $string =~ /username/i
- ? $self->_call('user')
- : '';
+ # XXX technically this is wrong. I might want to change that.
+ # spec say it's "staged" and that the content of the challenge doesn't
+ # matter
+ # actually, let's try
+ my $stage = ++$self->{stage};
+ if ($stage == 1) {
+ return $self->_call('user');
+ }
+ elsif ($stage == 2) {
+ return $self->_call('pass');
+ }
+ elsif ($stage == 3) {
+ $self->set_success;
+ return;
+ }
+ else {
+ return $self->set_error("Invalid sequence");
+ }
}
sub server_start {
View
4 t/login.t
@@ -22,8 +22,8 @@ is($conn->mechanism, 'LOGIN', 'conn mechanism');
is($conn->client_start, '', 'client_start');
-is($conn->client_step("xyz"), '', 'client_step xyz');
-
is($conn->client_step("username"), 'gbarr', 'client_step username');
is($conn->client_step("password"), 'fred', 'client_step password');
+
+## XXX TODO check for success and extra steps

0 comments on commit 9af51b5

Please sign in to comment.
Something went wrong with that request. Please try again.