"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[2379],{7824:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>o,default:()=>x,frontMatter:()=>c,metadata:()=>l,toc:()=>h});var s=r(5893),i=r(1151),t=r(510);const c={id:"auth-control",title:"15. \u5b89\u5168\u9274\u6743",sidebar_label:"15. \u5b89\u5168\u9274\u6743"},o=void 0,l={id:"auth-control",title:"15. \u5b89\u5168\u9274\u6743",description:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7",source:"@site/docs/auth-control.mdx",sourceDirName:".",slug:"/auth-control",permalink:"/docs/auth-control",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/auth-control.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1693600484,formattedLastUpdatedAt:"Sep 1, 2023",frontMatter:{id:"auth-control",title:"15. \u5b89\u5168\u9274\u6743",sidebar_label:"15. \u5b89\u5168\u9274\u6743"},sidebar:"docs",previous:{title:"14. \u5206\u5e03\u5f0f\u7f13\u5b58",permalink:"/docs/cache"},next:{title:"16. CORS \u8de8\u57df",permalink:"/docs/cors"}},d={},h=[{value:"15.1 \u4ec0\u4e48\u662f\u9274\u6743",id:"151-\u4ec0\u4e48\u662f\u9274\u6743",level:2},{value:"15.1.1 \u5e38\u89c1\u7684\u9274\u6743\u65b9\u5f0f",id:"1511-\u5e38\u89c1\u7684\u9274\u6743\u65b9\u5f0f",level:3},{value:"15.2 \u5982\u4f55\u4f7f\u7528",id:"152-\u5982\u4f55\u4f7f\u7528",level:2},{value:"15.2.1 \u6dfb\u52a0 Cookie
\u8eab\u4efd\u9a8c\u8bc1",id:"1521-\u6dfb\u52a0-cookie-\u8eab\u4efd\u9a8c\u8bc1",level:3},{value:"15.2.2 \u6dfb\u52a0 Jwt
\u8eab\u4efd\u9a8c\u8bc1",id:"1522-\u6dfb\u52a0-jwt-\u8eab\u4efd\u9a8c\u8bc1",level:3},{value:"15.2.3 \u6df7\u5408\u8eab\u4efd\u9a8c\u8bc1",id:"1523-\u6df7\u5408\u8eab\u4efd\u9a8c\u8bc1",level:3},{value:"15.3 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u6388\u6743",id:"153-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u6388\u6743",level:2},{value:"15.3.1 AppAuthorizeHandler
",id:"1531-appauthorizehandler",level:3},{value:"15.3.2 \u5b8c\u5168\u81ea\u5b9a\u4e49\u6388\u6743",id:"1532-\u5b8c\u5168\u81ea\u5b9a\u4e49\u6388\u6743",level:3},{value:"15.4 \u6388\u6743\u7279\u6027\u53ca\u5168\u5c40\u6388\u6743",id:"154-\u6388\u6743\u7279\u6027\u53ca\u5168\u5c40\u6388\u6743",level:2},{value:"15.4.1 \u5168\u5c40\u6388\u6743",id:"1541-\u5168\u5c40\u6388\u6743",level:3},{value:"15.4.2 \u533f\u540d\u8bbf\u95ee",id:"1542-\u533f\u540d\u8bbf\u95ee",level:3},{value:"15.5 \u81ea\u52a8\u5237\u65b0 Token",id:"155-\u81ea\u52a8\u5237\u65b0-token",level:2},{value:"15.5.1 \u540e\u7aef\u767b\u5f55\u90e8\u5206",id:"1551-\u540e\u7aef\u767b\u5f55\u90e8\u5206",level:3},{value:"15.5.2 \u540e\u7aef\u6388\u6743 Handler
\u90e8\u5206",id:"1552-\u540e\u7aef\u6388\u6743-handler-\u90e8\u5206",level:3},{value:"15.5.3 \u5ba2\u6237\u7aef\u90e8\u5206",id:"1553-\u5ba2\u6237\u7aef\u90e8\u5206",level:3},{value:"15.6 \u83b7\u53d6 Jwt
\u5b58\u50a8\u7684\u4fe1\u606f",id:"156-\u83b7\u53d6-jwt-\u5b58\u50a8\u7684\u4fe1\u606f",level:2},{value:"15.7 \u524d\u7aef\u89e3\u5bc6 JWT
\u4fe1\u606f",id:"157-\u524d\u7aef\u89e3\u5bc6-jwt-\u4fe1\u606f",level:2},{value:"15.8 Jwt
\u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u76d1\u542c",id:"158-jwt-\u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u76d1\u542c",level:2},{value:"15.8.1 \u5b9e\u73b0 Url
\u53c2\u6570\u9a8c\u8bc1 Token
",id:"1581-\u5b9e\u73b0-url-\u53c2\u6570\u9a8c\u8bc1-token",level:3},{value:"15.9 \u5173\u4e8e Blazor + WebAPI
\u6df7\u5408\u6388\u6743",id:"159-\u5173\u4e8e-blazor--webapi-\u6df7\u5408\u6388\u6743",level:2},{value:"15.10 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"1510-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function a(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",hr:"hr",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.a)(),...e.components},{Details:r}=n;return r||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(r,{children:[(0,s.jsx)("summary",{children:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7"}),(0,s.jsx)("div",{children:(0,s.jsx)("div",{children:(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u95ee\u9898\u4fee\u590d"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(t.Z,{children:"\u4fee\u590d"})," \u4f7f\u7528\u5237\u65b0 ",(0,s.jsx)(n.code,{children:"Token"})," \u4e5f\u80fd\u901a\u8fc7\u9274\u6743\u68c0\u67e5\u4e25\u91cd\u5b89\u5168 ",(0,s.jsx)(n.code,{children:"Bug"})," ",(0,s.jsx)("sup",{children:"4.8.8.42"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.08.28"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I7TII4",children:"#I7TII4"})]}),"\n"]}),"\n"]}),"\n"]})})})]}),"\n",(0,s.jsx)(n.h2,{id:"151-\u4ec0\u4e48\u662f\u9274\u6743",children:"15.1 \u4ec0\u4e48\u662f\u9274\u6743"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u9274\u6743\u5b9e\u9645\u4e0a\u5c31\u662f\u4e00\u79cd\u8eab\u4efd\u8ba4\u8bc1"}),"\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u7531\u7528\u6237\u63d0\u4f9b\u51ed\u636e\uff0c\u7136\u540e\u5c06\u5176\u4e0e\u5b58\u50a8\u5728\u64cd\u4f5c\u7cfb\u7edf\u3001\u6570\u636e\u5e93\u3001\u5e94\u7528\u6216\u8d44\u6e90\u4e2d\u7684\u51ed\u636e\u8fdb\u884c\u6bd4\u8f83\u3002 \u5728\u6388\u6743\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u51ed\u636e\u5339\u914d\uff0c\u5219\u7528\u6237\u8eab\u4efd\u9a8c\u8bc1\u6210\u529f\uff0c\u53ef\u6267\u884c\u5df2\u5411\u5176\u6388\u6743\u7684\u64cd\u4f5c\u3002 \u6388\u6743\u6307\u5224\u65ad\u5141\u8bb8\u7528\u6237\u6267\u884c\u7684\u64cd\u4f5c\u7684\u8fc7\u7a0b\u3002\r\n\u4e5f\u53ef\u4ee5\u5c06\u8eab\u4efd\u9a8c\u8bc1\u7406\u89e3\u4e3a\u8fdb\u5165\u7a7a\u95f4\uff08\u4f8b\u5982\u670d\u52a1\u5668\u3001\u6570\u636e\u5e93\u3001\u5e94\u7528\u6216\u8d44\u6e90\uff09\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u800c\u6388\u6743\u662f\u7528\u6237\u53ef\u4ee5\u5bf9\u8be5\u7a7a\u95f4\uff08\u670d\u52a1\u5668\u3001\u6570\u636e\u5e93\u6216\u5e94\u7528\uff09\u5185\u7684\u54ea\u4e9b\u5bf9\u8c61\u6267\u884c\u54ea\u4e9b\u64cd\u4f5c\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"1511-\u5e38\u89c1\u7684\u9274\u6743\u65b9\u5f0f",children:"15.1.1 \u5e38\u89c1\u7684\u9274\u6743\u65b9\u5f0f"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"HTTP Basic Authentication"})}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u662f ",(0,s.jsx)(n.code,{children:"HTTP"})," \u534f\u8bae\u5b9e\u73b0\u7684\u57fa\u672c\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u6211\u4eec\u5728\u6d4f\u89c8\u7f51\u9875\u65f6\uff0c\u4ece\u6d4f\u89c8\u5668\u6b63\u4e0a\u65b9\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u8981\u6c42\u6211\u4eec\u8f93\u5165\u8d26\u53f7\u5bc6\u7801\uff0c\u6b63\u662f\u4f7f\u7528\u4e86\u8fd9\u79cd\u8ba4\u8bc1\u65b9\u5f0f"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"Session + Cookie"})}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5229\u7528\u670d\u52a1\u5668\u7aef\u7684 session\uff08\u4f1a\u8bdd\uff09\u548c\u6d4f\u89c8\u5668\u7aef\u7684 cookie \u6765\u5b9e\u73b0\u524d\u540e\u7aef\u7684\u8ba4\u8bc1\uff0c\u7531\u4e8e http \u8bf7\u6c42\u65f6\u662f\u65e0\u72b6\u6001\u7684\uff0c\u670d\u52a1\u5668\u6b63\u5e38\u60c5\u51b5\u4e0b\u662f\u4e0d\u77e5\u9053\u5f53\u524d\u8bf7\u6c42\u4e4b\u524d\u6709\u6ca1\u6709\u6765\u8fc7\uff0c\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u5982\u679c\u8981\u8bb0\u5f55\u72b6\u6001\uff0c\u5c31\u9700\u8981\u5728\u670d\u52a1\u5668\u7aef\u521b\u5efa\u4e00\u4e2a\u4f1a\u8bdd(session),\u5c06\u540c\u4e00\u4e2a\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u90fd\u7ef4\u62a4\u5728\u5404\u81ea\u7684\u4f1a\u8bdd\u4e2d\uff0c\u6bcf\u5f53\u8bf7\u6c42\u5230\u8fbe\u670d\u52a1\u5668\u7aef\u7684\u65f6\u5019\uff0c\u5148\u53bb\u67e5\u4e00\u4e0b\u8be5\u5ba2\u6237\u7aef\u6709\u6ca1\u6709\u5728\u670d\u52a1\u5668\u7aef\u521b\u5efa session\uff0c\u5982\u679c\u6709\u5219\u5df2\u7ecf\u8ba4\u8bc1\u6210\u529f\u4e86\uff0c\u5426\u5219\u5c31\u6ca1\u6709\u8ba4\u8bc1\u3002"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"Token"})}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5ba2\u6237\u7aef\u5728\u9996\u6b21\u767b\u5f55\u4ee5\u540e\uff0c\u670d\u52a1\u7aef\u518d\u6b21\u63a5\u6536 ",(0,s.jsx)(n.code,{children:"HTTP"})," \u8bf7\u6c42\u7684\u65f6\u5019\uff0c\u5c31\u53ea\u8ba4 ",(0,s.jsx)(n.code,{children:"Token"})," \u4e86\uff0c\u8bf7\u6c42\u53ea\u8981\u6bcf\u6b21\u628a ",(0,s.jsx)(n.code,{children:"Token"})," \u5e26\u4e0a\u5c31\u884c\u4e86\uff0c\u670d\u52a1\u5668\u7aef\u4f1a\u62e6\u622a\u6240\u6709\u7684\u8bf7\u6c42\uff0c\u7136\u540e\u6821\u9a8c ",(0,s.jsx)(n.code,{children:"Token"})," \u7684\u5408\u6cd5\u6027\uff0c\u5408\u6cd5\u5c31\u653e\u884c\uff0c\u4e0d\u5408\u6cd5\u5c31\u8fd4\u56de 401\uff08\u9274\u6743\u5931\u8d25\uff09"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Token"}),"\u9a8c\u8bc1\u6bd4\u8f83\u7075\u6d3b\uff0c\u9002\u7528\u4e8e\u5927\u90e8\u5206\u573a\u666f\u3002\u5e38\u7528\u7684 ",(0,s.jsx)(n.code,{children:"Token"})," \u9274\u6743\u65b9\u5f0f\u7684\u89e3\u51b3\u65b9\u6848\u662f ",(0,s.jsx)(n.code,{children:"JWT"}),"\uff0c",(0,s.jsx)(n.code,{children:"JWT"})," \u662f\u901a\u8fc7\u5bf9\u5e26\u6709\u76f8\u5173\u7528\u6237\u4fe1\u606f\u7684\u8fdb\u884c\u52a0\u5bc6\uff0c\u52a0\u5bc6\u7684\u65b9\u5f0f\u6bd4\u8f83\u7075\u6d3b\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u5177\u4f53\u8bbe\u8ba1\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"OAuth"})}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"OAuth\uff08\u5f00\u653e\u6388\u6743\uff09\u662f\u4e00\u4e2a\u5f00\u653e\u6807\u51c6\uff0c\u5141\u8bb8\u7528\u6237\u6388\u6743\u7b2c\u4e09\u65b9\u7f51\u7ad9\u8bbf\u95ee\u4ed6\u4eec\u5b58\u50a8\u5728\u53e6\u5916\u7684\u670d\u52a1\u63d0\u4f9b\u8005\u4e0a\u7684\u4fe1\u606f\uff0c\u800c\u4e0d\u9700\u8981\u5c06\u7528\u6237\u540d\u548c\u5bc6\u7801\u63d0\u4f9b\u7ed9\u7b2c\u4e09\u65b9\u7f51\u7ad9\u6216\u5206\u4eab\u4ed6\u4eec\u6570\u636e\u7684\u6240\u6709\u5185\u5bb9\uff0c\u4e3a\u4e86\u4fdd\u62a4\u7528\u6237\u6570\u636e\u7684\u5b89\u5168\u548c\u9690\u79c1\uff0c\u7b2c\u4e09\u65b9\u7f51\u7ad9\u8bbf\u95ee\u7528\u6237\u6570\u636e\u524d\u90fd\u9700\u8981\u663e\u5f0f\u7684\u5411\u7528\u6237\u5f81\u6c42\u6388\u6743\u3002\u6211\u4eec\u5e38\u89c1\u7684\u63d0\u4f9b OAuth \u8ba4\u8bc1\u670d\u52a1\u7684\u5382\u5546\u6709\u652f\u4ed8\u5b9d\u3001QQ \u548c\u5fae\u4fe1\u3002"}),"\n",(0,s.jsx)(n.p,{children:"OAuth \u534f\u8bae\u53c8\u6709 1.0 \u548c 2.0 \u4e24\u4e2a\u7248\u672c\u3002\u76f8\u6bd4\u8f83 1.0 \u7248\uff0c2.0 \u7248\u6574\u4e2a\u6388\u6743\u9a8c\u8bc1\u6d41\u7a0b\u66f4\u7b80\u5355\u66f4\u5b89\u5168\uff0c\u4e5f\u662f\u76ee\u524d\u6700\u4e3b\u8981\u7684\u7528\u6237\u8eab\u4efd\u9a8c\u8bc1\u548c\u6388\u6743\u65b9\u5f0f\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"152-\u5982\u4f55\u4f7f\u7528",children:"15.2 \u5982\u4f55\u4f7f\u7528"}),"\n",(0,s.jsxs)(n.admonition,{title:"\u914d\u7f6e\u4e4b\u524d",type:"info",children:[(0,s.jsxs)(n.p,{children:["\u5728\u6dfb\u52a0\u6388\u6743\u670d\u52a1\u4e4b\u524d\uff0c\u8bf7\u5148\u786e\u4fdd ",(0,s.jsx)(n.code,{children:"Startup.cs"})," \u4e2d ",(0,s.jsx)(n.code,{children:"Configure"})," \u662f\u5426\u6dfb\u52a0\u4e86\u4ee5\u4e0b\u4e24\u4e2a\u4e2d\u95f4\u4ef6\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"app.UseAuthentication();\r\napp.UseAuthorization();\n"})})]}),"\n",(0,s.jsxs)(n.h3,{id:"1521-\u6dfb\u52a0-cookie-\u8eab\u4efd\u9a8c\u8bc1",children:["15.2.1 ",(0,s.jsxs)("s",{children:["\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"Cookie"})," \u8eab\u4efd\u9a8c\u8bc1"]})]}),"\n",(0,s.jsx)(n.admonition,{title:"\u4f7f\u7528\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f ",(0,s.jsx)(n.code,{children:"WebAPI"}),"\uff0c\u5219\u8be5\u5c0f\u8282\u53ef\u5ffd\u7565\uff0c\u901a\u5e38 ",(0,s.jsx)(n.code,{children:"WebAPI"})," \u4f7f\u7528\u7684\u662f ",(0,s.jsx)(n.code,{children:"JWT"})," \u6388\u6743\u65b9\u5f0f\uff0c\u800c\u975e ",(0,s.jsx)(n.code,{children:"Cookie"}),"\u3002"]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// Cookies\u5355\u72ec\u8eab\u4efd\u9a8c\u8bc1\r\nservices.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)\r\n .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, b =>\r\n {\r\n b.LoginPath = "/Home/Login";\r\n });\n'})}),"\n",(0,s.jsxs)(n.h3,{id:"1522-\u6dfb\u52a0-jwt-\u8eab\u4efd\u9a8c\u8bc1",children:["15.2.2 \u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"Jwt"})," \u8eab\u4efd\u9a8c\u8bc1"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,s.jsx)(n.code,{children:"Furion.Extras.Authentication.JwtBearer"})," \u62d3\u5c55\u5305"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"Startup.cs"})," \u4e2d\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"AddJwt"})," \u670d\u52a1\uff0c\u6ce8\u610f\uff0c",(0,s.jsxs)(n.strong,{children:["\u5fc5\u987b\u5728 ",(0,s.jsx)(n.code,{children:".AddControllers()"})," \u4e4b\u524d\u6ce8\u518c\uff01\uff01"]})]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,5}",children:"// \u9ed8\u8ba4\u6388\u6743\u673a\u5236\uff0c\u9700\u6388\u6743\u7684\u5373\u53ef\uff08\u65b9\u6cd5\uff09\u9700\u8d34 `[Authorize]` \u7279\u6027\r\nservices.AddJwt();\r\n\r\n// \u542f\u7528\u5168\u5c40\u6388\u6743\uff0c\u8fd9\u6837\u6bcf\u4e2a\u63a5\u53e3\u90fd\u5fc5\u987b\u6388\u6743\u624d\u80fd\u8bbf\u95ee\uff0c\u65e0\u9700\u8d34 `[Authorize]` \u7279\u6027\uff0c\u63a8\u8350\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\u2764\ufe0f\r\n// services.AddJwt(enableGlobalAuthorize:true);\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["\u6ce8\uff1a\u5982\u679c\u9879\u76ee\u4f7f\u7528\u4e86 ",(0,s.jsx)(n.code,{children:"services.AddSignalR();"})," \u670d\u52a1\uff0c\u90a3\u4e48\u8be5\u670d\u52a1\u5fc5\u987b\u5728 ",(0,s.jsx)(n.code,{children:"services.AddJwt"})," \u4e4b\u540e\u6ce8\u518c\u3002"]})}),"\n",(0,s.jsxs)(n.admonition,{title:"\u989d\u5916\u8865\u5145",type:"note",children:[(0,s.jsxs)(n.p,{children:["\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"JwtHandler"})," \u4ee3\u7801\uff1a"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {8,14}",children:"using Furion.Authorization;\r\nusing Microsoft.AspNetCore.Authorization;\r\nusing Microsoft.AspNetCore.Http;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace FurionApi.Web.Core;\r\n\r\npublic class JwtHandler : AppAuthorizeHandler\r\n{\r\n public override Task PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)\r\n {\r\n // \u8fd9\u91cc\u5199\u60a8\u7684\u6388\u6743\u5224\u65ad\u903b\u8f91\uff0c\u6388\u6743\u901a\u8fc7\u8fd4\u56de true\uff0c\u5426\u5219\u8fd4\u56de false\r\n\r\n return Task.FromResult(true);\r\n }\r\n}\n"})})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u81ea\u5b9a\u4e49 ",(0,s.jsx)(n.code,{children:"Jwt"})," \u914d\u7f6e\uff08",(0,s.jsx)(n.strong,{children:"\u9ed8\u8ba4\u65e0\u9700\u914d\u7f6e"}),"\uff09"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"showLineNumbers {4,6,8}",children:'{\r\n "JWTSettings": {\r\n "ValidateIssuerSigningKey": true, // \u662f\u5426\u9a8c\u8bc1\u5bc6\u94a5\uff0cbool \u7c7b\u578b\uff0c\u9ed8\u8ba4true\r\n "IssuerSigningKey": "\u4f60\u7684\u5bc6\u94a5", // \u5bc6\u94a5\uff0cstring \u7c7b\u578b\uff0c\u5fc5\u987b\u662f\u590d\u6742\u5bc6\u94a5\uff0c\u957f\u5ea6\u5927\u4e8e16\uff0c.NET8+ \u957f\u5ea6\u9700\u5927\u4e8e 32\r\n "ValidateIssuer": true, // \u662f\u5426\u9a8c\u8bc1\u7b7e\u53d1\u65b9\uff0cbool \u7c7b\u578b\uff0c\u9ed8\u8ba4true\r\n "ValidIssuer": "\u7b7e\u53d1\u65b9", // \u7b7e\u53d1\u65b9\uff0cstring \u7c7b\u578b\r\n "ValidateAudience": true, // \u662f\u5426\u9a8c\u8bc1\u7b7e\u6536\u65b9\uff0cbool \u7c7b\u578b\uff0c\u9ed8\u8ba4true\r\n "ValidAudience": "\u7b7e\u6536\u65b9", // \u7b7e\u6536\u65b9\uff0cstring \u7c7b\u578b\r\n "ValidateLifetime": true, // \u662f\u5426\u9a8c\u8bc1\u8fc7\u671f\u65f6\u95f4\uff0cbool \u7c7b\u578b\uff0c\u9ed8\u8ba4true\uff0c\u5efa\u8baetrue\r\n "ExpiredTime": 20, // \u8fc7\u671f\u65f6\u95f4\uff0clong \u7c7b\u578b\uff0c\u5355\u4f4d\u5206\u949f\uff0c\u9ed8\u8ba420\u5206\u949f\r\n "ClockSkew": 5, // \u8fc7\u671f\u65f6\u95f4\u5bb9\u9519\u503c\uff0clong \u7c7b\u578b\uff0c\u5355\u4f4d\u79d2\uff0c\u9ed8\u8ba4 5\u79d2\r\n "Algorithm": "HS256" // \u52a0\u5bc6\u7b97\u6cd5\uff0cstring \u7c7b\u578b\uff0c\u9ed8\u8ba4 HS256\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{title:"\u7cfb\u7edf\u5b89\u5168\u6ce8\u610f\u4e8b\u9879",type:"warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u4e3a\u4e86\u65b9\u4fbf\u5f00\u53d1\uff0c\u5df2\u7ecf\u81ea\u52a8\u6dfb\u52a0\u4e86 ",(0,s.jsx)(n.code,{children:"Jwt"})," \u9ed8\u8ba4\u914d\u7f6e\u3002\u5efa\u8bae\u6bcf\u4e2a\u9879\u76ee\u90fd\u5e94\u8be5\u5355\u72ec\u914d\u7f6e ",(0,s.jsx)(n.code,{children:"IssuerSigningKey"}),"\uff0c",(0,s.jsx)(n.code,{children:"ValidIssuer"}),"\uff0c",(0,s.jsx)(n.code,{children:"ValidAudience"})," \u8fd9\u4e09\u4e2a\u3002\u5426\u5219\u540c\u6837\u7528\u4e86 ",(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u751f\u6210\u7684 ",(0,s.jsx)(n.code,{children:"Token"})," \u53ef\u80fd\u5b58\u5728\u76f8\u4e92\u8bbf\u95ee\u5404\u81ea\u7cfb\u7edf\u7684\u98ce\u9669\u3002"]})}),"\n",(0,s.jsxs)(n.admonition,{type:"important",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:[(0,s.jsx)(n.code,{children:"Algorithm"})," \u7b97\u6cd5\u652f\u6301\u5217\u8868"]}),(0,s.jsxs)(n.p,{children:["\u76ee\u524d\u652f\u6301\u7684",(0,s.jsx)(n.code,{children:"\u52a0\u5bc6\u7b97\u6cd5"})]}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"HS256"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"HS384"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"HS512"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"PS256"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"PS384"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"PS512"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"RS256"}),"\uff1a\u9700\u81ea\u884c\u5b9e\u73b0\u7b97\u6cd5"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"RS384"}),"\uff1a\u9700\u81ea\u884c\u5b9e\u73b0\u7b97\u6cd5"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"RS512"}),"\uff1a\u9700\u81ea\u884c\u5b9e\u73b0\u7b97\u6cd5"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"ES256"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"ES256K"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"ES384"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"ES512"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"EdDSA"})}),"\n"]}),(0,s.jsxs)(n.p,{children:["\u8be6\u60c5\u8bf7\u67e5\u9605 ",(0,s.jsx)(n.a,{href:"https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/dev/src/Microsoft.IdentityModel.Tokens/SecurityAlgorithms.cs",children:"SecurityAlgorithms"})]})]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u2764\ufe0f \u2764\ufe0f \u751f\u6210 ",(0,s.jsx)(n.code,{children:"Token"})]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u901a\u5e38\u6211\u4eec\u9700\u8981\u5728\u767b\u5f55\u6210\u529f\u4e4b\u540e\u751f\u6210 ",(0,s.jsx)(n.code,{children:"JWT"})," Token \u5e76\u8fd4\u56de\uff0c\u53ef\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"JWTEncryption.Encrypt"})," \u9759\u6001\u65b9\u6cd5\u751f\u6210\uff0c\u5982\uff1a"]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:["\u5173\u4e8e ",(0,s.jsx)(n.code,{children:"Token"})," \u7684\u503c"]}),(0,s.jsxs)(n.p,{children:["\u5b57\u5178 ",(0,s.jsx)(n.code,{children:"Dictionary"})," \u4e2d\u7684\u503c\u652f\u6301\u6240\u6709\u57fa\u5143\u7c7b\u578b\u548c\u57fa\u5143\u7c7b\u578b\u7ec4\u6210\u7684\u503c\uff0c\u4f46\u5e94\u5c3d\u53ef\u80fd\u907f\u514d\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"\u6570\u7ec4"})," \u503c\u3002"]})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,4-5}",children:'// \u751f\u6210 token\r\nvar accessToken = JWTEncryption.Encrypt(new Dictionary()\r\n {\r\n { "UserId", user.Id }, // \u5b58\u50a8Id\r\n { "Account",user.Account }, // \u5b58\u50a8\u7528\u6237\u540d\r\n });\n'})}),"\n",(0,s.jsx)(n.h3,{id:"1523-\u6df7\u5408\u8eab\u4efd\u9a8c\u8bc1",children:"15.2.3 \u6df7\u5408\u8eab\u4efd\u9a8c\u8bc1"}),"\n",(0,s.jsxs)(n.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u9700\u8981\u591a\u79cd\u6df7\u5408\u9a8c\u8bc1\u65b9\u5f0f\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u9700\u8981\u914d\u7f6e\u4e00\u4e2a",(0,s.jsx)(n.strong,{children:"\u4e3b\u9a8c\u8bc1"})," \u65b9\u5f0f\uff0c\u6240\u4ee5\u9700\u8981\u4fee\u6539 ",(0,s.jsx)(n.code,{children:"options.DefaultAuthenticateScheme"})," \u548c ",(0,s.jsx)(n.code,{children:"options.DefaultChallengeScheme"})," \u4e3a\u4e3b\u9a8c\u8bc1\u65b9\u5f0f\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u9700\u7b2c\u4e8c\u79cd\u65b9\u5f0f\uff0c\u53ea\u9700\u8981\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"[Authorize(JwtBearerDefaults.AuthenticationScheme)]"})," \u8d34\u5373\u53ef\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"JWT"})," \u548c ",(0,s.jsx)(n.code,{children:"Cookies"})," \u6df7\u5408\u8eab\u4efd\u9a8c\u8bc1"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3-4,6}",children:'services.AddJwt(options =>\r\n{\r\n options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; // \u66f4\u6539\u9ed8\u8ba4\u9a8c\u8bc1\u4e3a Cookies\r\n options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; // \u66f4\u6539\u9ed8\u8ba4\u9a8c\u8bc1\u4e3a Cookies\r\n})\r\n.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>\r\n{\r\n options.LoginPath = "/Home/Login";\r\n});\n'})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"JWT"})," \u548c ",(0,s.jsx)(n.code,{children:"Windows"})," \u8eab\u4efd\u9a8c\u8bc1\u6df7\u5408\u9a8c\u8bc1"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,3-4,6}",children:"services.AddJwt(options =>\r\n{\r\n options.DefaultAuthenticateScheme = NegotiateDefaults.AuthenticationScheme; // \u66f4\u6539\u9ed8\u8ba4\u9a8c\u8bc1\u4e3a Windows \u8eab\u4efd\u9a8c\u8bc1\r\n options.DefaultChallengeScheme = NegotiateDefaults.AuthenticationScheme; // \u66f4\u6539\u9ed8\u8ba4\u9a8c\u8bc1\u4e3a Windows \u8eab\u4efd\u9a8c\u8bc1\r\n})\r\n.AddNegotiate();\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5e94\u7528\u4f8b\u5b50"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1-2,7-8}",children:"// \u8d34\u4e86 [Authorize] \u5219\u8868\u793a\u5e94\u7528 JwtBearerDefaults.AuthenticationScheme\r\n[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]\r\npublic class ApiServices : IDynamicApiController\r\n{\r\n}\r\n\r\n// \u4e0d\u8d34\u5219\u5e94\u7528\u4e3b\u9a8c\u8bc1\uff0c\u4e5f\u5373\u662f `DefaultAuthenticateScheme` \u8bbe\u7f6e\u7684\r\npublic class HomeController: Controller\r\n{\r\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"153-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u6388\u6743",children:"15.3 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u6388\u6743"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u9ad8\u7ea7\u7b56\u7565\u9274\u6743\u548c\u6388\u6743\u65b9\u5f0f\uff0c\u901a\u8fc7\u8be5\u7b56\u7565\u6388\u6743\u65b9\u5f0f\u53ef\u4ee5\u5b9e\u73b0\u4efb\u4f55\u81ea\u5b9a\u4e49\u6388\u6743\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"1531-appauthorizehandler",children:["15.3.1 ",(0,s.jsx)(n.code,{children:"AppAuthorizeHandler"})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u63d0\u4f9b\u4e86 ",(0,s.jsx)(n.code,{children:"AppAuthorizeHandler"})," \u7b56\u7565\u6388\u6743\u5904\u7406\u7a0b\u5e8f\u63d0\u4f9b\u57fa\u7c7b\uff0c\u53ea\u9700\u8981\u521b\u5efa\u81ea\u5df1\u7684 ",(0,s.jsx)(n.code,{children:"Handler"})," \u7ee7\u627f\u5b83\u5373\u53ef\u3002\u5982\uff1a",(0,s.jsx)(n.code,{children:"JwtHandler"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {20,12}",children:'using Furion.Authorization;\r\nusing Furion.Core;\r\nusing Microsoft.AspNetCore.Authorization;\r\nusing Microsoft.AspNetCore.Http;\r\nusing Microsoft.IdentityModel.JsonWebTokens;\r\n\r\nnamespace Furion.Web.Core\r\n{\r\n /// \r\n /// JWT \u6388\u6743\u81ea\u5b9a\u4e49\u5904\u7406\u7a0b\u5e8f\r\n /// \r\n public class JwtHandler : AppAuthorizeHandler\r\n {\r\n /// \r\n /// \u8bf7\u6c42\u7ba1\u9053\r\n /// \r\n /// \r\n /// \r\n /// \r\n public override Task PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)\r\n {\r\n // \u6b64\u5904\u5df2\u7ecf\u81ea\u52a8\u9a8c\u8bc1 Jwt token\u7684\u6709\u6548\u6027\u4e86\uff0c\u65e0\u9700\u624b\u52a8\u9a8c\u8bc1\r\n\r\n // \u68c0\u67e5\u6743\u9650\uff0c\u5982\u679c\u65b9\u6cd5\u662f\u5f02\u6b65\u7684\u5c31\u4e0d\u7528 Task.FromResult \u5305\u88f9\uff0c\u76f4\u63a5\u4f7f\u7528 async/await \u5373\u53ef\r\n return Task.FromResult(CheckAuthorzie(httpContext));\r\n }\r\n\r\n /// \r\n /// \u68c0\u67e5\u6743\u9650\r\n /// \r\n /// \r\n /// \r\n private static bool CheckAuthorzie(DefaultHttpContext httpContext)\r\n {\r\n // \u83b7\u53d6\u6743\u9650\u7279\u6027\r\n var securityDefineAttribute = httpContext.GetMetadata();\r\n if (securityDefineAttribute == null) return true;\r\n\r\n return "\u67e5\u8be2\u6570\u636e\u5e93\u8fd4\u56de\u662f\u5426\u6709\u6743\u9650";\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e4b\u540e\u6ce8\u518c ",(0,s.jsx)(n.code,{children:"JwtHandler"})," \u5373\u53ef\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"services.AddJwt();\n"})}),"\n",(0,s.jsx)(n.h3,{id:"1532-\u5b8c\u5168\u81ea\u5b9a\u4e49\u6388\u6743",children:"15.3.2 \u5b8c\u5168\u81ea\u5b9a\u4e49\u6388\u6743"}),"\n",(0,s.jsxs)(n.p,{children:["\u6709\u4e9b\u65f6\u5019\u53ef\u80fd\u9488\u5bf9\u4e0d\u540c\u7684\u5e73\u53f0\u91c7\u7528\u4e0d\u4e00\u6837\u7684\u6388\u6743\u65b9\u5f0f\uff0c\u6bd4\u5982\u5408\u4f5c\u4fe1\u4efb\u7684\u7b2c\u4e09\u65b9\u673a\u6784\u53ef\u4ee5\u514d\u6388\u6743\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u53ea\u9700\u8981\u91cd\u5199 ",(0,s.jsx)(n.code,{children:"HandleAsync"})," \u65b9\u6cd5\u5373\u53ef\u3002\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {11-25}",children:"using Furion.Authorization;\r\nusing Furion.Core;\r\nusing Microsoft.AspNetCore.Authorization;\r\nusing Microsoft.AspNetCore.Http;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Furion.Web.Core\r\n{\r\n public class JwtHandler : AppAuthorizeHandler\r\n {\r\n public override async Task HandleAsync(AuthorizationHandlerContext context)\r\n {\r\n // \u5e38\u89c4\u6388\u6743\uff08\u53ef\u4ee5\u5224\u65ad\u662f\u4e0d\u662f\u7b2c\u4e09\u65b9\uff09\r\n var isAuthenticated = context.User.Identity.IsAuthenticated;\r\n\r\n // \u7b2c\u4e09\u65b9\u6388\u6743\u81ea\u5b9a\u4e49\r\n if(\u662f\u7b2c\u4e09\u65b9){\r\n foreach (var requirement in pendingRequirements)\r\n {\r\n // \u6388\u6743\u6210\u529f\r\n context.Succeed(requirement);\r\n }\r\n }\r\n // \u6388\u6743\u5931\u8d25\r\n else context.Fail();\r\n }\r\n }\r\n}\n"})}),"\n",(0,s.jsx)(n.h2,{id:"154-\u6388\u6743\u7279\u6027\u53ca\u5168\u5c40\u6388\u6743",children:"15.4 \u6388\u6743\u7279\u6027\u53ca\u5168\u5c40\u6388\u6743"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6240\u6709\u7684\u8def\u7531\u90fd\u662f\u5141\u8bb8\u533f\u540d\u8bbf\u95ee\u7684\uff0c\u6240\u4ee5\u5982\u679c\u9700\u8981\u5bf9\u67d0\u4e2a ",(0,s.jsx)(n.code,{children:"Action"})," \u6216 ",(0,s.jsx)(n.code,{children:"Controller"})," \u8bbe\u5b9a\u6388\u6743\u8bbf\u95ee\uff0c\u53ea\u9700\u8981\u5728 ",(0,s.jsx)(n.code,{children:"Action"})," \u6216 ",(0,s.jsx)(n.code,{children:"Controller"})," \u8d34 ",(0,s.jsx)(n.code,{children:"[AppAuthorize]"})," \u6216 ",(0,s.jsx)(n.code,{children:"[Authorize]"})," \u7279\u6027\u5373\u53ef\u3002"]})}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u9700\u8981\u5bf9\u7279\u5b9a\u7684 ",(0,s.jsx)(n.code,{children:"Action"})," \u6216 ",(0,s.jsx)(n.code,{children:"Controller"})," \u5141\u8bb8\u533f\u540d\u8bbf\u95ee\uff0c\u5219\u8d34 ",(0,s.jsx)(n.code,{children:"[AllowAnonymous]"})," \u5373\u53ef\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"1541-\u5168\u5c40\u6388\u6743",children:"15.4.1 \u5168\u5c40\u6388\u6743"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"services.AddJwt(enableGlobalAuthorize:true);\n"})}),"\n",(0,s.jsx)(n.h3,{id:"1542-\u533f\u540d\u8bbf\u95ee",children:"15.4.2 \u533f\u540d\u8bbf\u95ee"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u9700\u8981\u5bf9\u7279\u5b9a\u7684 ",(0,s.jsx)(n.code,{children:"Action"})," \u6216 ",(0,s.jsx)(n.code,{children:"Controller"})," \u5141\u8bb8\u533f\u540d\u8bbf\u95ee\uff0c\u5219\u8d34 ",(0,s.jsx)(n.code,{children:"[AllowAnonymous]"})," \u5373\u53ef\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"155-\u81ea\u52a8\u5237\u65b0-token",children:"15.5 \u81ea\u52a8\u5237\u65b0 Token"}),"\n",(0,s.jsx)(n.h3,{id:"1551-\u540e\u7aef\u767b\u5f55\u90e8\u5206",children:"15.5.1 \u540e\u7aef\u767b\u5f55\u90e8\u5206"}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u7528\u6237\u767b\u5f55\u6210\u529f\u4e4b\u540e\uff0c\u8fd4\u56de ",(0,s.jsx)(n.code,{children:"accessToken"})," \u5b57\u7b26\u4e32\uff0c\u4e4b\u540e\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"JWTEncryption.GenerateRefreshToken()"})," \u83b7\u53d6 ",(0,s.jsx)(n.code,{children:"\u5237\u65b0Token"}),"\uff0c\u5e76\u901a\u8fc7\u54cd\u5e94\u62a5\u6587\u5934\u8fd4\u56de\uff0c\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {9}",children:'// token\r\nvar accessToken = JWTEncryption.Encrypt(new Dictionary()\r\n {\r\n { "UserId", user.Id }, // \u5b58\u50a8Id\r\n { "Account",user.Account }, // \u5b58\u50a8\u7528\u6237\u540d\r\n });\r\n\r\n// \u83b7\u53d6\u5237\u65b0 token\r\nvar refreshToken = JWTEncryption.GenerateRefreshToken(accessToken, 43200); // \u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u5237\u65b0 token \u7684\u6709\u6548\u671f\uff08\u5206\u949f\uff09\uff0c\u9ed8\u8ba4\u4e09\u5341\u5929\r\n\r\n// \u8bbe\u7f6e\u54cd\u5e94\u62a5\u6587\u5934\r\nhttpContextAccessor.HttpContext.Response.Headers["access-token"] = accessToken;\r\nhttpContextAccessor.HttpContext.Response.Headers["x-access-token"] = refreshToken;\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u7528\u6237\u767b\u5f55\u6210\u529f\u4e4b\u540e\u628a ",(0,s.jsx)(n.code,{children:"accessToken"})," \u548c ",(0,s.jsx)(n.code,{children:"refreshToken"})," \u4e00\u8d77\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u5b58\u50a8\u8d77\u6765\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"1552-\u540e\u7aef\u6388\u6743-handler-\u90e8\u5206",children:["15.5.2 \u540e\u7aef\u6388\u6743 ",(0,s.jsx)(n.code,{children:"Handler"})," \u90e8\u5206"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {16-28}",children:'using Furion.Authorization;\r\nusing Furion.Core;\r\nusing Furion.DataEncryption;\r\nusing Microsoft.AspNetCore.Authorization;\r\nusing Microsoft.AspNetCore.Http;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Furion.Web.Core\r\n{\r\n /// \r\n /// JWT \u6388\u6743\u81ea\u5b9a\u4e49\u5904\u7406\u7a0b\u5e8f\r\n /// \r\n public class JwtHandler : AppAuthorizeHandler\r\n {\r\n /// \r\n /// \u91cd\u5199 Handler \u6dfb\u52a0\u81ea\u52a8\u5237\u65b0\u6536\u53d6\u903b\u8f91\r\n /// \r\n /// \r\n /// \r\n public override async Task HandleAsync(AuthorizationHandlerContext context)\r\n {\r\n // \u81ea\u52a8\u5237\u65b0 token\r\n if (JWTEncryption.AutoRefreshToken(context, context.GetCurrentHttpContext()))\r\n {\r\n await AuthorizeHandleAsync(context);\r\n }\r\n else context.Fail(); // \u6388\u6743\u5931\u8d25\r\n }\r\n\r\n /// \r\n /// \u9a8c\u8bc1\u7ba1\u9053\uff0c\u4e5f\u5c31\u662f\u9a8c\u8bc1\u6838\u5fc3\u4ee3\u7801\r\n /// \r\n /// \r\n /// \r\n /// \r\n public override Task PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)\r\n {\r\n // \u68c0\u67e5\u6743\u9650\uff0c\u5982\u679c\u65b9\u6cd5\u662f\u5f02\u6b65\u7684\u5c31\u4e0d\u7528 Task.FromResult \u5305\u88f9\uff0c\u76f4\u63a5\u4f7f\u7528 async/await \u5373\u53ef\r\n return Task.FromResult(true);\r\n }\r\n }\r\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"1553-\u5ba2\u6237\u7aef\u90e8\u5206",children:"15.5.3 \u5ba2\u6237\u7aef\u90e8\u5206"}),"\n",(0,s.jsxs)(n.p,{children:["\u5ba2\u6237\u7aef\u6bcf\u6b21\u8bf7\u6c42\u9700\u5c06 ",(0,s.jsx)(n.code,{children:"accessToken"})," \u548c ",(0,s.jsx)(n.code,{children:"refreshToken"})," \u653e\u5230\u8bf7\u6c42\u62a5\u6587\u5934\u4e2d\u4f20\u9001\u5230\u670d\u52a1\u7aef\uff0c\u683c\u5f0f\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Authorization: Bearer \u4f60\u7684token\r\nX-Authorization: Bearer \u4f60\u7684\u5237\u65b0token\n"})}),"\n",(0,s.jsx)(n.admonition,{title:"\u7279\u522b\u6ce8\u610f",type:"caution",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Authorization"})," \u548c ",(0,s.jsx)(n.code,{children:"X-Authorization"})," \u90fd\u5fc5\u987b\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"Bearer "})," \u524d\u7f00\u3002"]})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u63d0\u4f9b\u4e86 ",(0,s.jsx)(n.code,{children:"vue/react/angular"})," \u5ba2\u6237\u7aef\u8bf7\u6c42\u53c2\u8003\u4ee3\u7801\uff1a",(0,s.jsx)(n.strong,{children:(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/tree/v4/clients",children:"https://gitee.com/dotnetchina/Furion/tree/v4/clients"})})]}),"\n",(0,s.jsx)(n.admonition,{title:"\u5c0f\u5efa\u8bae",type:"tip",children:(0,s.jsxs)(n.p,{children:["\u5efa\u8bae\u4f7f\u7528\u81ea\u52a8\u751f\u6210 ",(0,s.jsx)(n.code,{children:"Vue/React/Angular"})," \u4ee3\u7406\u65b9\u5f0f\uff1a",(0,s.jsx)(n.a,{href:"/docs/clientapi",children:"5.6 Vue/React/Angular \u63a5\u53e3\u4ee3\u7406"})]})}),"\n",(0,s.jsx)(n.admonition,{title:"\u5176\u4ed6\u8865\u5145",type:"important",children:(0,s.jsxs)(n.p,{children:["\u5728\u6b63\u5e38\u5f00\u53d1\u4e2d\uff0c",(0,s.jsx)(n.code,{children:"refreshToken"})," \u65e0\u9700\u6bcf\u6b21\u8bf7\u6c42\u643a\u5e26\uff0c\u800c\u662f ",(0,s.jsx)(n.code,{children:"accessToken"})," \u5373\u5c06\u8fc7\u671f\u4e4b\u540e\u643a\u5e26\u5373\u53ef\u3002\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u81ea\u884c\u5224\u65ad ",(0,s.jsx)(n.code,{children:"accessToken"})," \u662f\u5426\u5373\u5c06\u8fc7\u671f\u3002"]})}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c ",(0,s.jsx)(n.code,{children:"Token"})," \u8fc7\u671f\uff0c\u90a3\u4e48 ",(0,s.jsx)(n.code,{children:"Furion"})," \u5c06\u81ea\u52a8\u6839\u636e\u6709\u6548\u671f\u5185\u7684 ",(0,s.jsx)(n.code,{children:"refreshToken"})," \u81ea\u52a8\u751f\u6210\u65b0\u7684 ",(0,s.jsx)(n.code,{children:"AccessToken"}),"\uff0c\u5e76\u5728 ",(0,s.jsx)(n.strong,{children:"\u54cd\u5e94\u62a5\u6587\u5934"})," \u4e2d\u8fd4\u56de\uff0c\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"access-token: \u65b0\u7684token\r\nx-access-token: \u65b0\u7684\u5237\u65b0token\n"})}),"\n",(0,s.jsx)(n.admonition,{title:"\u5b58\u50a8\u65b0\u7684 Token",type:"note",children:(0,s.jsxs)(n.p,{children:["\u524d\u7aef\u9700\u8981\u83b7\u53d6 ",(0,s.jsx)(n.strong,{children:"\u54cd\u5e94\u62a5\u6587\u5934"})," \u65b0\u7684 token \u548c\u5237\u65b0 token \u66ff\u6362\u4e4b\u524d\u5728\u5ba2\u6237\u5904\u5b58\u50a8\u65e7\u7684 token \u548c\u5237\u65b0 token\u3002"]})}),"\n",(0,s.jsxs)(n.h2,{id:"156-\u83b7\u53d6-jwt-\u5b58\u50a8\u7684\u4fe1\u606f",children:["15.6 \u83b7\u53d6 ",(0,s.jsx)(n.code,{children:"Jwt"})," \u5b58\u50a8\u7684\u4fe1\u606f"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:'// \u83b7\u53d6 `Jwt` \u5b58\u50a8\u7684\u4fe1\u606f\r\nvar userId = App.User?.FindFirstValue("\u952e");\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:["\u6ce8\u610f\u5f15\u5165 ",(0,s.jsx)(n.code,{children:"System.Security.Claims"})," \u547d\u540d\u7a7a\u95f4"]})}),"\n",(0,s.jsxs)(n.admonition,{type:"warning",children:[(0,s.jsxs)(n.mdxAdmonitionTitle,{children:["\u83b7\u53d6\u4e0d\u5230 ",(0,s.jsx)(n.code,{children:"Token"})," \u4fe1\u606f\u8bf4\u660e"]}),(0,s.jsxs)(n.p,{children:["\u8bf7\u786e\u4fdd ",(0,s.jsx)(n.code,{children:".AddJwt"})," \u670d\u52a1\u5df2\u6ce8\u518c\u4e14\u542f\u7528\u4e86 ",(0,s.jsx)(n.code,{children:"\u5168\u5c40\u6388\u6743"})," \u6216\u8be5\u63a5\u53e3\uff08\u65b9\u6cd5\uff09\u8d34\u6709 ",(0,s.jsx)(n.code,{children:"[Authorize]"})," \u7279\u6027\u3002"]})]}),"\n",(0,s.jsxs)(n.h2,{id:"157-\u524d\u7aef\u89e3\u5bc6-jwt-\u4fe1\u606f",children:["15.7 \u524d\u7aef\u89e3\u5bc6 ",(0,s.jsx)(n.code,{children:"JWT"})," \u4fe1\u606f"]}),"\n",(0,s.jsxs)(n.p,{children:["\u901a\u5e38\u5728\u7528\u6237\u767b\u5f55\u6210\u529f\u540e\u6211\u4eec\u4f1a\u5c06 ",(0,s.jsx)(n.code,{children:"JWT Token"})," \u5b58\u50a8\u5230\u6d4f\u89c8\u5668\u4e2d\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u5728\u6d4f\u89c8\u5668\u7aef\u89e3\u6790 ",(0,s.jsx)(n.code,{children:"token"})," \u91cc\u9762\u5b58\u50a8\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u4e0b\u9762\u65b9\u6cd5\u5b9e\u73b0\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"TypeScript"})," \u7248\u672c"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",metastring:"showLineNumbers {7-9}",children:'/**\r\n * \u89e3\u5bc6 JWT token \u7684\u4fe1\u606f\r\n * @param token jwt token \u5b57\u7b26\u4e32\r\n * @returns object\r\n */\r\nfunction decryptJWT(token: string): any {\r\n token = token.replace(/_/g, "/").replace(/-/g, "+");\r\n var json = decodeURIComponent(escape(window.atob(token.split(".")[1])));\r\n return JSON.parse(json);\r\n}\n'})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"JavaScript"})," \u7248\u672c"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",metastring:"showLineNumbers {7-9}",children:'/**\r\n * \u89e3\u5bc6 JWT token \u7684\u4fe1\u606f\r\n * @param token jwt token \u5b57\u7b26\u4e32\r\n * @returns object\r\n */\r\nfunction decryptJWT(token) {\r\n token = token.replace(/_/g, "/").replace(/-/g, "+");\r\n var json = decodeURIComponent(escape(window.atob(token.split(".")[1])));\r\n return JSON.parse(json);\r\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u6837\u5c31\u53ef\u4ee5\u628a\u540e\u7aef\u653e\u5728 ",(0,s.jsx)(n.code,{children:"token"})," \u91cc\u9762\u7684\u4fe1\u606f\u89e3\u6790\u51fa\u6765\u4e86\u3002"]}),"\n",(0,s.jsx)(n.admonition,{title:"\u5c0f\u77e5\u8bc6",type:"tip",children:(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u5728\u89e3\u5bc6\u4e4b\u540e\u8bfb\u53d6 ",(0,s.jsx)(n.code,{children:"\u8fc7\u671f\u65f6\u95f4 exp"})," \u6765\u89e3\u51b3\u8bf7\u6c42\u65f6\u662f\u5426\u9700\u8981\u5e26\u5237\u65b0 ",(0,s.jsx)(n.code,{children:"Token"}),"\uff0c\u6bd4\u5982\u5373\u5c06\u8fc7\u671f\u524d ",(0,s.jsx)(n.code,{children:"5"})," \u5206\u949f\u3002"]})}),"\n",(0,s.jsxs)(n.h2,{id:"158-jwt-\u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u76d1\u542c",children:["15.8 ",(0,s.jsx)(n.code,{children:"Jwt"})," \u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u76d1\u542c"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u80fd\u591f\u81ea\u5b9a\u4e49\u6216\u8005\u76d1\u542c ",(0,s.jsx)(n.code,{children:"Jwt"})," \u9a8c\u8bc1\u8fc7\u7a0b\uff0c\u6bd4\u5982\u9a8c\u8bc1\u5931\u8d25\u540e\u5728 ",(0,s.jsx)(n.code,{children:"Response"})," \u4e2d\u6dfb\u52a0 ",(0,s.jsx)(n.code,{children:"Headers"}),"\uff0c\u6216\u8005\u5bf9\u63a5\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u65f6\u8981\u6c42\u63d0\u4f9b ",(0,s.jsx)(n.code,{children:"apikey"})," \u7b49\u65b9\u5f0f\uff0c\u8fd9\u65f6\u5019\u5c31\u7528\u5230\u4e86\u81ea\u5b9a\u4e49\u529f\u80fd\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,5,9,14,19,24}",children:"// \u6ce8\u518c JWT \u6388\u6743\r\nservices.AddJwt(jwtBearerConfigure: options =>\r\n{\r\n // \u5b9e\u73b0 JWT \u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u63a7\u5236\r\n options.Events = new JwtBearerEvents\r\n {\r\n // \u6dfb\u52a0\u989d\u5916 Token \u8bfb\u53d6\u5904\u7406\r\n // \u53ef\u4ee5\u5728\u8fd9\u91cc\u5b9e\u73b0\u4efb\u4f55\u65b9\u5f0f\u7684\u8bfb\u53d6 Token\uff0c\u7136\u540e\u8bbe\u7f6e\u7ed9 context.Token \u5373\u53ef\r\n OnMessageReceived = context =>\r\n {\r\n return Task.CompletedTask;\r\n },\r\n // Token \u9a8c\u8bc1\u901a\u8fc7\u5904\u7406\r\n OnTokenValidated = context =>\r\n {\r\n return Task.CompletedTask;\r\n },\r\n // Token \u9a8c\u8bc1\u5931\u8d25\u5904\u7406\r\n OnAuthenticationFailed = context =>\r\n {\r\n return Task.CompletedTask;\r\n },\r\n // \u5ba2\u6237\u7aef\u672a\u63d0\u4f9b Token \u6216 Token \u683c\u5f0f\u4e0d\u6b63\u786e\u5904\u7406\r\n OnChallenge = context =>\r\n {\r\n return Task.CompletedTask;\r\n }\r\n };\r\n});\n"})}),"\n",(0,s.jsxs)(n.h3,{id:"1581-\u5b9e\u73b0-url-\u53c2\u6570\u9a8c\u8bc1-token",children:["15.8.1 \u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"Url"})," \u53c2\u6570\u9a8c\u8bc1 ",(0,s.jsx)(n.code,{children:"Token"})]}),"\n",(0,s.jsxs)(n.p,{children:["\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c",(0,s.jsx)(n.code,{children:"JWT"})," \u90fd\u662f\u901a\u8fc7\u8bf7\u6c42\u5934\u7684 ",(0,s.jsx)(n.code,{children:"Authorization"})," \u8bbe\u7f6e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e0b\u5217\u4ee3\u7801\u5b9e\u73b0\u652f\u6301 ",(0,s.jsx)(n.code,{children:"Url"})," \u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"Token"}),"\uff0c\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {5,8,13-19}",children:'// \u5b9e\u73b0 JWT \u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u63a7\u5236\r\nservices.AddJwt(jwtBearerConfigure: options =>\r\n{\r\n // \u5b9e\u73b0 JWT \u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\u63a7\u5236\r\n options.Events = new JwtBearerEvents\r\n {\r\n // \u6dfb\u52a0\u8bfb\u53d6 Token \u7684\u65b9\u5f0f\r\n OnMessageReceived = context =>\r\n {\r\n var httpContext = context.HttpContext;\r\n\r\n // \u5224\u65ad\u8bf7\u6c42\u662f\u5426\u5305\u542b Authorization \u53c2\u6570\uff0c\u5982\u679c\u6709\u5c31\u8bbe\u7f6e\u7ed9 Token\r\n if (httpContext.Request.Query.ContainsKey("Authorization"))\r\n {\r\n var token = httpContext.Request.Query["Authorization"];\r\n\r\n // \u8bbe\u7f6e Token\r\n context.Token = token;\r\n }\r\n\r\n return Task.CompletedTask;\r\n }\r\n };\r\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u6837\u5c31\u53ef\u4ee5\u901a\u8fc7\uff1a",(0,s.jsx)(n.code,{children:"https://www.xxxx.com?Authorization=\u4f60\u7684Token"})," \u8bbf\u95ee\u4e86\u3002"]}),"\n",(0,s.jsxs)(n.h2,{id:"159-\u5173\u4e8e-blazor--webapi-\u6df7\u5408\u6388\u6743",children:["15.9 \u5173\u4e8e ",(0,s.jsx)(n.code,{children:"Blazor + WebAPI"})," \u6df7\u5408\u6388\u6743"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e00\u4e9b\u5e94\u7528\u4f7f\u7528\u4e86 ",(0,s.jsx)(n.code,{children:"Blazor"})," + ",(0,s.jsx)(n.code,{children:"WebAPI"})," \u6a21\u677f\u540e\u5e76\u542f\u7528\u5168\u5c40\u6388\u6743\uff0c\u53ef\u80fd\u4f1a\u9047\u5230 ",(0,s.jsx)(n.code,{children:"401/403"})," \u6388\u6743\u5931\u8d25\u7684\u63d0\u793a\uff0c\u8fd9\u65f6\u53ea\u9700\u8981\u5728\u542f\u52a8\u5c42 ",(0,s.jsx)(n.code,{children:"YourProject.Web.Entry"})," \u4e0b\u7684 ",(0,s.jsx)(n.code,{children:"Pages/_Host.cshtml"})," \u9876\u90e8\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u5373\u53ef\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers",children:"@using Microsoft.AspNetCore.Authorization\r\n@attribute [AllowAnonymous]\n"})}),"\n",(0,s.jsx)(n.h2,{id:"1510-\u53cd\u9988\u4e0e\u5efa\u8bae",children:"15.10 \u53cd\u9988\u4e0e\u5efa\u8bae"}),"\n",(0,s.jsx)(n.admonition,{title:"\u4e0e\u6211\u4eec\u4ea4\u6d41",type:"note",children:(0,s.jsxs)(n.p,{children:["\u7ed9 Furion \u63d0 ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/new?issue",children:"Issue"}),"\u3002"]})}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.admonition,{title:"\u4e86\u89e3\u66f4\u591a",type:"note",children:(0,s.jsxs)(n.p,{children:["\u60f3\u4e86\u89e3\u66f4\u591a ",(0,s.jsx)(n.code,{children:"\u9274\u6743\u6388\u6743"})," \u77e5\u8bc6\u53ef\u67e5\u9605 ",(0,s.jsx)(n.a,{href:"https://docs.microsoft.com/zh-cn/aspnet/core/security/?view=aspnetcore-5.0",children:"ASP.NET Core - \u5b89\u5168\u548c\u6807\u8bc6"})," \u7ae0\u8282\u3002"]})})]})}function x(e={}){const{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},510:(e,n,r)=>{r.d(n,{Z:()=>U});r(7294);const s=(e,n,r)=>e?"string"==typeof e?e:e[n]||r:r;var i=r(5893);const t={display:"block"},c=e=>{let{size:n,color:r,style:c,...o}=e;const l=c?{...t,...c}:t;return(0,i.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:l,...o,children:(0,i.jsx)("path",{d:"M856.4 292.8c-63.3-63.6-126.6-127.1-190.2-190.3-15.3-15.2-32.7-16.1-48.1-0.8-64.3 63.6-128.1 127.6-191.8 191.9-14 14.2-16.3 31.6-1.7 46 14.8 14.7 31.5 10.6 46.1-2.7 5.1-4.6 9.8-9.7 14.7-14.7 39.2-39.7 78.5-79.5 122.8-124.4 0 170 3 332.2-1.1 494-2.4 96.4-91.2 174.6-187.4 176.6-110.6 2.3-198.6-84.4-199-197.4-0.6-136.3-0.2-272.6-0.1-408.9 0-21.8-7.9-37.4-31.2-39.9-18.9-2-33.2 13.2-33.1 37.5 0 145.8-3.4 291.7 2.4 437.2 6 152.1 160.4 263.5 309.5 230.5C591.8 900 672.8 797.2 673.6 664.6c0.8-144 0.2-288.1 0.2-432.1v-33.3c11.2 10.2 17.6 15.4 23.3 21.3 38.5 38.4 76.7 77 115.3 115.2 14.8 14.6 32.2 19.2 47.8 2.9 13.8-14.8 10.3-31.7-3.8-45.8z",fill:s(r,0,"#333333")})})};c.defaultProps={size:18};const o=c,l={display:"block"},d=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...l,...t}:l;return(0,i.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:[(0,i.jsx)("path",{d:"M143.872 768a51.2 51.2 0 0 1-15.36-2.56 51.2 51.2 0 0 1-35.328-51.2V283.136a148.992 148.992 0 0 1 141.824-153.6h450.56a148.992 148.992 0 0 1 141.824 153.6V512a148.992 148.992 0 0 1-141.824 153.6H244.224l-60.928 80.896a51.2 51.2 0 0 1-39.424 21.504zM235.008 180.224a97.792 97.792 0 0 0-90.624 102.4v430.592L218.624 614.4h466.944a97.792 97.792 0 0 0 90.624-102.4V283.136a97.792 97.792 0 0 0-90.624-102.4z",fill:s(r,0,"#333333")}),(0,i.jsx)("path",{d:"M880.128 875.52a51.2 51.2 0 0 1-39.424-20.48l-60.928-80.896h-243.2a25.6 25.6 0 0 1 0-51.2h268.8l76.288 102.4v-295.936a25.6 25.6 0 0 1 25.6-25.6 25.6 25.6 0 0 1 25.6 25.6v293.888a51.2 51.2 0 0 1-51.2 51.2z",fill:s(r,1,"#333333")})]})};d.defaultProps={size:18};const h=d,a={display:"block"},x=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...a,...t}:a;return(0,i.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:[(0,i.jsx)("path",{d:"M223.425605 449.2744l161.632237 0 0 253.65714c0 16.954137 13.745049 30.699186 30.699186 30.699186 16.95516 0 30.699186-13.745049 30.699186-30.699186l0-284.356326c0-16.95516-13.744026-30.699186-30.699186-30.699186L291.035446 387.876028l217.23665-248.51605L733.039255 387.580293 607.104031 387.580293c-16.954137 0-30.699186 13.745049-30.699186 30.699186l0 284.652062c0 16.954137 13.745049 30.699186 30.699186 30.699186s30.699186-13.745049 30.699186-30.699186L637.803217 448.978664l164.448376 0c12.140505 0 23.140023-7.154957 28.063149-18.251689 4.922103-11.097756 2.841721-24.053835-5.307889-33.05279L530.62315 72.570829c-5.881964-6.495948-14.273075-10.134825-23.024389-10.091846-8.763594 0.076748-17.076934 3.895727-22.844288 10.494005L200.312188 398.371056c-7.92653 9.067516-9.818623 21.931498-4.839215 32.896224S211.383338 449.2744 223.425605 449.2744z",fill:s(r,0,"#333333")}),(0,i.jsx)("path",{d:"M222.354204 829.113381l581.732178 0c16.954137 0 30.699186-13.745049 30.699186-30.699186s-13.745049-30.699186-30.699186-30.699186L222.354204 767.715009c-16.954137 0-30.699186 13.745049-30.699186 30.699186S205.400067 829.113381 222.354204 829.113381z",fill:s(r,1,"#333333")}),(0,i.jsx)("path",{d:"M804.086381 896.729361 222.354204 896.729361c-16.954137 0-30.699186 13.745049-30.699186 30.699186s13.745049 30.699186 30.699186 30.699186l581.732178 0c16.954137 0 30.699186-13.745049 30.699186-30.699186S821.041542 896.729361 804.086381 896.729361z",fill:s(r,2,"#333333")})]})};x.defaultProps={size:18};const u=x,j={display:"block"},p=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...j,...t}:j;return(0,i.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:(0,i.jsx)("path",{d:"M380.15463648 874.54223633c0 18.12744166-14.83154297 32.95898463-32.95898463 32.95898463s-32.95898463-14.83154297-32.95898462-32.95898463V228.9152832L172.71078883 370.86962865a33.04467773 33.04467773 0 0 1-46.60400416 0 33.04467773 33.04467773 0 0 1 0-46.6040034l197.55615234-198.14941406A32.76782227 32.76782227 0 0 1 347.0967749 116.52514674c0.03295924 0 0.06591772-0.03295924 0.09887695-0.03295924 1.54907201 0 2.90039088 0.69213867 4.41650366 0.88989258 2.66967773 0.39550781 5.40527318 0.59326172 7.94311548 1.61499049 12.03002904 4.94384766 20.59936549 16.71020508 20.59936549 30.45410156v725.0910642z m320.15698192 23.34155248a32.85351537 32.85351537 0 0 1-23.43383789 9.59106445c-0.03295924 0-0.06591772 0.03295924-0.09887696 0.03295924-1.54907201 0-2.90039088-0.69213867-4.41650365-0.92285182-2.70263697-0.36254857-5.40527318-0.56030248-7.94311549-1.61498972-12.03002904-4.91088842-20.59936549-16.67724584-20.59936473-30.42114309V149.45776367c0-18.12744166 14.83154297-32.95898463 32.95898387-32.95898463s32.95898463 14.83154297 32.95898463 32.95898463v645.60058619l141.52587916-141.92138697c12.81445313-12.82104467 33.81591797-12.82104467 46.63037109 0 12.78808619 12.81445313 12.78808619 33.77636719 0 46.60400416L700.3116184 897.88378881z",fill:s(r,0,"#333333")})})};p.defaultProps={size:18};const m=p,g={display:"block"},A=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...g,...t}:g;return(0,i.jsx)("svg",{viewBox:"0 0 1172 1024",width:n+"px",height:n+"px",style:o,...c,children:(0,i.jsx)("path",{d:"M870.0416 250.4704a38.4 38.4 0 0 0-8.96 53.5552c13.056 18.2784 24.4224 37.8368 33.7408 58.112a38.4512 38.4512 0 0 0 50.944 18.8928 38.4512 38.4512 0 0 0 18.8416-50.944 436.0192 436.0192 0 0 0-40.96-70.6048 38.3488 38.3488 0 0 0-53.6064-9.0112zM181.4528 566.016a35.9936 35.9936 0 0 0 25.5488-10.5984L351.7952 410.624a36.096 36.096 0 1 0-51.0976-51.0976L217.6 442.5728C250.0096 278.1184 395.264 153.6 569.1392 153.6c50.7904 0 99.8912 10.3936 145.92 30.9248a38.4 38.4 0 1 0 31.232-70.0928 431.36 431.36 0 0 0-177.152-37.632c-214.6816 0-393.1136 156.416-428.4416 361.216L62.1568 359.4752a36.1984 36.1984 0 0 0-51.0976 51.0976l144.8448 144.7936a36.0448 36.0448 0 0 0 25.5488 10.6496zM978.5344 463.104a36.1984 36.1984 0 0 0-51.0976 0l-144.8448 144.7936a36.096 36.096 0 1 0 51.0976 51.0976l88.6272-88.576C894.3104 740.2496 746.8032 870.4 569.1392 870.4a357.7856 357.7856 0 0 1-325.2736-207.7184 38.4 38.4 0 1 0-69.7344 32.3072 434.3808 434.3808 0 0 0 394.9568 252.2112c215.1936 0 393.984-157.184 428.6464-362.7008l74.496 74.496a35.9936 35.9936 0 0 0 51.0976 0 36.096 36.096 0 0 0 0-51.0976l-144.7936-144.7936z",fill:s(r,0,"#333333")})})};A.defaultProps={size:18};const k=A,v={display:"block"},w=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...v,...t}:v;return(0,i.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:[(0,i.jsx)("path",{d:"M302 332a30 30 0 1 1 0-60h420a30 30 0 0 1 0 60H302zM302 542a30 30 0 0 1 0-60h420a30 30 0 0 1 0 60H302zM302 752a30 30 0 0 1 0-60h120a30 30 0 0 1 0 60H302z",fill:s(r,0,"#333333")}),(0,i.jsx)("path",{d:"M789.47 784.1a30 30 0 0 1 39.36 45.3l-144.24 125.25a30 30 0 0 1-19.68 7.35H214.85C163.4 962 122 919.46 122 867.38V156.62C122 104.54 163.4 62 214.85 62h594.3C860.6 62 902 104.54 902 156.62v529.05a30 30 0 1 1-60 0V156.62C842 137.3 827.09 122 809.15 122H214.85C196.91 122 182 137.3 182 156.62v710.76C182 886.7 196.91 902 214.85 902h438.84l135.78-117.9z",fill:s(r,1,"#333333")}),(0,i.jsx)("path",{d:"M692 931.19a30 30 0 1 1-60 0v-174.6C632 704.57 673.4 662 724.85 662h147.78a30 30 0 0 1 0 60h-147.78c-17.94 0-32.85 15.3-32.85 34.62v174.6z",fill:s(r,2,"#333333")})]})};w.defaultProps={size:18};const y=w,T={display:"block"},C=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...T,...t}:T;return(0,i.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:[(0,i.jsx)("path",{d:"M512 883.2A371.2 371.2 0 1 0 140.8 512 371.2 371.2 0 0 0 512 883.2z m0 64a435.2 435.2 0 1 1 435.2-435.2 435.2 435.2 0 0 1-435.2 435.2z",fill:s(r,0,"#333333")}),(0,i.jsx)("path",{d:"M557.056 512l122.368 122.368a31.744 31.744 0 1 1-45.056 45.056L512 557.056l-122.368 122.368a31.744 31.744 0 1 1-45.056-45.056L466.944 512 344.576 389.632a31.744 31.744 0 1 1 45.056-45.056L512 466.944l122.368-122.368a31.744 31.744 0 1 1 45.056 45.056z",fill:s(r,1,"#333333")})]})};C.defaultProps={size:18};const f=C,b={display:"block"},z=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...b,...t}:b;return(0,i.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:[(0,i.jsx)("path",{d:"M940 512H792V412c76.8 0 139-62.2 139-139 0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 34.8-28.2 63-63 63H232c-34.8 0-63-28.2-63-63 0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8 0 76.8 62.2 139 139 139v100H84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h148v96c0 6.5 0.2 13 0.7 19.3C164.1 728.6 116 796.7 116 876c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8 0-44.2 23.9-82.9 59.6-103.7 6 17.2 13.6 33.6 22.7 49 24.3 41.5 59 76.2 100.5 100.5S460.5 960 512 960s99.8-13.9 141.3-38.2c41.5-24.3 76.2-59 100.5-100.5 9.1-15.5 16.7-31.9 22.7-49C812.1 793.1 836 831.8 836 876c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8 0-79.3-48.1-147.4-116.7-176.7 0.4-6.4 0.7-12.8 0.7-19.3v-96h148c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM716 680c0 36.8-9.7 72-27.8 102.9-17.7 30.3-43 55.6-73.3 73.3-20.1 11.8-42 20-64.9 24.3V484c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v396.5c-22.9-4.3-44.8-12.5-64.9-24.3-30.3-17.7-55.6-43-73.3-73.3C317.7 752 308 716.8 308 680V412h408v268z",fill:s(r,0,"#333333")}),(0,i.jsx)("path",{d:"M304 280h56c4.4 0 8-3.6 8-8 0-28.3 5.9-53.2 17.1-73.5 10.6-19.4 26-34.8 45.4-45.4C450.9 142 475.7 136 504 136h16c28.3 0 53.2 5.9 73.5 17.1 19.4 10.6 34.8 26 45.4 45.4C650 218.9 656 243.7 656 272c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8 0-40-8.8-76.7-25.9-108.1-17.2-31.5-42.5-56.8-74-74C596.7 72.8 560 64 520 64h-16c-40 0-76.7 8.8-108.1 25.9-31.5 17.2-56.8 42.5-74 74C304.8 195.3 296 232 296 272c0 4.4 3.6 8 8 8z",fill:s(r,1,"#333333")})]})};z.defaultProps={size:18};const H=z,J={display:"block"},S=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...J,...t}:J;return(0,i.jsxs)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:[(0,i.jsx)("path",{d:"M512 71.68c-242.688 0-440.32 197.632-440.32 440.32s197.632 440.32 440.32 440.32 440.32-197.632 440.32-440.32-197.632-440.32-440.32-440.32z m0 819.2c-208.896 0-378.88-169.984-378.88-378.88s169.984-378.88 378.88-378.88 378.88 169.984 378.88 378.88-169.984 378.88-378.88 378.88z",fill:s(r,0,"#333333")}),(0,i.jsx)("path",{d:"M542.72 261.12H481.28v220.16H261.12v61.44h220.16v220.16h61.44v-220.16h220.16V481.28h-220.16z",fill:s(r,1,"#333333")})]})};S.defaultProps={size:18};const N=S,M={display:"block"},L=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...M,...t}:M;return(0,i.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:(0,i.jsx)("path",{d:"M384 896h-64v-70.4c0-15.2-10.4-28-24.8-31.2C159.2 768 64 644.8 64 496v-32h64v32c0 118.4 73.6 215.2 179.2 236 44.8 8.8 76.8 48 76.8 94.4v69.6zM704 896h-64v-70.4c0-45.6 32-85.6 76.8-94.4C822.4 711.2 896 614.4 896 496v-32h64v32c0 148.8-95.2 272-231.2 298.4-14.4 3.2-24.8 16-24.8 31.2v70.4zM512.8 640l-41.6-37.6c-147.2-133.6-244-208-244-316.8 0-88 68.8-156.8 156.8-156.8 49.6 0 97.6 23.2 128.8 60C544 152 592 128.8 641.6 128.8c88 0 156.8 68.8 156.8 156.8 0 108-96.8 183.2-244 316.8L512.8 640z",fill:s(r,0,"#333333")})})};L.defaultProps={size:18};const W=L,F={display:"block"},D=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...F,...t}:F;return(0,i.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:(0,i.jsx)("path",{d:"M942.4615936 284.62787926c-14.30911886-14.12709945-37.31996786-14.05468217-51.48229632 0.21920654L517.97142983 661.27810333 139.75544149 286.45003606c-14.30911886-14.16232846-37.31996786-14.05468217-51.51948344 0.21920654-14.16232846 14.30911886-14.05468217 37.35519687 0.21920654 51.51948345l401.99014627 398.34974663c0.61847666 0.61847666 1.41897273 0.76526706 2.03940637 1.34655658 0.14483342 0.14483342 0.18201941 0.32685283 0.32685283 0.47364324 7.09877874 7.02636259 16.38375538 10.55911595 25.63154489 10.55911595 9.35739278 0 18.75001458-3.60516949 25.85075143-10.77636551l398.34974663-401.99014628C956.84312974 321.8382427 956.73548345 298.7921647 942.4615936 284.62787926z",fill:s(r,0,"#333333")})})};D.defaultProps={size:18};const I=D,P={display:"block"},B=e=>{let{size:n,color:r,style:t,...c}=e;const o=t?{...P,...t}:P;return(0,i.jsx)("svg",{viewBox:"0 0 1024 1024",width:n+"px",height:n+"px",style:o,...c,children:(0,i.jsx)("path",{d:"M81.5384064 739.37212074c14.30911886 14.12709945 37.31996786 14.05468217 51.48229632-0.21920654L506.02857017 362.72189667 884.24455851 737.54996394c14.30911886 14.16232846 37.31996786 14.05468217 51.51948344-0.21920654 14.16232846-14.30911886 14.05468217-37.35519687-0.21920654-51.51948345l-401.99014627-398.34974663c-0.61847666-0.61847666-1.41897273-0.76526706-2.03940637-1.34655658-0.14483342-0.14483342-0.18201941-0.32685283-0.32685282-0.47364324-7.09877874-7.02636259-16.38375538-10.55911595-25.6315449-10.55911595-9.35739278 0-18.75001458 3.60516949-25.85075143 10.77636551l-398.34974663 401.99014628C67.15687026 702.1617573 67.26451655 725.2078353 81.5384064 739.37212074z",fill:s(r,0,"#333333")})})};B.defaultProps={size:18};const E=B,R=e=>{let{name:n,...r}=e;switch(n){case"youhua":return(0,i.jsx)(o,{...r});case"dayi":return(0,i.jsx)(h,{...r});case"shengji":return(0,i.jsx)(u,{...r});case"tiaozheng":return(0,i.jsx)(m,{...r});case"gengxin":return(0,i.jsx)(k,{...r});case"wendang":return(0,i.jsx)(y,{...r});case"shanchu":return(0,i.jsx)(f,{...r});case"bug":return(0,i.jsx)(H,{...r});case"xinzeng":return(0,i.jsx)(N,{...r});case"fuwu":return(0,i.jsx)(W,{...r});case"down":return(0,i.jsx)(I,{...r});case"up":return(0,i.jsx)(E,{...r})}return null},V={label:"label_p8vM",icon:"icon_knQK"};function U(e){const{children:n}=e,r={"\u65b0\u589e":{icon:"xinzeng",bgColor:"#39b54a"},"\u4fee\u590d":{icon:"bug",bgColor:"#9c26b0"},"\u6587\u6863":{icon:"wendang",bgColor:"rgb(79, 147, 255)"},"\u66f4\u65b0":{icon:"gengxin",bgColor:"#0081ff"},"\u8c03\u6574":{icon:"tiaozheng",bgColor:"#333"},"\u5347\u7ea7":{icon:"shengji",bgColor:"#e03997"},"\u79fb\u9664":{icon:"shanchu",bgColor:"#666"},"\u7b54\u7591":{icon:"dayi",bgColor:"#bbb"},"\u4f18\u5316":{icon:"youhua",bgColor:"#38e550"}};return(0,i.jsxs)("label",{className:V.label,title:n,style:{backgroundColor:r[n].bgColor},children:[(0,i.jsx)(R,{name:r[n].icon,color:"white",size:14,className:V.icon})," ",n]})}},1151:(e,n,r)=>{r.d(n,{Z:()=>o,a:()=>c});var s=r(7294);const i={},t=s.createContext(i);function c(e){const n=s.useContext(t);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:c(e.components),s.createElement(t.Provider,{value:n},e.children)}}}]);