Skip to content
Snippets Groups Projects
Commit 9b480015 authored by Andy Summers's avatar Andy Summers
Browse files

Add `isMemberOf` attribute for Manifest group delivery

parent 3b1645fa
No related branches found
No related tags found
1 merge request!13Add `isMemberOf` attribute for Manifest group delivery
Showing
with 61 additions and 18 deletions
......@@ -4,7 +4,7 @@
"type": "library",
"homepage": "https://git.doit.wisc.edu/adi-ia/uw-php-security",
"license": "Apache-2.0",
"version": "2.0.1",
"version": "2.1.0",
"authors": [{
"name": "UW-Madison DoIT ADI Integrated Applications",
"email": "adi-ia@lists.wisc.edu",
......
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "8f6e29a0b7f012c3a62df9e5899d57d3",
"content-hash": "9e664849ddf46e1a2b66fd5185bf57b8",
"hash": "04e36a4c8fb561534363967c2928a542",
"content-hash": "1f9986fcd261b43d38be581603b2af13",
"packages": [],
"packages-dev": [
{
......
......@@ -26,6 +26,8 @@ class UWUserDetails implements UserDetails
private $firstName;
/** @var string */
private $lastName;
/** @var array */
private $memberships;
/**
* UWUserDetails constructor.
......@@ -48,7 +50,8 @@ class UWUserDetails implements UserDetails
$source,
$isisEmplid,
$firstName,
$lastName
$lastName,
$memberships
) {
$this->eppn = $eppn;
$this->pvi = $pvi;
......@@ -59,6 +62,7 @@ class UWUserDetails implements UserDetails
$this->isisEmplid = $isisEmplid;
$this->firstName = $firstName;
$this->lastName = $lastName;
$this->memberships = $memberships;
}
/**
......@@ -133,4 +137,12 @@ class UWUserDetails implements UserDetails
return $this->lastName;
}
/**
* {@inheritdoc}
*/
public function getIsMemberOf()
{
return $this->memberships;
}
}
\ No newline at end of file
......@@ -73,5 +73,12 @@ interface UserDetails
* @return string|null
*/
public function getLastName();
/**
* The user's Manifest group memberships delivered to the application.
*
* @return array|null
*/
public function getIsMemberOf();
}
......@@ -20,6 +20,7 @@ abstract class UserDetailsProvider
const UDDS = "udds";
const SOURCE = "source";
const ISIS_EMPLID = "isisEmplid";
const MEMBER_OF = "isMemberOf";
/** Delimiter used by multi-valued headers */
const DELIMITER = ';';
......
......@@ -53,7 +53,8 @@ class LocalUserDetailsProvider extends PreauthUserDetailsProvider
$attributes[static::SOURCE],
$attributes[static::ISIS_EMPLID],
$attributes[static::FIRST_NAME],
$attributes[static::LAST_NAME]
$attributes[static::LAST_NAME],
explode(static::DELIMITER, $attributes[static::MEMBER_OF])
);
}
......
......@@ -42,19 +42,21 @@ class FederatedPreauthUserDetailsProvider extends UserDetailsProvider
getenv($this->httpHeaderFromAttribute(static::SOURCE)),
getenv($this->httpHeaderFromAttribute(static::ISIS_EMPLID)),
getenv($this->httpHeaderFromAttribute(static::FIRST_NAME)),
getenv($this->httpHeaderFromAttribute(static::LAST_NAME))
getenv($this->httpHeaderFromAttribute(static::LAST_NAME)),
explode(static::DELIMITER, getenv($this->httpHeaderFromAttribute(static::MEMBER_OF)))
);
} else {
$userDetails = new UWUserDetails(
getenv(static::EPPN),
getenv(static::SPVI),
getenv(static::FULL_NAME),
getenv(static::UDDS),
explode(static::DELIMITER, getenv(static::UDDS)),
getenv(static::EMAIL),
getenv(static::SOURCE),
getenv(static::ISIS_EMPLID),
getenv(static::FIRST_NAME),
getenv(static::LAST_NAME)
getenv(static::LAST_NAME),
explode(static::DELIMITER, getenv(static::MEMBER_OF))
);
}
......
......@@ -41,19 +41,21 @@ class PreauthUserDetailsProvider extends UserDetailsProvider
getenv($this->httpHeaderFromAttribute(static::SOURCE)),
getenv($this->httpHeaderFromAttribute(static::ISIS_EMPLID)),
getenv($this->httpHeaderFromAttribute(static::FIRST_NAME)),
getenv($this->httpHeaderFromAttribute(static::LAST_NAME))
getenv($this->httpHeaderFromAttribute(static::LAST_NAME)),
explode(static::DELIMITER, getenv($this->httpHeaderFromAttribute(static::MEMBER_OF)))
);
} else {
$userDetails = new UWUserDetails(
getenv(static::EPPN),
getenv(static::PVI),
getenv(static::FULL_NAME),
getenv(static::UDDS),
explode(static::DELIMITER, getenv(static::UDDS)),
getenv(static::EMAIL),
getenv(static::SOURCE),
getenv(static::ISIS_EMPLID),
getenv(static::FIRST_NAME),
getenv(static::LAST_NAME)
getenv(static::LAST_NAME),
explode(static::DELIMITER, getenv(static::MEMBER_OF))
);
}
......
......@@ -8,5 +8,6 @@
"wiscEduUDDS": "A061234;A072345",
"mail": "bucky.badger@wisc.edu",
"source": "a_source",
"isisEmplid": "123456789"
"isisEmplid": "123456789",
"isMemberOf": "A06;A07"
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ class LocalUserDetailsProviderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals("123456789", $user->getIsisEmplid());
$this->assertEquals("BUCKINGHAM", $user->getFirstName());
$this->assertEquals("BADGER", $user->getLastName());
$this->assertEquals(['A06', 'A07'], $user->getIsMemberOf());
}
/** @test */
......
......@@ -11,9 +11,6 @@ class FederatedPreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCas
use EnvironmentHelper;
/** @var array */
private $attributes;
/** @var FederatedPreauthUserDetailsProvider */
private $userProvider;
......@@ -39,7 +36,8 @@ class FederatedPreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCas
FederatedPreauthUserDetailsProvider::LAST_NAME => 'BADGER',
FederatedPreauthUserDetailsProvider::SOURCE => 'a_source',
FederatedPreauthUserDetailsProvider::SPVI => 'UW123A456',
FederatedPreauthUserDetailsProvider::ISIS_EMPLID => '123456789'
FederatedPreauthUserDetailsProvider::ISIS_EMPLID => '123456789',
FederatedPreauthUserDetailsProvider::MEMBER_OF => 'A06;A07'
];
}
......@@ -73,6 +71,10 @@ class FederatedPreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCas
$user->getFirstName()
);
static::assertEquals($this->environment[FederatedPreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
static::assertEquals(
explode(FederatedPreauthUserDetailsProvider::DELIMITER, $this->environment[FederatedPreauthUserDetailsProvider::MEMBER_OF]),
$user->getIsMemberOf()
);
}
/** @test */
......@@ -96,6 +98,10 @@ class FederatedPreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCas
$user->getFirstName()
);
static::assertEquals($this->environment[FederatedPreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
static::assertEquals(
explode(FederatedPreauthUserDetailsProvider::DELIMITER, $this->environment[FederatedPreauthUserDetailsProvider::MEMBER_OF]),
$user->getIsMemberOf()
);
}
/** @test */
......
......@@ -36,7 +36,8 @@ class PreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCase
PreauthUserDetailsProvider::LAST_NAME => 'BADGER',
PreauthUserDetailsProvider::SOURCE => 'a_source',
PreauthUserDetailsProvider::PVI => 'UW123A456',
PreauthUserDetailsProvider::ISIS_EMPLID => '123456789'
PreauthUserDetailsProvider::ISIS_EMPLID => '123456789',
PreauthUserDetailsProvider::MEMBER_OF => 'A06;A07'
];
}
......@@ -65,6 +66,10 @@ class PreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCase
static::assertEquals($this->environment[PreauthUserDetailsProvider::ISIS_EMPLID], $user->getIsisEmplid());
static::assertEquals($this->environment[PreauthUserDetailsProvider::FIRST_NAME], $user->getFirstName());
static::assertEquals($this->environment[PreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
static::assertEquals(
explode(PreauthUserDetailsProvider::DELIMITER, $this->environment[PreauthUserDetailsProvider::MEMBER_OF]),
$user->getIsMemberOf()
);
}
/** @test */
......@@ -82,6 +87,10 @@ class PreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCase
static::assertEquals($this->environment[PreauthUserDetailsProvider::ISIS_EMPLID], $user->getIsisEmplid());
static::assertEquals($this->environment[PreauthUserDetailsProvider::FIRST_NAME], $user->getFirstName());
static::assertEquals($this->environment[PreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
static::assertEquals(
explode(PreauthUserDetailsProvider::DELIMITER, $this->environment[PreauthUserDetailsProvider::MEMBER_OF]),
$user->getIsMemberOf()
);
}
/** @test */
......
......@@ -8,5 +8,6 @@
"wiscEduUDDS": "A061234;A072345",
"mail": "bucky.badger@wisc.edu",
"source": "a_source",
"wiscEduIsisEmplid": "123456789"
"wiscEduIsisEmplid": "123456789",
"isMemberOf": "A06;A07"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment