-
First of all, I would like to say great thank you for creating this template. It helps a lot for building apps. Im creating monitoring system with rasperry pi 5. `
` And now, I cannot find a way to implement authorization for custom class I mean that authentication comes from UI/Client projects and when I try to access eg I know that in controllers we can implement: I dont want to report a bug. Cause for sure it not a bug. Can you advice me any solution? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Greetings, |
Beta Was this translation helpful? Give feedback.
-
here is a link to repo, and my commit: https://github.com/Woselko/AuthorizationTest/commit/d1fd51148ab818b765b2d3e0f5267ba823a94143#diff-f6b49bac3c053b5feb2daa40cfef725251937d7c170911b454308c2d3dd61af6 So to sum up, while user is logged, user should see hangfire dashboard. Well, for me it is mission impossible. If you could take a look. Thanks in advance |
Beta Was this translation helpful? Give feedback.
-
First of all, you can't register hangfire dashboard wherever you want! I'd recommend you to register it next to the swagger middleware. The second issue is how to pass access_token to the dashboard? You can open dashboard using something like this: http://localhost:5118/hangfire?access_token=.................................... You can build such a url in your web client app and bind it to the src of link, so user can click on it. In your commit, there's no sample for using IAuthorizationService and there is no controller for Products, so I can't verify http://localhost:6030/api/product/GetProducts either. Finally, put middlewares in Program.Middlewares.cs and register services in Program.Services.cs instead of changing Program.cs itself. |
Beta Was this translation helpful? Give feedback.
-
@ysmoradi thank you! this is when Im logged in: What is more I used: Which means that user need to be logged in only. Without any role, just authenticated. |
Beta Was this translation helpful? Give feedback.
@ysmoradi thank you!
removing those if statements is what I was looking for:
this is when Im logged in:
and there is no access token cookie when Im logged out.
What is more I used:
app.MapHangfireDashboardWithAuthorizationPolicy("");
Which means that user need to be logged in only. Without any role, just authenticated.
Thanks!