Skip to content

Add admin controllers for cities, polls and ideas#62

Open
SubochArtem wants to merge 23 commits intofeature/polls-cqrs-handlers-ideasfrom
task/polls-admin-controllers
Open

Add admin controllers for cities, polls and ideas#62
SubochArtem wants to merge 23 commits intofeature/polls-cqrs-handlers-ideasfrom
task/polls-admin-controllers

Conversation

@SubochArtem
Copy link
Copy Markdown
Owner

No description provided.

@SubochArtem SubochArtem requested a review from 5Ka-me April 14, 2026 09:18
Comment thread src/Backend/Services/Polls/Polls.API/Authorization/Auth0Settings.cs Outdated
Comment thread src/Backend/Services/Polls/Polls.API/Authorization/ConfigureJwtBearerOptions.cs Outdated

public static class ClaimsPrincipalExtensions
{
private const string CityIdClaim = "https://citypulse.com/city_id";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not store it in appsettings?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preferred a constant over appsettings in this situation because:

  1. This data is consistent across all environments and doesn't need to be configurable.
  2. This specific claim key is only used within this extension class, so it doesn't need global visibility.
  3. ClaimsPrincipalExtensions is a static class, which makes it difficult to use the Options pattern or IConfiguration

Comment thread src/Backend/Services/Polls/Polls.API/Common/Filters/ResultFilter.cs Outdated
Comment thread src/Backend/Services/Polls/Polls.API/Common/Filters/ResultFilter.cs
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using both result pattern and ExceptionMiddleware?
Every Internal Exception will be thrown without it

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Result pattern for expected domain logic. The ExceptionMiddleware is there because I don't want to leak internal error details to user. It allows me to control the output, and ensure every crash is logged in a standardized format

@sonarqubecloud
Copy link
Copy Markdown

Comment on lines +10 to +15
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.RequireClaim(Permissions.ClaimType, policyName)
.Build();

return Task.FromResult<AuthorizationPolicy?>(policy);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no async work .Using async without await would create a state machine unnecessarily. Task.FromResult returns an already-completed task with zero overhead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants