- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 253
 
Replaced the ForceUpdateActionFilter with ForceUpdateMiddleware #11502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 
          
 Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the  You can disable this status message by setting the  WalkthroughThe PR migrates app version validation from an action filter to HTTP middleware, moving it before authentication to prevent unauthorized errors on outdated clients. Related filters are reorganized into a RequestPipeline namespace, and the filter is removed entirely. Changes
 Sequence DiagramsequenceDiagram
    participant Client
    participant Server
    rect rgb(200, 220, 255)
    note over Client, Server: OLD: Action Filter (runs after auth)
    Client->>Server: Request (X-App-Version, X-App-Platform)
    Server->>Server: CORS Middleware
    Server->>Server: Authentication Middleware
    Server->>Server: ForceUpdateActionFilter ❌<br/>(version check)
    alt Version outdated
        Server-->>Client: 401 Unauthorized<br/>(auth failure masks version issue)
    else Version OK
        Server->>Server: Action execution
        Server-->>Client: 200 OK
    end
    end
    rect rgb(220, 255, 220)
    note over Client, Server: NEW: Middleware (runs before auth)
    Client->>Server: Request (X-App-Version, X-App-Platform)
    Server->>Server: CORS Middleware
    Server->>Server: ForceUpdateMiddleware ✓<br/>(version check)
    alt Version outdated
        Server-->>Client: ClientNotSupportedException<br/>(clear error, before auth)
    else Version OK
        Server->>Server: Authentication Middleware
        Server->>Server: Action execution
        Server-->>Client: 200 OK
    end
    end
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The changes involve understanding both filter and middleware execution order, verifying the logic migration is correct, and ensuring proper configuration in two Program.cs files. While heterogeneous (multiple file types affected), the changes follow a consistent refactoring pattern with clear intent to fix an authorization issue. Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (4 passed)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (8)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Filters/ForceUpdateActionFilter.cs(0 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Middlewares.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/RequestPipeline/ForceUpdateMiddleware.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/RequestPipeline/HangfireDashboardAuthorizationFilter.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/RequestPipeline/ODataOperationFilter.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs(3 hunks)
💤 Files with no reviewable changes (1)
- src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Filters/ForceUpdateActionFilter.cs
 
🔇 Additional comments (7)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/RequestPipeline/ODataOperationFilter.cs (1)
5-5: LGTM! Namespace refactoring aligns with the broader reorganization.The namespace change from
Boilerplate.Server.Api.FilterstoBoilerplate.Server.Api.RequestPipelineappropriately groups request pipeline components together.src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs (1)
190-190: LGTM! Correctly removes filter registration in favor of middleware approach.The simplification from
AddControllers(options => { ... })toAddControllers()is appropriate since version validation has been moved to middleware, which executes earlier in the request pipeline and solves the unauthorized error issue described in the PR objectives.src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Middlewares.cs (1)
46-49: LGTM! Correct middleware placement solves the unauthorized error issue.The ForceUpdateMiddleware is properly positioned after CORS (line 44) but before authentication (line 50). This ensures that version validation happens before authentication, preventing the unauthorized errors that occurred when the old ForceUpdateActionFilter executed after authentication middleware.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/RequestPipeline/HangfireDashboardAuthorizationFilter.cs (1)
4-4: LGTM! Namespace refactoring aligns with the broader reorganization.The namespace change appropriately groups request pipeline components together.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj (1)
78-78: LGTM! Global using directive updated to match namespace refactoring.The change ensures types from the new
Boilerplate.Server.Api.RequestPipelinenamespace are available throughout the project.src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs (2)
14-14: LGTM! Import updated to match namespace refactoring.The using directive correctly references the new
Boilerplate.Server.Api.RequestPipelinenamespace.
32-33: LGTM! Correct settings binding and middleware placement.The
ServerApiSettingsbinding (lines 32-33) enables the conditional registration ofForceUpdateMiddleware(lines 106-109), which is properly positioned after CORS but before authentication. This mirrors the Server.Api implementation and ensures consistent version validation across both server projects.Also applies to: 106-109
closes #11469
Summary by CodeRabbit