Skip to content

Commit

Permalink
composeresítés
Browse files Browse the repository at this point in the history
  • Loading branch information
szabogyula committed Apr 25, 2016
1 parent 14f734f commit 4f09b18
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
SSP IdP authsource for aai/vho
SSP IdP authsource for aai/vho

composer require niif/simplesamlphp-module-authVHO

config/authsources.php

```
'authVHO' => array(
'authVHO:authVHO',
'vho_login_url' => 'https://your.vho.com/loginForIdp'
),
```
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "niif/simplesamlphp-module-authVHO",
"description": "Authentication source for niif:VHO",
"type": "simplesamlphp-module",
"require": {
"simplesamlphp/composer-module-installer": "~1.0",
}
}
6 changes: 3 additions & 3 deletions lib/Auth/Process/RedirectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* A simple processing filter for testing that redirection works as it should.
*
*/
class sspmod_exampleauth_Auth_Process_RedirectTest extends SimpleSAML_Auth_ProcessingFilter {
class sspmod_authVHO_Auth_Process_RedirectTest extends SimpleSAML_Auth_ProcessingFilter {


/**
Expand All @@ -20,8 +20,8 @@ public function process(&$state) {
$state['Attributes']['RedirectTest1'] = array('OK');

// Save state and redirect
$id = SimpleSAML_Auth_State::saveState($state, 'exampleauth:redirectfilter-test');
$url = SimpleSAML_Module::getModuleURL('exampleauth/redirecttest.php');
$id = SimpleSAML_Auth_State::saveState($state, 'authVHO:redirectfilter-test');
$url = SimpleSAML_Module::getModuleURL('authVHO/redirecttest.php');
\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
}

Expand Down
27 changes: 14 additions & 13 deletions lib/Auth/Source/authVHO.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class sspmod_authVHO_Auth_Source_authVHO extends SimpleSAML_Auth_Source {
* @param array $info Information about this authentication source.
* @param array $config Configuration.
*/
public function __construct($info, $config) {
public function __construct($info, $config)
{
assert('is_array($info)');
assert('is_array($config)');

Expand All @@ -43,7 +44,8 @@ public function __construct($info, $config) {
*
* @return array|NULL The user's attributes, or NULL if the user isn't authenticated.
*/
private function getUser() {
private function getUser()
{

/*
* In this example we assume that the attributes are
Expand Down Expand Up @@ -72,11 +74,12 @@ private function getUser() {
*
* @param array &$state Information about the current authentication.
*/
public function authenticate(&$state) {
public function authenticate(&$state)
{
assert('is_array($state)');

$attributes = $this->getUser();
if ($attributes !== NULL) {
if ($attributes !== null) {
/*
* The user is already authenticated.
*
Expand Down Expand Up @@ -129,9 +132,7 @@ public function authenticate(&$state) {
* This is in the configuration file.
*/

// $authPage = SimpleSAML_Module::getModuleURL('authVHO/authpage.php');
// $authPage = $config->get('vho_login_url');
$authPage = 'https://project.local/app_dev.php/loginForIdp';
$authPage = $config->get('vho_login_url');

/*
* The redirect to the authentication page.
Expand All @@ -158,8 +159,8 @@ public function authenticate(&$state) {
*
* @param array &$state The authentication state.
*/
public static function resume() {

public static function resume()
{
/*
* First we need to restore the $state-array. We should have the identifier for
* it in the 'State' request parameter.
Expand All @@ -181,7 +182,7 @@ public static function resume() {
* source.
*/
$source = SimpleSAML_Auth_Source::getById($state['authVHO:AuthID']);
if ($source === NULL) {
if ($source === null) {
/*
* The only way this should fail is if we remove or rename the authentication source
* while the user is at the login page.
Expand All @@ -205,7 +206,7 @@ public static function resume() {
* First we check that the user is acutally logged in, and didn't simply skip the login page.
*/
$attributes = $source->getUser();
if ($attributes === NULL) {
if ($attributes === null) {
/*
* The user isn't authenticated.
*
Expand Down Expand Up @@ -236,7 +237,8 @@ public static function resume() {
*
* @param array &$state The logout state array.
*/
public function logout(&$state) {
public function logout(&$state)
{
assert('is_array($state)');

if (!session_id()) {
Expand All @@ -254,5 +256,4 @@ public function logout(&$state) {
* here, but in this example we don't need to do this.
*/
}

}
2 changes: 1 addition & 1 deletion www/redirecttest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if (!array_key_exists('StateId', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
}
$state = SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'exampleauth:redirectfilter-test');
$state = SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'authVHO:redirectfilter-test');

$state['Attributes']['RedirectTest2'] = array('OK');

Expand Down

0 comments on commit 4f09b18

Please sign in to comment.