Skip to content

Commit 1cd0003

Browse files
committed
Net::SAML2::SP configurable values for metadata
1 parent 07b68dd commit 1cd0003

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

lib/Net/SAML2/SP.pm

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ has 'cert' => (isa => 'Str', is => 'ro', required => 1);
9898
has 'key' => (isa => 'Str', is => 'ro', required => 1);
9999
has 'cacert' => (isa => 'Maybe[Str]', is => 'ro', required => 1);
100100

101+
has 'error_url' => (isa => 'Str', is => 'ro', required => 1);
102+
has 'slo_url_soap' => (isa => 'Str', is => 'ro', required => 1);
103+
has 'slo_url_redirect' => (isa => 'Str', is => 'ro', required => 1);
104+
has 'slo_url_post' => (isa => 'Str', is => 'ro', required => 1);
105+
has 'acs_url_post' => (isa => 'Str', is => 'ro', required => 1);
106+
has 'acs_url_artifact' => (isa => 'Str', is => 'ro', required => 1);
107+
101108
has 'org_name' => (isa => 'Str', is => 'ro', required => 1);
102109
has 'org_display_name' => (isa => 'Str', is => 'ro', required => 1);
103110
has 'org_contact' => (isa => 'Str', is => 'ro', required => 1);
@@ -316,7 +323,7 @@ sub metadata {
316323
$md,
317324
{ AuthnRequestsSigned => defined($self->authnreq_signed) ? $self->authnreq_signed : '1',
318325
WantAssertionsSigned => defined($self->want_assertions_signed) ? $self->want_assertions_signed : '1',
319-
errorURL => $self->url . '/saml/error',
326+
errorURL => $self->url . $self->error_url,
320327
protocolSupportEnumeration => 'urn:oasis:names:tc:SAML:2.0:protocol' },
321328
$x->KeyDescriptor(
322329
$md,
@@ -336,29 +343,29 @@ sub metadata {
336343
$x->SingleLogoutService(
337344
$md,
338345
{ Binding => 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP',
339-
Location => $self->url . '/saml/slo-soap' },
346+
Location => $self->url . $self->slo_url_soap },
340347
),
341348
$x->SingleLogoutService(
342349
$md,
343350
{ Binding => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
344-
Location => $self->url . '/saml/sls-redirect-response' },
351+
Location => $self->url . $self->slo_url_redirect },
345352
),
346353
$x->SingleLogoutService(
347354
$md,
348355
{ Binding => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
349-
Location => $self->url . '/saml/sls-post-response' },
356+
Location => $self->url . $self->slo_url_post },
350357
),
351358
$x->AssertionConsumerService(
352359
$md,
353360
{ Binding => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
354-
Location => $self->url . '/saml/consumer-post',
361+
Location => $self->url . $self->acs_url_post,
355362
index => '1',
356363
isDefault => 'true' },
357364
),
358365
$x->AssertionConsumerService(
359366
$md,
360367
{ Binding => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
361-
Location => $self->url . '/saml/consumer-artifact',
368+
Location => $self->url . $self->acs_url_artifact,
362369
index => '2',
363370
isDefault => 'false' },
364371
),

t/lib/Test/Net/SAML2/Util.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ sub net_saml2_sp {
4242
org_display_name => 'Test',
4343
org_contact => 'test@example.com',
4444
org_url => 'http://www.example.com',
45+
slo_url_soap => '/slo-soap',
46+
slo_url_redirect => '/sls-redirect-response',
47+
slo_url_post => '/sls-post-response',
48+
acs_url_post => '/consumer-post',
49+
acs_url_artifact => '/consumer-artifact',
50+
org_name => 'Net::SAML2 Saml2Test',
51+
org_display_name => 'Saml2Test app for Net::SAML2',
52+
org_contact => 'saml2test@example.com',
53+
error_url => '/error',
4554
authnreq_signed => '0',
4655
want_assertions_signed => '0',
4756
@_,

xt/testapp/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ url: "https://netsaml2-testapp.local"
88
cert: "sign-certonly.pem"
99
key: "sign-nopw-cert.pem"
1010
cacert: "saml_cacert.pem"
11+
slo_url_soap: "/slo-soap"
12+
slo_url_redirect: "/sls-redirect-response"
13+
slo_url_post: "/sls-post-response"
14+
acs_url_post: "/consumer-post"
15+
acs_url_artifact: "/consumer-artifact"
16+
org_name: "Net::SAML2 Saml2Test"
17+
org_display_name: "Saml2Test app for Net::SAML2"
18+
org_contact: "saml2test@example.com"
19+
error_url: "/error"

xt/testapp/lib/Saml2Test.pm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,16 @@ sub _sp {
201201
cert => config->{cert},
202202
key => config->{key},
203203
cacert => config->{cacert},
204+
slo_url_soap => config->{slo_url_soap},
205+
slo_url_redirect => config->{slo_url_redirect},
206+
slo_url_post => config->{slo_url_post},
207+
acs_url_post => config->{acs_url_post},
208+
acs_url_artifact => config->{acs_url_artifact},
209+
error_url => config->{error_url},
204210

205-
org_name => 'Net::SAML2 Saml2Test',
206-
org_display_name => 'Saml2Test app for Net::SAML2',
207-
org_contact => 'saml2test@example.com',
211+
org_name => config->{org_name},
212+
org_display_name => config->{org_display_name},
213+
org_contact => config->{org_contact},
208214
);
209215
return $sp;
210216
}

0 commit comments

Comments
 (0)