Antiforgery integration for minimal APIs
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- csharp
调研方向
从所引用的 fundamentals/minimal-apis/samples/MyAntiForgery/Program.cs 入口点开始,重点查看第 16–17 行和第 57 行附近的 HTML 生成。比较 action 参数和 AntiforgeryTokenSet 是如何传入表单标记的;完成的标准是示例采用清晰、易维护的方式,不存在尚未解决的 null-token 问题,也没有不必要的重复 HTML。
由索引模型根据 Issue 内容生成。
描述
See Antiforgery integration for minimal APIs
and this sample
In this code I pass in the action so
app.MapGet("/DisableAntiforgery", () =>
{
return Results.Content(MyHtml.html("/todo"), "text/html");
});
app.MapGet("/post2", () =>
{
return Results.Content(MyHtml.html("/todo2"), "text/html");
});
Can use the same HTML when they pass in the action arg.
Is there a clean way to do this to pass in an arg for
<input name="{token.FormFieldName}"
type="hidden" value="{token.RequestToken}" />
Maybe that makes things too messy. Perhaps I should duplicate most of the HTML and not get the HTML from a method while passing the action.
public static string html2(string action, AntiforgeryTokenSet token) => $"""
<html><body>
<form action="{action}" method="POST" enctype="multipart/form-data">
<input name="{token.FormFieldName}"
type="hidden" value="{token.RequestToken}" />
<input type="text" name="name" />
<input type="date" name="dueDate" />
<input type="checkbox" name="isCompleted" />
<input type="submit" />
</form>
</body></html>
""";
Works, but I'm not sure it's an improvement. There's no way to pass in a null token.
@sammychinedu2ky @david-acker
cc @guardrex
- 主要语言
- C#
- 星标
- 225
- 派生
- 169
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/AspNetCore.Docs.Samples 的其他 Issue
-
Move GoogleAuthticationExample to this repo可能重新可做 @Rick-Anderson 于 745 天前认领,目前没有进行中的 PR。 未关闭
dotnet/AspNetCore.Docs.Samples#264 · 已指派 1 人 ·
-
难度 3/5 1-2 天 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 45/100
查看 dotnet/AspNetCore.Docs.Samples 的全部 Issue
相似的 Issue
-
is:bug is:FQNIssue
难度 2/5 1-3 小时 新手友好度 72/100
nunit/nunit3-vs-adapter#1527 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
bug effort:S P3
难度 2/5 1-3 小时 新手友好度 72/100
nightscout/nocturne#2840 ·
维护者通常 1 天内回复
-
track:release
难度 2/5 1-3 小时 新手友好度 80/100
-
[Bug] [Go] Ack returns nil when the server answers with a non-OK status可能已有人在做 @leizhiyuan 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
apache/rocketmq-clients#1465 ·
维护者通常 2 天内回复