Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Perl and SAML

by bcarroll (Pilgrim)
on Jun 18, 2014 at 13:45 UTC ( #1090308=note: print w/replies, xml ) Need Help??

in reply to Perl and SAML

Have a look at Authen::NZRealMe and its sub modules

The process may be a little different depending on whether you are trying to parse a Service Provider issued SAML AuthnRequest or an Identity Provider issued SAMLResponse

An AuthnRequest will typically be rawdeflated ( IO::Compress::RawDeflate::rawdeflate ), Base64 encoded ( MIME::Base64::encode_base64 ), and URI encoded ( URI::Escape::uri_escape ).

To parse a SAML AuthnRequest you need to process the data in reverse.

Here is a simple example. Note: This example does not verify the digital signature of the AuthnRequest (if it exists).

use warnings; use strict; use MIME::Base64 qw(encode_base64 decode_base64); use URI::Escape qw(uri_escape uri_unescape); use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError); my $AuthnRequestXML = ''; my $samlRequest = 'BASE64_ENCODED_SAMLREQUEST_FROM_SERVICE_PROVIDER'; $samlRequest = uri_unescape($samlRequest); $samlRequest = decode_base64($samlRequest); rawinflate \$samlRequest => $AuthnRequestXML or return "Error decompre +ssing data: $RawInflateError\n"; print "SAML AuthnRequest XML:\n$AuthnRequestXML\n";
To make the XML output easier to read, you can send it through XML::Tidy
use XML::Tidy; XML::Tidy->new('xml'=>$AuthnRequestXML)->tidy()->toString();

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090308]
[jedikaiti]: Hi, Monks
[marto]: heya jedikaiti!
[jedikaiti]: Cute Robot!
[jedikaiti]: How's life, marto?
[marto]: I saw this robot the other day, pretty fancy stuff. Things are pretty good jedikaiti, improving :) How are things with you?
[jedikaiti]: Doing OK, but a little achy this AM - I think the cats were using me as a wrestling mat and mattress while I was asleep last night.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (18)
As of 2017-07-25 15:04 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (374 votes). Check out past polls.