{"action":"created","issue":{"url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/4026","repository_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate","labels_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/4026/labels{/name}","comments_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/4026/comments","events_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/4026/events","html_url":"https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4026","id":382599953,"node_id":"MDU6SXNzdWUzODI1OTk5NTM=","number":4026,"title":"Permissions Checks from Session.Use","user":{"login":"zetic-be","id":40064735,"node_id":"MDQ6VXNlcjQwMDY0NzM1","avatar_url":"https://avatars3.githubusercontent.com/u/40064735?v=4","gravatar_id":"","url":"https://api.github.com/users/zetic-be","html_url":"https://github.com/zetic-be","followers_url":"https://api.github.com/users/zetic-be/followers","following_url":"https://api.github.com/users/zetic-be/following{/other_user}","gists_url":"https://api.github.com/users/zetic-be/gists{/gist_id}","starred_url":"https://api.github.com/users/zetic-be/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zetic-be/subscriptions","organizations_url":"https://api.github.com/users/zetic-be/orgs","repos_url":"https://api.github.com/users/zetic-be/repos","events_url":"https://api.github.com/users/zetic-be/events{/privacy}","received_events_url":"https://api.github.com/users/zetic-be/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-11-20T10:37:20Z","updated_at":"2018-11-20T13:36:58Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nI am currently using .Net Core on Abp 3.9.0\r\n\r\nI am trying to make permissions work in a **domain service** that is called by a **Background Job**.\r\n\r\nTo be able to use the correct user, I am using :\r\n``` csharp\r\nusing (_session.Use(user.TenantId, user.UserId))\r\n{\r\n      _importService.DoStuff();\r\n}\r\n```\r\nThis is working fine.\r\n\r\nAfter that I need to check permissions but **_session.Use** does not seem to make that happen automatically and **AbpAuthorize(\"SomePermission\")** attributes will always fail.\r\n\r\nThe first thing I have tried then is to remove the permission from there and check for grant manually in code in **DoStuff** method in domain service.\r\n\r\n``` csharp\r\nvar checker = await _permissionChecker.IsGrantedAsync(_session.ToUserIdentifier(), \"SomePermission\");\r\nif (!checker) throw new AbpAuthorizationException(\"You are not authorized to do that !\");\r\n```\r\nThis solution works and would have been fine if the domain service was not calling other injected domain services also requiring evaluating other permissions and so getting kind of a \"cascading permission issue\".  Doing all of this manually with **PermissionChecker** would lead to less clean code that just keep **ApbAuthorize** attributes, correctly doing their job when called in other situations.\r\n\r\nIs there a way of making this work automatically without any manual fix other than **Session.Use** or just with a call to something that would look like **PermissionChecker.Use()** also surrounding **_importService.DoStuff()** ?\r\n\r\nThank you in advance for looking at this.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/comments/440275826","html_url":"https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4026#issuecomment-440275826","issue_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/4026","id":440275826,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDI3NTgyNg==","user":{"login":"maliming","id":6908465,"node_id":"MDQ6VXNlcjY5MDg0NjU=","avatar_url":"https://avatars1.githubusercontent.com/u/6908465?v=4","gravatar_id":"","url":"https://api.github.com/users/maliming","html_url":"https://github.com/maliming","followers_url":"https://api.github.com/users/maliming/followers","following_url":"https://api.github.com/users/maliming/following{/other_user}","gists_url":"https://api.github.com/users/maliming/gists{/gist_id}","starred_url":"https://api.github.com/users/maliming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maliming/subscriptions","organizations_url":"https://api.github.com/users/maliming/orgs","repos_url":"https://api.github.com/users/maliming/repos","events_url":"https://api.github.com/users/maliming/events{/privacy}","received_events_url":"https://api.github.com/users/maliming/received_events","type":"User","site_admin":false},"created_at":"2018-11-20T13:36:58Z","updated_at":"2018-11-20T13:36:58Z","author_association":"MEMBER","body":"@zetic-be \r\nCan you use the startup template to reproduce the problem? (Because I use the startup template everything works fine)\r\nhttps://aspnetboilerplate.com/Templates"}}
{"actor":{"display_login":"maliming"}}