{"action":"created","issue":{"url":"https://api.github.com/repos/lightSAML/SpBundle/issues/55","repository_url":"https://api.github.com/repos/lightSAML/SpBundle","labels_url":"https://api.github.com/repos/lightSAML/SpBundle/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/lightSAML/SpBundle/issues/55/comments","events_url":"https://api.github.com/repos/lightSAML/SpBundle/issues/55/events","html_url":"https://github.com/lightSAML/SpBundle/pull/55","id":251877000,"number":55,"title":"private->protected in SimpleUsernameMapper","user":{"login":"arteniioleg","id":28860670,"avatar_url":"https://avatars2.githubusercontent.com/u/28860670?v=4","gravatar_id":"","url":"https://api.github.com/users/arteniioleg","html_url":"https://github.com/arteniioleg","followers_url":"https://api.github.com/users/arteniioleg/followers","following_url":"https://api.github.com/users/arteniioleg/following{/other_user}","gists_url":"https://api.github.com/users/arteniioleg/gists{/gist_id}","starred_url":"https://api.github.com/users/arteniioleg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arteniioleg/subscriptions","organizations_url":"https://api.github.com/users/arteniioleg/orgs","repos_url":"https://api.github.com/users/arteniioleg/repos","events_url":"https://api.github.com/users/arteniioleg/events{/privacy}","received_events_url":"https://api.github.com/users/arteniioleg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-22T08:29:14Z","updated_at":"2017-08-22T08:34:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lightSAML/SpBundle/pulls/55","html_url":"https://github.com/lightSAML/SpBundle/pull/55","diff_url":"https://github.com/lightSAML/SpBundle/pull/55.diff","patch_url":"https://github.com/lightSAML/SpBundle/pull/55.patch"},"body":"Easier to extend\r\n\r\nI overridden this in my child bundle and it currently duplicates `$attributes` because of `private`\r\n\r\n```php\r\n<?php\r\n\r\nnamespace Tema\\Api\\LightSamlBundle\\Security\\User;\r\n\r\nuse LightSaml\\Model\\Assertion\\Assertion;\r\nuse LightSaml\\Model\\Protocol\\Response;\r\nuse LightSaml\\SamlConstants;\r\nuse LightSaml\\SpBundle\\Security\\User\\SimpleUsernameMapper as SimpleUsernameMapperBase;\r\n\r\nclass PersistentUsernameMapper extends SimpleUsernameMapperBase\r\n{\r\n    const NAME_ID_FORMAT = SamlConstants::NAME_ID_FORMAT_PERSISTENT;\r\n\r\n    /** @var string[] */\r\n    protected $attributes;\r\n\r\n    /**\r\n     * @param string[] $attributes\r\n     */\r\n    public function __construct(array $attributes)\r\n    {\r\n        parent::__construct($attributes);\r\n\r\n        $this->attributes = $attributes;\r\n    }\r\n\r\n    /**\r\n     * @param Response $response\r\n     *\r\n     * @return string|null\r\n     */\r\n    public function getUsername(Response $response)\r\n    {\r\n        foreach ($response->getAllAssertions() as $assertion) {\r\n            $username = $this->getUsernameFromAssertion($assertion);\r\n            if ($username) {\r\n                return $username;\r\n            }\r\n        }\r\n\r\n        return null;\r\n    }\r\n\r\n    /**\r\n     * @param Assertion $assertion\r\n     *\r\n     * @return null|string\r\n     */\r\n    protected function getUsernameFromAssertion(Assertion $assertion)\r\n    {\r\n        foreach ($this->attributes as $attributeName) {\r\n            if (self::NAME_ID == $attributeName) {\r\n                if ($assertion->getSubject() &&\r\n                    $assertion->getSubject()->getNameID() &&\r\n                    $assertion->getSubject()->getNameID()->getValue() &&\r\n                    $assertion->getSubject()->getNameID()->getFormat() === self::NAME_ID_FORMAT\r\n                ) {\r\n                    return $assertion->getSubject()->getNameID()->getValue();\r\n                }\r\n            } else {\r\n                foreach ($assertion->getAllAttributeStatements() as $attributeStatement) {\r\n                    $attribute = $attributeStatement->getFirstAttributeByName($attributeName);\r\n                    if ($attribute && $attribute->getFirstAttributeValue()) {\r\n                        return $attribute->getFirstAttributeValue();\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return null;\r\n    }\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/lightSAML/SpBundle/issues/comments/323957943","html_url":"https://github.com/lightSAML/SpBundle/pull/55#issuecomment-323957943","issue_url":"https://api.github.com/repos/lightSAML/SpBundle/issues/55","id":323957943,"user":{"login":"coveralls","id":2354108,"avatar_url":"https://avatars1.githubusercontent.com/u/2354108?v=4","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2017-08-22T08:34:28Z","updated_at":"2017-08-22T08:34:28Z","body":"\n[![Coverage Status](https://coveralls.io/builds/12933984/badge)](https://coveralls.io/builds/12933984)\n\nCoverage increased (+0.5%) to 98.618% when pulling **9a63ebe2e84079b25a7a7542fd10d999330c2a4a on arteniioleg:patch-1** into **c32db2ea093b7047ed50e4935d29b6b492718311 on lightSAML:master**.\n"}}
{"actor":{"display_login":"coveralls"}}