|
| 1 | +NAME |
| 2 | + Net::SAML2 |
| 3 | + |
| 4 | +VERSION |
| 5 | + version 0.34 |
| 6 | + |
| 7 | +SYNOPSIS |
| 8 | + # generate a redirect off to the IdP: |
| 9 | + |
| 10 | + my $idp = Net::SAML2::IdP->new($IDP); |
| 11 | + my $sso_url = $idp->sso_url('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'); |
| 12 | + |
| 13 | + my $authnreq = Net::SAML2::Protocol::AuthnRequest->new( |
| 14 | + issuer => 'http://localhost:3000/metadata.xml', |
| 15 | + destination => $sso_url, |
| 16 | + nameid_format => $idp->format('persistent'), |
| 17 | + )->as_xml; |
| 18 | + |
| 19 | + my $authnreq = Net::SAML2::Protocol::AuthnRequest->new( |
| 20 | + id => 'NETSAML2_Crypt::OpenSSL::Random::random_pseudo_bytes(16), |
| 21 | + issuer => $self->{id}, # Service Provider (SP) Entity ID |
| 22 | + destination => $sso_url, # Identity Provider (IdP) SSO URL |
| 23 | + provider_name => $provider_name, # Service Provider (SP) Human Readable Name |
| 24 | + issue_instant => DateTime->now, # Defaults to Current Time |
| 25 | + ); |
| 26 | + |
| 27 | + my $request_id = $authnreq->id; # Store and Compare to InResponseTo |
| 28 | + |
| 29 | + # or |
| 30 | + |
| 31 | + my $request_id = 'NETSAML2_' . unpack 'H*', Crypt::OpenSSL::Random::random_pseudo_bytes(16); |
| 32 | + |
| 33 | + my $authnreq = Net::SAML2::Protocol::AuthnRequest->as_xml( |
| 34 | + id => $request_id, # Unique Request ID will be returned in response |
| 35 | + issuer => $self->{id}, # Service Provider (SP) Entity ID |
| 36 | + destination => $sso_url, # Identity Provider (IdP) SSO URL |
| 37 | + provider_name => $provider_name, # Service Provider (SP) Human Readable Name |
| 38 | + issue_instant => DateTime->now, # Defaults to Current Time |
| 39 | + ); |
| 40 | + |
| 41 | + my $redirect = Net::SAML2::Binding::Redirect->new( |
| 42 | + key => '/path/to/SPsign-nopw-key.pem', |
| 43 | + url => $sso_url, |
| 44 | + param => 'SAMLRequest' OR 'SAMLResponse', |
| 45 | + cert => '/path/to/IdP-cert.pem' |
| 46 | + ); |
| 47 | + |
| 48 | + my $url = $redirect->sign($authnreq); |
| 49 | + |
| 50 | + my $ret = $redirect->verify($url); |
| 51 | + |
| 52 | + # handle the POST back from the IdP, via the browser: |
| 53 | + |
| 54 | + my $post = Net::SAML2::Binding::POST->new; |
| 55 | + my $ret = $post->handle_response( |
| 56 | + $saml_response |
| 57 | + ); |
| 58 | + |
| 59 | + if ($ret) { |
| 60 | + my $assertion = Net::SAML2::Protocol::Assertion->new_from_xml( |
| 61 | + xml => decode_base64($saml_response) |
| 62 | + ); |
| 63 | + |
| 64 | + # ... |
| 65 | + } |
| 66 | + |
| 67 | +DESCRIPTION |
| 68 | + Support for the Web Browser SSO profile of SAML2. |
| 69 | + |
| 70 | + Net::SAML2 correctly perform the SSO process against numerous SAML |
| 71 | + Identity Providers (IdPs). It has been tested against: |
| 72 | + |
| 73 | + GSuite (Google) |
| 74 | + Azure (Microsoft Office 365) |
| 75 | + OneLogin |
| 76 | + Jump |
| 77 | + Mircosoft ADFS |
| 78 | + Keycloak |
| 79 | + |
| 80 | +NAME |
| 81 | + Net::SAML2 - SAML bindings and protocol implementation |
| 82 | + |
| 83 | +MAJOR CAVEATS |
| 84 | + SP-side protocol only |
| 85 | + Requires XML metadata from the IdP |
| 86 | + |
| 87 | +AUTHOR |
| 88 | + Chris Andrews <chrisandrews@venda.com> |
| 89 | + |
| 90 | +COPYRIGHT |
| 91 | + The following copyright notice applies to all the files provided in this |
| 92 | + distribution, including binary files, unless explicitly noted otherwise. |
| 93 | + |
| 94 | + Copyright 2010, 2011 Venda Ltd. |
| 95 | + |
| 96 | +LICENCE |
| 97 | + This library is free software; you can redistribute it and/or modify it |
| 98 | + under the same terms as Perl itself. |
| 99 | + |
| 100 | +AUTHOR |
| 101 | + Original Author: Chris Andrews <chrisa@cpan.org> |
| 102 | + |
| 103 | +COPYRIGHT AND LICENSE |
| 104 | + This software is copyright (c) 2021 by Chris Andrews and Others; in |
| 105 | + detail: |
| 106 | + |
| 107 | + Copyright 2010-2012 Chris Andrews |
| 108 | + 2016 Jeff Fearn |
| 109 | + 2017 xmikew |
| 110 | + 2019-2021 Timothy Legge |
| 111 | + |
| 112 | + This is free software; you can redistribute it and/or modify it under |
| 113 | + the same terms as the Perl 5 programming language system itself. |
| 114 | + |
0 commit comments