Skip to content
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

Warning about Razor Pages applicability seems incomplete #10996

Closed
joaofbantunes opened this issue Feb 18, 2019 — with docs.microsoft.com · 3 comments
Closed

Warning about Razor Pages applicability seems incomplete #10996

joaofbantunes opened this issue Feb 18, 2019 — with docs.microsoft.com · 3 comments
Assignees
Labels
Pri1 Source - Docs.ms Docs Customer feedback via GitHub Issue
Milestone

Comments

Copy link

joaofbantunes commented Feb 18, 2019

The warning at the top of the doc, indicating this doesn't apply to Razor Pages seems incomplete, because it makes it look as if role-based authorization doesn't apply at all to Razor Pages, but it does, only one should be aware of differences while using it, at least from my understanding.

Regarding the Authorize attribute, if we use it in the class directly, not the methods, it seems to work as expected, example:

[Authorize(Roles = "admin")]
public class IndexModel : PageModel

Another way to achieve this seems to be by using Razor Pages conventions, configured in the Startup class:

services
	.AddMvc()
	.AddRazorPagesOptions(options =>
	{
		options.Conventions.AuthorizePage("/Admin/Index", "APolicyThatRequiresARole");
	})

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added the Source - Docs.ms Docs Customer feedback via GitHub Issue label Feb 18, 2019
@guardrex
Copy link
Collaborator

Related to (and probably should be worked with) 👉 #6301

@blowdart
Copy link
Contributor

@ryanbrandenburg because Razor Pages are his and this is an MVC issue

@blowdart
Copy link
Contributor

Wrong ryan :) @rynowak

@Rick-Anderson Rick-Anderson added this to the Backlog milestone Feb 19, 2019
@pranavkm pranavkm assigned pranavkm and unassigned blowdart and rynowak Feb 25, 2019
Rick-Anderson pushed a commit that referenced this issue Feb 26, 2019
@dotnet dotnet locked and limited conversation to collaborators Oct 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Pri1 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

7 participants