1+ <?php
2+ /**
3+ * SAMPLE Code to demonstrate how provide SAML settings.
4+ *
5+ * The settings are contained within a SamlSettings object. You need to
6+ * provide, at a minimum, the following things:
7+ * - idp_sso_target_url: This is the URL to forward to for auth requests.
8+ * It will be provided by your IdP.
9+ * - x509certificate: This is a certificate required to authenticate your
10+ * request. This certificate should be provided by your IdP.
11+ * - assertion_consumer_service_url: The URL that the IdP should redirect
12+ * to once the authorization is complete. You must provide this, and it
13+ * should point to the consume.php script or its equivalent.
14+ */
15+
16+ define ('XMLSECLIB_DIR ' , './../src ' )
17+
18+ define ('ONELOGIN_SAML_DIR ' , './../src/OneLogin/Saml/ ' );
19+ require ONELOGIN_SAML_DIR . 'AuthRequest.php ' ;
20+ require ONELOGIN_SAML_DIR . 'Response.php ' ;
21+ require ONELOGIN_SAML_DIR . 'Settings.php ' ;
22+ require ONELOGIN_SAML_DIR . 'XmlSec.php ' ;
23+
24+ /**
25+ * Return a SamlSettings object with user settings.
26+ */
27+ function saml_get_settings ()
28+ {
29+ // This function should be modified to return the SAML settings for the current user
30+
31+ $ settings = new OneLogin_Saml_Settings ();
32+
33+ // When using Service Provider Initiated SSO (starting at index.php), this URL asks the IdP to authenticate the user.
34+ $ settings ->idp_sso_target_url = "https://app.onelogin.com/saml/signon/6171 " ;
35+
36+ // The certificate for the users account in the IdP
37+ $ settings ->x509certificate = <<<ENDCERTIFICATE
38+ -----BEGIN CERTIFICATE-----
39+ MIIBrTCCAaGgAwIBAgIBATADBgEAMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApD
40+ YWxpZm9ybmlhMRUwEwYDVQQHDAxTYW50YSBNb25pY2ExETAPBgNVBAoMCE9uZUxv
41+ Z2luMRkwFwYDVQQDDBBhcHAub25lbG9naW4uY29tMB4XDTEwMDMwOTA5NTgzNFoX
42+ DTE1MDMwOTA5NTgzNFowZzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3Ju
43+ aWExFTATBgNVBAcMDFNhbnRhIE1vbmljYTERMA8GA1UECgwIT25lTG9naW4xGTAX
44+ BgNVBAMMEGFwcC5vbmVsb2dpbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ
45+ AoGBANtmwriqGBbZy5Dwy2CmJEtHEENVPoATCZP3UDESRDQmXy9Q0Kq1lBt+KyV4
46+ kJNHYAAQ9egLGWQ8/1atkPBye5s9fxROtf8VO3uk/x/X5VSRODIrhFISGmKUnVXa
47+ UhLFIXkGSCAIVfoR5S2ggdfpINKUWGsWS/lEzLNYMBkURXuVAgMBAAEwAwYBAAMB
48+ AA==
49+ -----END CERTIFICATE-----
50+ ENDCERTIFICATE ;
51+
52+ // The URL where to the SAML Response/SAML Assertion will be posted
53+ $ settings ->assertion_consumer_service_url = "http://localhost/php-saml/consume.php " ;
54+
55+ // Name of this application
56+ $ settings ->issuer = "php-saml " ;
57+
58+ // Tells the IdP to return the email address of the current user
59+ $ settings ->name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress " ;
60+
61+
62+ return $ settings ;
63+ }
0 commit comments