public function authenticate(TokenInterface $token) { ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate(AttributeSetWithFallbacks::class); $translatedAssertion = $this->attributeDictionary->translate($token->assertion); $authenticatingAuthorities = array_map(function ($authenticatingAuthority) { return new EntityId($authenticatingAuthority); }, $token->assertion->getAuthenticatingAuthority()); $user = AuthenticatedUser::createFrom($translatedAssertion, $authenticatingAuthorities); $authenticatedToken = new SamlToken(['ROLE_USER']); $authenticatedToken->setUser($user); return $authenticatedToken; }
/** * @test * @group Authentication * @group Attributes */ public function epti_attribute_is_correctly_set_when_creating_an_authenticated_user() { $expectedAttributeSet = AttributeSet::create([new Attribute(new AttributeDefinition('eduPersonTargetedID', 'urn:mace:dir:attribute-def:eduPersonTargetedID'), ['abcd-some-value-xyz']), new Attribute(new AttributeDefinition('displayName', 'urn:mace:dir:attribute-def:displayName'), ['Tester'])]); $assertionWithEpti = $this->getAssertionWithEpti(); $attributeDictionary = $this->getAttributeDictionary(); $assertionAdapter = $this->mockAssertionAdapterWith(AttributeSet::createFrom($assertionWithEpti, $attributeDictionary), 'abcd-some-value-xyz'); $authenticatedUser = AuthenticatedUser::createFrom($assertionAdapter, []); $actualAttributeSet = $authenticatedUser->getAttributes(); $this->assertEquals($expectedAttributeSet, $actualAttributeSet); }