Commit 5e212ab8 authored by Mario Hernandez's avatar Mario Hernandez 💬

Update Single_Sign-on_to_Azure_AD_using_SimpleSAMLphp.md

parent e5aa9383
...@@ -181,252 +181,39 @@ Now that configuration of SimpleSAMLphp is complete, we can use SimpleSAMLphp to ...@@ -181,252 +181,39 @@ Now that configuration of SimpleSAMLphp is complete, we can use SimpleSAMLphp to
So, all this configuration was just to get us to the point where we can create our own application code that allows us to authenticate with Azure AD. The reality is that our PHP “application” can be a single page. So, all this configuration was just to get us to the point where we can create our own application code that allows us to authenticate with Azure AD. The reality is that our PHP “application” can be a single page.
## index.php ## index.php
```php
Generally, the application will require an <font face="Courier New"><font style="font-size: 10pt" size="2">index.php</font></font> file – the code for which is below. I’ll give a very brief breakdown of the first few lines, the rest is obvious.
<div id="crayon-5f9b6b2f0d3aa656342966" dir="ltr">
<font style="font-size: 9pt" size="2">PHP</font>
<font style="font-size: 9pt" size="2"><?php require_once (dirname(__FILE__) . '/../simplesamlphp/lib/_autoload.php'); $as = new SimpleSAML_Auth_Simple('default-sp'); $as->requireAuth(); $attributes = $as->getAttributes(); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Index Page</title> </head> <body> <h2>Index Page</h2> <h3>Welcome <strong>Authenticated User</strong>!</h3> <h4>Claim list:</h4> <?php echo '<pre>'; print_r($attributes); echo '</pre>'; // Get a logout URL $url = $as->getLogoutURL(); echo '<a href="' . htmlspecialchars($url) . '">Logout</a>'; ?> </body> </html></font>
<table cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="border: none; padding: 0cm">
<font style="font-size: 9pt" size="2">1</font>
<font style="font-size: 9pt" size="2">2</font>
<font style="font-size: 9pt" size="2">3</font>
<font style="font-size: 9pt" size="2">4</font>
<font style="font-size: 9pt" size="2">5</font>
<font style="font-size: 9pt" size="2">6</font>
<font style="font-size: 9pt" size="2">7</font>
<font style="font-size: 9pt" size="2">8</font>
<font style="font-size: 9pt" size="2">9</font>
<font style="font-size: 9pt" size="2">10</font>
<font style="font-size: 9pt" size="2">11</font>
<font style="font-size: 9pt" size="2">12</font>
<font style="font-size: 9pt" size="2">13</font>
<font style="font-size: 9pt" size="2">14</font>
<font style="font-size: 9pt" size="2">15</font>
<font style="font-size: 9pt" size="2">16</font>
<font style="font-size: 9pt" size="2">17</font>
<font style="font-size: 9pt" size="2">18</font>
<font style="font-size: 9pt" size="2">19</font>
<font style="font-size: 9pt" size="2">20</font>
<font style="font-size: 9pt" size="2">21</font>
<font style="font-size: 9pt" size="2">22</font>
<font style="font-size: 9pt" size="2">23</font>
<font style="font-size: 9pt" size="2">24</font>
<font style="font-size: 9pt" size="2">25</font>
<font style="font-size: 9pt" size="2">26</font>
<font style="font-size: 9pt" size="2">27</font>
<font style="font-size: 9pt" size="2">28</font>
<font style="font-size: 9pt" size="2">29</font>
<font style="font-size: 9pt" size="2">30</font>
</td>
<td style="border: none; padding: 0cm">
<div id="crayon-5f9b6b2f0d3aa656342966-1" dir="ltr">
<?php <?php
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-2" dir="ltr">
require_once (dirname(__FILE__) . '/../simplesamlphp/lib/_autoload.php'); require_once (dirname(__FILE__) . '/../simplesamlphp/lib/_autoload.php');
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-3" dir="ltr">
$as = new SimpleSAML_Auth_Simple('default-sp'); $as = new SimpleSAML_Auth_Simple('default-sp');
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-4" dir="ltr">
$as->requireAuth(); $as->requireAuth();
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-6" dir="ltr">
$attributes = $as->getAttributes(); $attributes = $as->getAttributes();
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-8" dir="ltr">
?> ?>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-9" dir="ltr">
<!DOCTYPE html> <!DOCTYPE html>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-10" dir="ltr">
<html> <html>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-11" dir="ltr">
<head> <head>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-12" dir="ltr">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-13" dir="ltr">
<title>Index Page</title> <title>Index Page</title>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-14" dir="ltr">
</head> </head>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-15" dir="ltr">
<body> <body>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-16" dir="ltr">
<h2>Index Page</h2> <h2>Index Page</h2>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-17" dir="ltr">
<h3>Welcome <strong>Authenticated User</strong>!</h3> <h3>Welcome <strong>Authenticated User</strong>!</h3>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-18" dir="ltr">
<h4>Claim list:</h4> <h4>Claim list:</h4>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-19" dir="ltr">
<?php <?php
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-20" dir="ltr">
echo '<pre>'; echo '<pre>';
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-21" dir="ltr">
print_r($attributes); print_r($attributes);
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-22" dir="ltr">
echo '</pre>'; echo '</pre>';
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-24" dir="ltr">
// Get a logout URL // Get a logout URL
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-25" dir="ltr">
$url = $as->getLogoutURL(); $url = $as->getLogoutURL();
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-26" dir="ltr">
echo '<a href="' . htmlspecialchars($url) . '">Logout</a>'; echo '<a href="' . htmlspecialchars($url) . '">Logout</a>';
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-28" dir="ltr">
?> ?>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-29" dir="ltr">
</body> </body>
</div>
<div id="crayon-5f9b6b2f0d3aa656342966-30" dir="ltr">
</html> </html>
```
</div>
</td>
</tr>
</tbody>
</table>
</div>
This file will require authentication so, on line 2, it calls SimpleSAMLphp’s autoloader from the main installation of SimpleSAMLphp. This file will require authentication so, on line 2, it calls SimpleSAMLphp’s autoloader from the main installation of SimpleSAMLphp.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment