Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow setting of the desired NameIDFormat

  • Loading branch information...
commit 95b98cbe2958c0f3e6577aa9c069ca70286a51e2 1 parent 5ee0619
Chris Andrews authored
View
6 lib/Net/SAML2/Protocol/AuthnRequest.pm
@@ -2,6 +2,7 @@ package Net::SAML2::Protocol::AuthnRequest;
use Moose;
use MooseX::Types::Moose qw /Str /;
use MooseX::Types::URI qw/ Uri /;
+use MooseX::Types::Common::String qw/ NonEmptySimpleStr /;
with 'Net::SAML2::Role::ProtocolMessage';
@@ -34,6 +35,7 @@ Arguments:
has 'issuer' => (isa => Uri, is => 'ro', required => 1, coerce => 1);
has 'destination' => (isa => Uri, is => 'ro', required => 1, coerce => 1);
+has 'nameid_format' => (isa => NonEmptySimpleStr, is => 'ro', required => 1);
=head2 as_xml()
@@ -63,10 +65,10 @@ sub as_xml {
$x->NameIDPolicy(
$samlp,
{ AllowCreate => '1',
- Format => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent' },
+ Format => $self->nameid_format },
)
)
);
}
-1;
+__PACKAGE__->meta->make_immutable;
View
3  lib/Net/SAML2/SP.pm
@@ -69,12 +69,13 @@ given destination, which should be the identity URI of the IdP.
=cut
sub authn_request {
- my ($self, $destination) = @_;
+ my ($self, $destination, $nameid_format) = @_;
my $authnreq = Net::SAML2::Protocol::AuthnRequest->new(
issueinstant => DateTime->now,
issuer => $self->id,
destination => $destination,
+ nameid_format => $nameid_format,
);
return $authnreq;
View
5 t/06-redirect-binding.t
@@ -25,7 +25,10 @@ ok($idp);
my $sso_url = $idp->sso_url($idp->binding('redirect'));
ok($sso_url);
-my $authnreq = $sp->authn_request($idp->entityid)->as_xml;
+my $authnreq = $sp->authn_request(
+ $idp->entityid,
+ $idp->format('persistent'),
+)->as_xml;
ok($authnreq);
my $redirect = $sp->sso_redirect_binding($idp, 'SAMLRequest');
View
1  t/09-authn-request.t
@@ -6,6 +6,7 @@ use Net::SAML2;
my $ar = Net::SAML2::Protocol::AuthnRequest->new(
issuer => 'http://some/sp',
destination => 'http://some/idp',
+ nameid_format => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
);
ok($ar);
my $xml = $ar->as_xml;
View
5 testapp/lib/Saml2Test.pm
@@ -26,7 +26,10 @@ get '/' => sub {
get '/login' => sub {
my $idp = _idp();
my $sp = _sp();
- my $authnreq = $sp->authn_request($idp->entityid)->as_xml;
+ my $authnreq = $sp->authn_request(
+ $idp->entityid,
+ $idp->format('persistent'),
+ )->as_xml;
my $redirect = $sp->sso_redirect_binding($idp, 'SAMLRequest');
my $url = $redirect->sign($authnreq);
Please sign in to comment.
Something went wrong with that request. Please try again.