Skip to content

Commit 74fdd00

Browse files
authored
Merge pull request #186 from timlegge/authn_request_issue
Fix AuthnRequest name space typo issue
2 parents 4082afa + e04cc05 commit 74fdd00

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

Diff for: lib/Net/SAML2.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33
package Net::SAML2;
4-
our $VERSION = "0.71";
4+
our $VERSION = "0.72";
55

66
require 5.012;
77

Diff for: lib/Net/SAML2/Protocol/AuthnRequest.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Returns the AuthnRequest as XML.
192192
=cut
193193

194194
my $samlp = ['samlp' => URN_PROTOCOL];
195-
my $saml = ['samlp' => URN_ASSERTION];
195+
my $saml = ['saml' => URN_ASSERTION];
196196

197197
sub as_xml {
198198
my ($self) = @_;

Diff for: t/25-verify-authn-post-sign_xml.t

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use strict;
2+
use warnings;
3+
use Net::SAML2;
4+
use MIME::Base64 qw/decode_base64/;
5+
use XML::LibXML;
6+
7+
use Test::Lib;
8+
use Test::Net::SAML2;
9+
my $sp = net_saml2_sp();
10+
11+
my $metadata = path('t/idp-metadata.xml')->slurp;
12+
13+
my $idp = Net::SAML2::IdP->new_from_xml(
14+
xml => $metadata,
15+
cacert => 't/cacert.pem'
16+
);
17+
18+
my $authn = $sp->authn_request(
19+
$idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'),
20+
$idp->format || '', # default format.
21+
)->as_xml();
22+
23+
my $post = $sp->sp_post_binding($idp, 'SAMLRequest');
24+
25+
my $signed = decode_base64($post->sign_xml($authn));
26+
27+
my $dom = XML::LibXML->load_xml( string => $signed );
28+
29+
my $parser = XML::LibXML::XPathContext->new($dom);
30+
$parser->registerNs('saml2p', 'urn:oasis:names:tc:SAML:2.0:protocol');
31+
$parser->registerNs('saml2', 'urn:oasis:names:tc:SAML:2.0:assertion');
32+
$parser->registerNs('dsig', 'http://www.w3.org/2000/09/xmldsig#');
33+
ok($parser->exists('//dsig:Signature'), "The XML is now signed");
34+
35+
done_testing;

0 commit comments

Comments
 (0)