Shibboleth variables and coding examples

Because of the diversity of applications, we’re only providing code snippets that print out the CGI environment, which will include Shibboleth data while a user is authenticated to the IdP.

Perl

#!/usr/bin/perl
print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}

PHP

<?php
foreach($_SERVER as $key_name => $key_value) {
print $key_name . " = " . $key_value . "<br>";
}
?>

Classic ASP

< %
for each header in Request.ServerVariables
response.write header & " = " & Request.ServerVariables(header) & " <br><br> "
next
% >

ASP classic users will need to refer to environment variables with the prefix ‘HEADER_’ instead of ‘HTTP_’ in order to ensure they retrieve valid values from the headers. Read the KB reference that discusses the difference between HTTP_ and HEADER_.

ASP.NET

<% For Each header As String In Request.ServerVariables Response.Write(header & " = " & Request.ServerVariables(header)
& "<br><br>")
Next
%>

Python

#!/usr/bin/python
import sys, os
print "Content-Type: text/html\n\n";
for name, value in os.environ.items():
print "%s\t= %s <br/>" % (name, value)