{"action":"created","issue":{"url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle/issues/294","repository_url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle","labels_url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle/issues/294/labels{/name}","comments_url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle/issues/294/comments","events_url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle/issues/294/events","html_url":"https://github.com/lexik/LexikJWTAuthenticationBundle/issues/294","id":197909874,"number":294,"title":"Extending JWTTokenAuthenticator::getUser()","user":{"login":"SmurfyFR","id":2379631,"avatar_url":"https://avatars.githubusercontent.com/u/2379631?v=3","gravatar_id":"","url":"https://api.github.com/users/SmurfyFR","html_url":"https://github.com/SmurfyFR","followers_url":"https://api.github.com/users/SmurfyFR/followers","following_url":"https://api.github.com/users/SmurfyFR/following{/other_user}","gists_url":"https://api.github.com/users/SmurfyFR/gists{/gist_id}","starred_url":"https://api.github.com/users/SmurfyFR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SmurfyFR/subscriptions","organizations_url":"https://api.github.com/users/SmurfyFR/orgs","repos_url":"https://api.github.com/users/SmurfyFR/repos","events_url":"https://api.github.com/users/SmurfyFR/events{/privacy}","received_events_url":"https://api.github.com/users/SmurfyFR/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-28T20:13:42Z","updated_at":"2016-12-30T14:06:05Z","closed_at":null,"body":"Hi,\r\n\r\nBefore upgrading, I was using a JWTProvider to allow a JWT Token to be \"user less\" (eg : a token to allow another system to call my API (eg : a JWT used by my WHMCS installation).\r\nI was overriding the `getUserFromPayload()` function to return a user created by instancing a new User object.\r\n\r\nAs the JWTProvider has been deprecated in flavor of the JWTTokenAuthenticator class, I would like to do the same with this new class : extending the `JWTTokenAuthenticator::getUser()` method.\r\n\r\nI saw in the issue #277 ( http://github.com/lexik/LexikJWTAuthenticationBundle/issues/277#issuecomment-264116280 ) that I should use the following line to make my custom JWTTokenAuthenticator work : https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Security/Guard/JWTTokenAuthenticator.php#L153.\r\n\r\nThe problem is that the `$preAuthenticationTokenStorage` property is declared as private ( see : https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Security/Guard/JWTTokenAuthenticator.php#L60 ) and thus cannot be accessed by my custom authenticator class.\r\n\r\nBefore going any further (like creating a new PR), am I doing something wrong ? Is this private declaration wanted ?\r\nIf not, could we declare this property as protected instead of private ?\r\n\r\nBest regards."},"comment":{"url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle/issues/comments/269775239","html_url":"https://github.com/lexik/LexikJWTAuthenticationBundle/issues/294#issuecomment-269775239","issue_url":"https://api.github.com/repos/lexik/LexikJWTAuthenticationBundle/issues/294","id":269775239,"user":{"login":"chalasr","id":7502063,"avatar_url":"https://avatars.githubusercontent.com/u/7502063?v=3","gravatar_id":"","url":"https://api.github.com/users/chalasr","html_url":"https://github.com/chalasr","followers_url":"https://api.github.com/users/chalasr/followers","following_url":"https://api.github.com/users/chalasr/following{/other_user}","gists_url":"https://api.github.com/users/chalasr/gists{/gist_id}","starred_url":"https://api.github.com/users/chalasr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chalasr/subscriptions","organizations_url":"https://api.github.com/users/chalasr/orgs","repos_url":"https://api.github.com/users/chalasr/repos","events_url":"https://api.github.com/users/chalasr/events{/privacy}","received_events_url":"https://api.github.com/users/chalasr/received_events","type":"User","site_admin":false},"created_at":"2016-12-30T14:06:05Z","updated_at":"2016-12-30T14:06:05Z","body":"Hi @SmurfyFR,\r\n\r\nThank you for opening this issue.\r\nYou're right to discuss about before trying to solve it, I did not answer you before today because in fact we were about to merge a feature that should solve your problem and it needed to be finished, it is now.\r\n\r\nIn #278 we added a _database-less user provider_ which creates user instances from JWTs payload. The user provider is not mandatory, any other provider can still be used instead, but you could be interested by the feature for your use case as we provide a `JWTUserInterface` and any class implementing this interface can be used with this user provider (the class needs a `static createFromPayload($username, $payload): self` to guarantee that we can instantiate it.\r\n\r\nEven if you don't need the feature and keep creating your user instances by extending the authenticator, the PR will help you as we added a protected `loadUser()` method to the `JWTTokenAuthenticator` class, so you can just override it and return your custom user instance.\r\n\r\nAnyway, you can already try it by upgrading the bundle to `v2.1.0`, hope you're all good with it.\r\n\r\nCheers"}}
{"actor":{"display_login":"chalasr"}}