Ok, here is the patch for solution #1:
--- perl/Net-OpenID-Server/lib/Net/OpenID/Server.pm (revision 160)
+++ perl/Net-OpenID-Server/lib/Net/OpenID/Server.pm (working copy)
@@ -285,13 +285,14 @@
push @sign, $k;
}
- # include the list of all fields we'll be signing
+ # since signing of empty fields is not well defined,
+ # remove such fields from the list of fields to be signed
+ @sign = grep { defined $arg{$_} && $arg{$_} ne '' } @sign;
$arg{signed} = join(",", @sign);
my @arg; # arguments we'll append to the URL
my $token_contents = "";
foreach my $f (@sign) {
- next unless defined $arg{$f};
$token_contents .= "$f:$arg{$f}\n";
push @arg, "openid.$f" => $arg{$f};
delete $arg{$f};
And here is the patch for Consumer.
Specification of OpenID 1.1 doesn't list fields that must be signed,
so the check is for version 2.0 only.
--- perl/Net-OpenID-Consumer/lib/Net/OpenID/Consumer.pm (revision 160)
+++ perl/Net-OpenID-Consumer/lib/Net/OpenID/Consumer.pm (working copy)
@@ -777,7 +777,28 @@
my $assoc = Net::OpenID::Association::handle_assoc($self,
$server, $assoc_handle);
my %signed_fields; # key (without openid.) -> value
-
+
+ # Specificaiton v. 2.0 has strict requirements on which keys must
be signed
+ if ($self->_message_version>=2) {
+ my %signed_fields = map {$_ => 1} split /,/, $signed;
+ my %unsigned_fields;
+ # these fields must be signed unconditionally
+ foreach my $f (qw/op_endpoint return_to response_nonce
assoc_handle/) {
+ $unsigned_fields{$f}++ if !$signed_fields{$f};
+ }
+ # these fields must be signed if present
+ foreach my $f (qw/claimed_id identity/) {
+ next unless $self->args("openid.$f");
+ $unsigned_fields{$f}++ if !$signed_fields{$f};
+ }
+ if (%unsigned_fields) {
+ return $self->_fail(
+ "unsigned_field",
+ "Field(s) must be signed: " . join(", ", keys
%unsigned_fields)
+ );
+ }
+ }
+
if ($assoc) {
$self->_debug("verified_identity: verifying with found
association");
I've tested the new patches in the following use-cases:
patched Consumer accepts the Google OpenID and ID from Net::OpenID
Perl server
patched Server works with Net::OpenID consumer and with
blogger.com
(doesn't work without the patch!)
Martin, we need the changes (at least server part) for LiveJournal, it
would be nice if you could include them into trunk soon.
I can send the patch as an e-mail attachment, or whatever you'll find
appropriate.