ant-design-blazor / ant-design-blazor/ant-design-pro-blazor

使用 ReuseTabs 组件时,通过级联传入 RouteData 的方式会导致 AuthorizeRouteView 失效。

Aberta
#203 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
HTML
Estrelas
834
Forks
146
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

## 操作步骤:
1.使用 dotnet new antdesign -o MyAntDesignAppSimple 创建模板
2.添加文件 PersistingRevalidatingAuthenticationStateProvider
```
internal sealed class PersistingRevalidatingAuthenticationStateProvider : AuthenticationStateProvider
{

public override Task GetAuthenticationStateAsync()
{
//var cI = new ClaimsIdentity("test");
//cI.AddClaim(new Claim(ClaimTypes.Name, "admin"));
//cI.AddClaim(new Claim(ClaimTypes.Email, "admin@test"));

//var cP = new ClaimsPrincipal(cI);
//var state = new AuthenticationState(cP);
//var task = Task.FromResult(state);
//NotifyAuthenticationStateChanged(task);
//return task;
return Task.FromResult(new AuthenticationState(new ClaimsPrincipal()));
}
}

```
3. 在MyAntDesignAppSimple .Program.cs中添加以下内容
```
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped();
```
4. 添加一个需要权限的页面
```
@page "/counter"
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize]
Counter

Counter

没权限
有权限Hello @context.User.Identity?.IsAuthenticated.ToString();

Current count: @currentCount

Click me

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
```
5. 将Routes文件替换为以下内容
```





没权限路由




```
## 结果依旧可以导航到该页面
![image](https://github.com/user-attachments/assets/56956348-521c-4ae3-a8cd-a7c438c0c983)
## 后续
注释包裹AuthorizeRouteView 的CascadingValue,并向 ReuseTabs 组件传入 Body 参数后恢复正常
![image](https://github.com/user-attachments/assets/13b7f3fa-9a2a-4ff2-80f7-8dee835e6b52)

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.