You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicvoidConfigure(IApplicationBuilderapp,IWebHostEnvironmentenv,IApiapi){
...// Custom permissionsApp.Permissions["App"].Add(newPiranha.Security.PermissionItem{Title="Read secured posts",Name="ReadSecuredPosts"});// Custom middleware that checks for status 401app.Use(async(ctx,next)=>{awaitnext();if(ctx.Response.StatusCode==401){ctx.Response.Redirect("/login");}});
...}
Proposed solution
Adding a new helper method to the PiranhaServiceBuilder that simplifies the setup for all basic scenarios. The manual code above would be replaced by the following:
The method UsePermission will perform the following:
Add a new Policy to ASP.NET with the given name
Require a single claim with the same name as the Policy
Add a new item into Piranha.App.Permissions with the same name (and optional title)
This means that it won't be supported adding composite policies this way that require several different claims. But as the whole purpose of these methods are to simplify we think this is ok.
tidyui
changed the title
Add middleware component to handle unauthorized page access
Add tools to simplify authentication in the web application
Jun 29, 2020
tidyui
changed the title
Add tools to simplify authentication in the web application
Simplify authentication in the web application
Jun 29, 2020
Add middleware as described in the following documentation article to the core framework:
https://piranhacms.org/docs/tutorials/securing-pages
The text was updated successfully, but these errors were encountered: