Skip to content

Commit 237ef74

Browse files
committed
NameId Format is optional in the LogoutRequest
1 parent a8ee006 commit 237ef74

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/Net/SAML2/Protocol/LogoutRequest.pm

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ sent regardless
6363

6464
has 'session' => (isa => NonEmptySimpleStr, is => 'ro', required => 1);
6565
has 'nameid' => (isa => NonEmptySimpleStr, is => 'ro', required => 1);
66-
has 'nameid_format' => (isa => NonEmptySimpleStr, is => 'ro', required => 1);
66+
has 'nameid_format' => (isa => NonEmptySimpleStr, is => 'ro', required => 0);
6767
has 'destination' => (isa => NonEmptySimpleStr, is => 'ro', required => 0);
6868

6969
=head2 new_from_xml( ... )
@@ -91,13 +91,19 @@ sub new_from_xml {
9191
$xpath->registerNs('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
9292
$xpath->registerNs('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
9393

94-
my $self = $class->new(
94+
my %params = (
9595
id => $xpath->findvalue('/samlp:LogoutRequest/@ID'),
9696
session => $xpath->findvalue('/samlp:LogoutRequest/samlp:SessionIndex'),
9797
issuer => $xpath->findvalue('/samlp:LogoutRequest/saml:Issuer'),
9898
nameid => $xpath->findvalue('/samlp:LogoutRequest/saml:NameID'),
99-
nameid_format => $xpath->findvalue('/samlp:LogoutRequest/saml:NameID/@Format'),
100-
destination => $xpath->findvalue('/samlp:LogoutRequest/saml:NameID/@NameQualifier'),
99+
destination => $xpath->findvalue('/samlp:LogoutRequest/@Destination'),
100+
);
101+
102+
my $nameid_format = $xpath->findvalue('/samlp:LogoutRequest/saml:NameID/@Format');
103+
if ( $nameid_format ne '' ) { $params{nameid_format} = $nameid_format; }
104+
105+
my $self = $class->new(
106+
%params
101107
);
102108

103109
return $self;

0 commit comments

Comments
 (0)