Skip to content

Commit c815c58

Browse files
committed
testapp: Don't show POST button for login if IdP does not support
1 parent c093420 commit c815c58

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

xt/testapp/lib/Saml2Test.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ sub get_sso_post_url {
100100
load_config($idp_name);
101101
my $idp = _idp();
102102

103+
if ( ! defined $idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST') ) {
104+
return "NotSupported";
105+
}
106+
103107
return $idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST');
104108
}
105109

@@ -108,6 +112,9 @@ sub get_login_post {
108112

109113
load_config($idp_name);
110114
my $idp = _idp();
115+
if ( ! defined $idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST') ) {
116+
return "NotSupported";
117+
}
111118
my $sp = _sp();
112119

113120
my %params = (
@@ -137,6 +144,9 @@ sub get_logout_post {
137144

138145
load_config($idp_name);
139146
my $idp = _idp();
147+
if ( ! defined $idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST') ) {
148+
return "NotSupported";
149+
}
140150
my $sp = _sp();
141151

142152
my %logout_params = (

xt/testapp/views/index.tt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
<% FOREACH provider IN idps %>
55
<tr>
66
<td><b><a href ="/login?idp=<% provider.idp %>"><% provider.idp %></a></b></td>
7-
<td><form action="<% get_sso_post_url(provider.idp) %>" method="POST">
7+
<td><% if get_sso_post_url(provider.idp) != 'NotSupported' %>
8+
<form action="<% get_sso_post_url(provider.idp) %>" method="POST">
89
<input type="hidden" name="SAMLRequest" value="<% get_login_post(provider.idp) %>">
910
<input type="hidden" name="RelayState" value="<% provider.idp %>">
1011
<input type="submit" value="POST">
1112
</form>
12-
</td>
13+
<% end %></td>
1314
<% if provider.metadata == 'missing' %>metadata missing <% end %>
1415
<% if provider.cacert == 'missing' %>cacert missing<% end %>
1516
</tr>

0 commit comments

Comments
 (0)