-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add NotAuthorizedPage to AuthorizeRouteView #64646
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
base: main
Are you sure you want to change the base?
Conversation
|
Greetings! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo! |
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
| [Parameter] | ||
| [DynamicallyAccessedMembers(LinkerFlags.Component)] | ||
| public Type? ForbiddenPage { get; set; } |
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.
This is wrong. The router should not be involved in this feature. It should all be part of AuthorizeRouteView. For starters we only want the ForbiddenPageType. We don't want a way to trigger Forbidden from Navigation manager.
@copilot redesign the fix based on these constraints. You also need to add E2E tests for it. See src/Components/Agents.md
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.
Redesigned the implementation based on your feedback. The feature is now solely in AuthorizeRouteView with a NotAuthorizedPage property. All Router, NavigationManager, and endpoint changes have been reverted.
Key changes (commit 0fa988e):
- Added
NotAuthorizedPageparameter toAuthorizeRouteViewthat renders a specified component when authorization fails - Added IComponent validation with clear error message
- Added unit tests and E2E tests for the new feature
Based on reviewer feedback: - Removed all changes from Router, NavigationManager, and SSR endpoints - Added NotAuthorizedPage property to AuthorizeRouteView only - When set, renders the specified page component instead of NotAuthorized content Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
…Page Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Add NotAuthorizedPage to AuthorizeRouteView
Add NotAuthorizedPage parameter to AuthorizeRouteView for consistent authorization failure handling
Description
Currently, Blazor apps rely on
AuthorizeView.NotAuthorizedfor authorization failures, but this only works when authorization happens at the Blazor level—not when triggered byAuthorizationMiddleware. This PR addsNotAuthorizedPagesupport toAuthorizeRouteViewto provide a consistent experience across SSR and interactive render modes.Changes
AuthorizeRouteView: AddedNotAuthorizedPageparameter that allows specifying a component type to render when authorization failsIComponentwith a clear error messageUsage
When
NotAuthorizedPageis set, it takes priority over theNotAuthorizedrender fragment content.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.