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

Role-Based Authorization in Razor Pages #54

Closed
hishamco opened this issue Dec 1, 2018 · 4 comments
Closed

Role-Based Authorization in Razor Pages #54

hishamco opened this issue Dec 1, 2018 · 4 comments

Comments

@hishamco
Copy link
Owner

hishamco commented Dec 1, 2018

No description provided.

@neilbgr
Copy link

neilbgr commented Sep 22, 2021

Hi!
For your AuthorizeFolder() must be conventions.Add**Folder**ApplicationModelConvention(... instead of conventions.Add**Page**ApplicationModelConvention(... , isn't it ?
Thanks for your post.
Neil.

@hishamco
Copy link
Owner Author

Check the ASP.NET Core Docs

services.AddRazorPages(options =>
{
    options.Conventions.AuthorizePage("/Contact");
    options.Conventions.AuthorizeFolder("/Private");
    options.Conventions.AllowAnonymousToPage("/Private/PublicPage");
    options.Conventions.AllowAnonymousToFolder("/Private/PublicPages");
});

https://docs.microsoft.com/en-us/aspnet/core/security/authorization/razor-pages-authorization?view=aspnetcore-5.0

@neilbgr
Copy link

neilbgr commented Sep 22, 2021

I'd already seen this mdsm page. But it's consuming "Policies" not "Roles" like your great post http://hishambinateya.com/role-based-authorization-in-razor-pages
I just wanted to say to you that in the code of your extension method AuthorizeFolder(), there is a call to conventions.AddPageApplicationModelConvention(..) instead of conventions.AddFolderApplicationModelConvention().
(Note the diff between AddPageXxx/AddFolderXxx)
Only that.

@hishamco
Copy link
Owner Author

Thanks a lot @neilbgr, fixed in dedede5

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

No branches or pull requests

3 participants
@hishamco @neilbgr and others