From dccfbc519e2f2af9bddb5b6c816f493b20ddbf00 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 20 Oct 2008 13:47:59 +0000 Subject: [PATCH] Add authsource login example. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@938 44740490-163a-0410-bde0-09ae8108e29a --- www/example-simple/authsource-example.php | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 www/example-simple/authsource-example.php diff --git a/www/example-simple/authsource-example.php b/www/example-simple/authsource-example.php new file mode 100644 index 000000000..17854da3d --- /dev/null +++ b/www/example-simple/authsource-example.php @@ -0,0 +1,41 @@ +<?php + +/** + * The _include script registers a autoloader for the simpleSAMLphp libraries. It also + * initializes the simpleSAMLphp config class with the correct path. + */ +require_once('../_include.php'); + +$config = SimpleSAML_Configuration::getInstance(); +$session = SimpleSAML_Session::getInstance(); + + +if(array_key_exists('logout', $_REQUEST)) { + SimpleSAML_Auth_Default::initLogout('/' . $config->getBaseURL() . 'logout.php'); +} + +if(!array_key_exists('as', $_REQUEST)) { + throw new Exception('No authentication source chosen.'); +} + +$as = $_REQUEST['as']; + +if (!$session->isValid($as)) { + SimpleSAML_Auth_Default::initLogin($as, SimpleSAML_Utilities::selfURL()); +} + +$attributes = $session->getAttributes(); + +$t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); + +$t->data['header'] = '{status:header_saml20_sp}'; +$t->data['remaining'] = $session->remainingTime(); +$t->data['sessionsize'] = $session->getSize(); +$t->data['attributes'] = $attributes; +$t->data['logouturl'] = SimpleSAML_Utilities::selfURLNoQuery() . '?logout'; +$t->data['icon'] = 'bino.png'; +$t->show(); + + + +?> \ No newline at end of file -- GitLab