Skip to content

Commit

Permalink
Merge pull request #218 from timlegge/revert_substatus
Browse files Browse the repository at this point in the history
Revert and standardize substatus spelling
  • Loading branch information
waterkip committed Apr 21, 2024
2 parents 06b195c + bbb127d commit 478ff3d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
12 changes: 6 additions & 6 deletions lib/Net/SAML2/Object/Response.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ the status is successful you can grab an assertion and continue your flow.
warn "Got a response but isn't successful";
my $status = $response->status;
my $sub_status = $response->sub_status;
my $substatus = $response->substatus;
warn "We got a $status back with the following sub status $sub_status";
warn "We got a $status back with the following sub status $substatus";
}
else {
$response->to_assertion(
Expand All @@ -57,7 +57,7 @@ the status is successful you can grab an assertion and continue your flow.
Returns the status of the response
=head2 sub_status
=head2 substatus
Returns the sub status of the response
Expand All @@ -80,11 +80,11 @@ has status => (
required => 1,
);

has sub_status => (
has substatus => (
is => 'ro',
isa => 'Str',
required => 0,
predicate => 'has_sub_status',
predicate => 'has_substatus',
);

has assertions => (
Expand Down Expand Up @@ -134,7 +134,7 @@ sub new_from_xml {
return $self->new(
dom => $xml,
status => $status,
$substatus ? ( sub_status => $substatus) : (),
$substatus ? ( substatus => $substatus) : (),
issuer => $xpath->findvalue('saml:Issuer', $response),
id => $response->getAttribute('ID'),
in_response_to => $response->getAttribute('InResponseTo'),
Expand Down
6 changes: 3 additions & 3 deletions lib/Net/SAML2/Protocol/Assertion.pm
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ sub new_from_xml {

my $status_node = $nodeset->get_node(1);
my $status = $status_node->getAttribute('Value');
my $sub_status;
my $substatus;

if (my $s = first { $_->isa('XML::LibXML::Element') } $status_node->childNodes) {
$sub_status = $s->getAttribute('Value');
$substatus = $s->getAttribute('Value');
}

my $self = $class->new(
Expand All @@ -231,7 +231,7 @@ sub new_from_xml {
xpath => $xpath,
in_response_to => $xpath->findvalue('//saml:Subject/saml:SubjectConfirmation/saml:SubjectConfirmationData/@InResponseTo'),
response_status => $status,
$sub_status ? (response_substatus => $sub_status) : (),
$substatus ? (response_substatus => $substatus) : (),
$authnstatement ? (authnstatement => $authnstatement) : (),
);

Expand Down
23 changes: 3 additions & 20 deletions lib/Net/SAML2/Protocol/LogoutResponse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ IdP's identity URI
Response status (required)
=item B<sub_status>
=item B<substatus>
The sub status
Expand All @@ -60,7 +60,7 @@ Request ID we're responding to (required);
=cut

has 'status' => (isa => 'Str', is => 'ro', required => 1);
has 'sub_status' => (isa => 'Str', is => 'ro', required => 0);
has 'substatus' => (isa => 'Str', is => 'ro', required => 0);
has '+in_response_to' => (required => 1);

# Remove response_to/substatus after 6 months from now (april 18th 2024)
Expand All @@ -75,11 +75,6 @@ around BUILDARGS => sub {
"Please use in_response_to instead of response_to");
}

if (my $s = delete $args{substatus}) {
$args{sub_status} = $s;
deprecation_warning(
"Please use in_response_to instead of response_to");
}
return $self->$orig(%args);
};

Expand All @@ -95,18 +90,6 @@ sub response_to {
return $self->in_response_to;
}

=head2 substatus()
Deprecated use B<sub_status>
=cut

sub substatus {
my $self = shift;
deprecation_warning("Please use sub_status instead of substatus");
return $self->sub_status;
}

=head2 new_from_xml( ... )
Create a LogoutResponse object from the given XML.
Expand Down Expand Up @@ -139,7 +122,7 @@ sub new_from_xml {
session => $xpath->findvalue('/samlp:LogoutResponse/samlp:SessionIndex'),
issuer => $xpath->findvalue('/samlp:LogoutResponse/saml:Issuer'),
status => $xpath->findvalue('/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/@Value'),
sub_status => $xpath->findvalue('/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/samlp:StatusCode/@Value'),
substatus => $xpath->findvalue('/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/samlp:StatusCode/@Value'),
);

return $self;
Expand Down
2 changes: 1 addition & 1 deletion t/29-response.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sub get_object {
ok(!$response->has_assertions, "We don't have an assertion");
ok(!$response->success, "Unsuccessful response");
is($response->status, STATUS_RESPONDER(), "... because its a status:Responder");
is($response->sub_status, STATUS_AUTH_FAILED(), "... and substatus is also correct");
is($response->substatus, STATUS_AUTH_FAILED(), "... and substatus is also correct");
}


Expand Down

0 comments on commit 478ff3d

Please sign in to comment.