You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
21 KiB
JavaScript

12 months ago
"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[9742],{3719:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>i,default:()=>x,frontMatter:()=>l,metadata:()=>r,toc:()=>d});var s=t(5893),o=t(1151),c=t(510);const l={id:"jwt",title:"14. JWTEncryption \u9759\u6001\u7c7b",sidebar_label:"14. JWTEncryption \u9759\u6001\u7c7b"},i=void 0,r={id:"global/jwt",title:"14. JWTEncryption \u9759\u6001\u7c7b",description:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7",source:"@site/docs/global/jwt.mdx",sourceDirName:"global",slug:"/global/jwt",permalink:"/docs/global/jwt",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/global/jwt.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1700279625,formattedLastUpdatedAt:"Nov 18, 2023",frontMatter:{id:"jwt",title:"14. JWTEncryption \u9759\u6001\u7c7b",sidebar_label:"14. JWTEncryption \u9759\u6001\u7c7b"},sidebar:"global",previous:{title:"13. FS \u9759\u6001\u7c7b",permalink:"/docs/global/fs"},next:{title:"15. TP \u9759\u6001\u7c7b",permalink:"/docs/global/tp"}},a={},d=[{value:"14.1 \u751f\u6210 <code>Token</code>",id:"141-\u751f\u6210-token",level:2},{value:"14.2 \u751f\u6210\u5237\u65b0 <code>Token</code>",id:"142-\u751f\u6210\u5237\u65b0-token",level:2},{value:"14.3 \u6839\u636e\u8fc7\u671f <code>Token</code> \u4ea4\u6362\u65b0 <code>Token</code>",id:"143-\u6839\u636e\u8fc7\u671f-token-\u4ea4\u6362\u65b0-token",level:2},{value:"14.4 \u6388\u6743\u5904\u7406\u7a0b\u5e8f\u81ea\u52a8\u5237\u65b0 <code>Token</code>",id:"144-\u6388\u6743\u5904\u7406\u7a0b\u5e8f\u81ea\u52a8\u5237\u65b0-token",level:2},{value:"14.5 \u9a8c\u8bc1 <code>Token</code> \u6709\u6548\u6027",id:"145-\u9a8c\u8bc1-token-\u6709\u6548\u6027",level:2},{value:"14.6 \u9a8c\u8bc1\u8bf7\u6c42\u4e2d <code>Token</code> \u6709\u6548\u6027",id:"146-\u9a8c\u8bc1\u8bf7\u6c42\u4e2d-token-\u6709\u6548\u6027",level:2},{value:"14.7 \u8bfb\u53d6 <code>Token</code> \u4fe1\u606f\uff08\u4e0d\u542b\u9a8c\u8bc1\uff09",id:"147-\u8bfb\u53d6-token-\u4fe1\u606f\u4e0d\u542b\u9a8c\u8bc1",level:2}];function h(e){const n={a:"a",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.a)(),...e.components},{Details:t}=n;return t||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)(t,{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)(c.Z,{children:"\u4fee\u590d"})," ",(0,s.jsx)(n.code,{children:"JWTEncryption.GetJWTSettings()"})," \u72ec\u7acb\u4f7f\u7528\u65f6\u65e0\u6cd5\u83b7\u53d6\u81ea\u5b9a\u4e49\u914d\u7f6e ",(0,s.jsx)("sup",{children:"4.9.1.4"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.11.18"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/c045e084670a98f71d5ea5ed55ca5cbbfc981e0b",children:"c045e08"})]}),"\n"]}),"\n"]}),"\n"]})})})]}),"\n",(0,s.jsxs)(n.h2,{id:"141-\u751f\u6210-token",children:["14.1 \u751f\u6210 ",(0,s.jsx)(n.code,{children:"Token"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers ",children:'// \u8bfb\u53d6\u914d\u7f6e\u4fe1\u606f\u751f\u6210 Token\r\nvar token = JWTEncryption.Encrypt(new Dictionary<string, object> { { "UserId", 1 } });\r\n\r\n// \u914d\u7f6e Token \u8fc7\u671f\u65f6\u95f4\r\nvar token = JWTEncryption.Encrypt(new Dictionary<string, object> { { "UserId", 1 } }, 20);\r\n\r\n// \u914d\u7f6e Token \u5bc6\u94a5\r\nvar token = JWTEncryption.Encrypt("monksoul@outlook.com", new Dictionary<string, object> { { "UserId", 1 } });\r\n\r\n// \u914d\u7f6e\u7b97\u6cd5\r\nvar token = JWTEncryption.Encrypt("monksoul@outlook.com", new Dictionary<string, object> {