是否在 Blazor 应用程序中实施了访问被拒绝的路径
Is there implemented Access denied path in Blazor app
Blazor 应用中是否有内置 AccessDeniedPath
功能。
我的应用程序对某些组件使用基于角色的授权方法。例如 (@attribute [Authorize(Roles ="Admin")]
)
在我的 App.razor
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<h1>Sorry</h1>
<p>You're not authorized to reach this page.</p>
<p>You may need to log in as a different user.</p>
</NotAuthorized>
<Authorizing>
<h1>Authentication in progress</h1>
<p>Only visible while authentication is in progress.</p>
</Authorizing>
</AuthorizeRouteView>
属于 NotAuthorized
的请求是来自无权限用户还是匿名用户(根本未授权)。
有一个 context
可用于确定当前用户是否已通过身份验证。
例如:
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" >
<NotAuthorized>
@if(!context.User.Identity.IsAuthenticated)
{
<p> You need Login! </p>
} else{
<p> Sorry, the content here is not for you! </p>
@*or render or component like <AccessDenied /> directly *@
}
</NotAuthorized>
<Authorizing>
<h1>Authentication in progress</h1>
<p>Only visible while authentication is in progress.</p>
</Authorizing>
</AuthorizeRouteView>
Blazor 应用中是否有内置 AccessDeniedPath
功能。
我的应用程序对某些组件使用基于角色的授权方法。例如 (@attribute [Authorize(Roles ="Admin")]
)
在我的 App.razor
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<h1>Sorry</h1>
<p>You're not authorized to reach this page.</p>
<p>You may need to log in as a different user.</p>
</NotAuthorized>
<Authorizing>
<h1>Authentication in progress</h1>
<p>Only visible while authentication is in progress.</p>
</Authorizing>
</AuthorizeRouteView>
属于 NotAuthorized
的请求是来自无权限用户还是匿名用户(根本未授权)。
有一个 context
可用于确定当前用户是否已通过身份验证。
例如:
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" >
<NotAuthorized>
@if(!context.User.Identity.IsAuthenticated)
{
<p> You need Login! </p>
} else{
<p> Sorry, the content here is not for you! </p>
@*or render or component like <AccessDenied /> directly *@
}
</NotAuthorized>
<Authorizing>
<h1>Authentication in progress</h1>
<p>Only visible while authentication is in progress.</p>
</Authorizing>
</AuthorizeRouteView>