Skip to content

Commit 7a0f526

Browse files
authored
Merge pull request #204 from waterkip/deprecation-id-in-sp
Add deprecation warning to id() method
2 parents 99bb04c + 35c8b65 commit 7a0f526

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

lib/Net/SAML2/SP.pm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,14 @@ Consumer Services.
162162

163163
has 'url' => (isa => Uri, is => 'ro', required => 1, coerce => 1);
164164

165-
has 'id' => (isa => XsdID, is => 'ro', builder => '_build_id');
166-
has 'issuer' => (isa => 'Str', is => 'ro', required => 1);
165+
has '_id' => (
166+
isa => XsdID,
167+
is => 'ro',
168+
builder => '_build_id',
169+
init_arg => 'id'
170+
);
171+
172+
has 'issuer' => (isa => 'Str', is => 'ro', required => 1);
167173

168174
has 'cert' => (isa => 'Str', is => 'ro', required => 1, predicate => 'has_cert');
169175
has 'key' => (isa => 'Str', is => 'ro', required => 1);
@@ -298,6 +304,14 @@ sub _build_id {
298304
return Net::SAML2::Util::generate_id();
299305
}
300306

307+
sub id {
308+
my $self = shift;
309+
Net::SAML2::Util::deprecation_warning
310+
"id() has been renamed to issuer()";
311+
return $self->issuer;
312+
}
313+
314+
301315
sub _build_encryption_key_text {
302316
my ($self) = @_;
303317

@@ -590,7 +604,7 @@ sub generate_metadata {
590604
$md,
591605
{
592606
entityID => $self->issuer,
593-
ID => $self->id,
607+
ID => $self->_id,
594608
},
595609
$x->SPSSODescriptor(
596610
$md,

lib/Net/SAML2/Util.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sub generate_id {
1919
}
2020

2121
sub deprecation_warning {
22-
warn "NET::SAML2 deprecation warning: " . shift . "\n";
22+
warn "Net::SAML2 deprecation warning: " . shift . "\n";
2323
}
2424

2525

t/02-create-sp.t

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,18 @@ use URN::OASIS::SAML2 qw(:bindings :urn);
490490
is($child[1]->getAttribute('isRequired'), '1', ".. and requiredness");
491491
}
492492

493+
{
494+
my $sp = net_saml2_sp();
495+
496+
my @warns;
497+
local $SIG{__WARN__} = sub { push(@warns, shift); };
498+
my $id = $sp->id;
499+
is($id, $sp->issuer, "id is still the issuer");
500+
cmp_deeply(
501+
\@warns,
502+
["Net::SAML2 deprecation warning: id() has been renamed to issuer()\n"],
503+
"We have our deprecation warning"
504+
);
505+
}
506+
493507
done_testing;

t/09-authn-request.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ $override->override('Net::SAML2::Protocol::AuthnRequest::_build_id' =>
174174
is_passive => 0,
175175
);
176176

177-
my $req = $sp->authn_request($sp->id, '', %params,);
177+
my $req = $sp->authn_request($sp->issuer, '', %params,);
178178

179179
my $xp = get_xpath(
180180
$req->as_xml,

0 commit comments

Comments
 (0)