{"id":209676,"date":"2021-02-02T10:18:33","date_gmt":"2021-02-02T02:18:33","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=209676"},"modified":"2021-01-24T15:19:22","modified_gmt":"2021-01-24T07:19:22","slug":"dan-dian","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/dan-dian.html","title":{"rendered":"\u5355\u70b9\u767b\u5f55\u7684\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5728 B\/S \u7cfb\u7edf\u4e2d\uff0c\u767b\u5f55\u529f\u80fd\u901a\u5e38\u90fd\u662f\u57fa\u4e8e Cookie \u6765\u5b9e\u73b0\u7684\u3002\u5f53\u7528\u6237\u767b\u5f55\u6210\u529f\u540e\uff0c\u4e00\u822c\u4f1a\u5c06\u767b\u5f55\u72b6\u6001\u8bb0\u5f55\u5230 Session \u4e2d\uff0c\u6216\u8005\u662f\u7ed9\u7528\u6237\u7b7e\u53d1\u4e00\u4e2a Token\uff0c\u65e0\u8bba\u54ea\u4e00\u79cd\u65b9\u5f0f\uff0c\u90fd\u9700\u8981\u5728\u5ba2\u6237\u7aef\u4fdd\u5b58\u4e00\u4e9b\u4fe1\u606f\uff08Session ID \u6216 Token \uff09\uff0c\u5e76\u8981\u6c42\u5ba2\u6237\u7aef\u5728\u4e4b\u540e\u7684\u6bcf\u6b21\u8bf7\u6c42\u4e2d\u643a\u5e26\u5b83\u4eec\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5355\u70b9\u767b\u5f55\uff08Single Sign On, SSO\uff09\u662f\u6307\u5728\u540c\u4e00\u5e10\u53f7\u5e73\u53f0\u4e0b\u7684\u591a\u4e2a\u5e94\u7528\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u53ea\u9700\u767b\u5f55\u4e00\u6b21\uff0c\u5373\u53ef\u8bbf\u95ee\u6240\u6709\u76f8\u4e92\u4fe1\u4efb\u7684\u5e94\u7528\u7cfb\u7edf\u3002<\/p>\n \u4e3e\u4f8b\u6765\u8bf4\uff0c\u767e\u5ea6\u8d34\u5427\u548c\u767e\u5ea6\u5730\u56fe\u662f\u767e\u5ea6\u516c\u53f8\u65d7\u4e0b\u7684\u4e24\u4e2a\u4e0d\u540c\u7684\u5e94\u7528\u7cfb\u7edf\uff0c\u5982\u679c\u7528\u6237\u5728\u767e\u5ea6\u8d34\u5427\u767b\u5f55\u8fc7\u4e4b\u540e\uff0c\u5f53\u4ed6\u8bbf\u95ee\u767e\u5ea6\u5730\u56fe\u65f6\u65e0\u9700\u518d\u6b21\u767b\u5f55\uff0c\u90a3\u4e48\u5c31\u8bf4\u660e\u767e\u5ea6\u8d34\u5427\u548c\u767e\u5ea6\u5730\u56fe\u4e4b\u95f4\u5b9e\u73b0\u4e86\u5355\u70b9\u767b\u5f55\u3002<\/p>\n \u5355\u70b9\u767b\u5f55\u7684\u672c\u8d28\u5c31\u662f\u5728\u591a\u4e2a\u5e94\u7528\u7cfb\u7edf\u4e2d\u5171\u4eab\u767b\u5f55\u72b6\u6001\u3002\u5982\u679c\u7528\u6237\u7684\u767b\u5f55\u72b6\u6001\u662f\u8bb0\u5f55\u5728 Session \u4e2d\u7684\uff0c\u8981\u5b9e\u73b0\u5171\u4eab\u767b\u5f55\u72b6\u6001\uff0c\u5c31\u8981\u5148\u5171\u4eab Session\uff0c\u6bd4\u5982\u53ef\u4ee5\u5c06 Session \u5e8f\u5217\u5316\u5230 Redis \u4e2d\uff0c\u8ba9\u591a\u4e2a\u5e94\u7528\u7cfb\u7edf\u5171\u4eab\u540c\u4e00\u4e2a Redis\uff0c\u76f4\u63a5\u8bfb\u53d6 Redis \u6765\u83b7\u53d6 Session\u3002<\/p>\n \u5f53\u7136\u4ec5\u6b64\u662f\u4e0d\u591f\u7684\uff0c\u56e0\u4e3a\u4e0d\u540c\u7684\u5e94\u7528\u7cfb\u7edf\u6709\u7740\u4e0d\u540c\u7684\u57df\u540d\uff0c\u5c3d\u7ba1 Session \u5171\u4eab\u4e86\uff0c\u4f46\u662f\u7531\u4e8e Session ID \u662f\u5f80\u5f80\u4fdd\u5b58\u5728\u6d4f\u89c8\u5668 Cookie \u4e2d\u7684\uff0c\u56e0\u6b64\u5b58\u5728\u4f5c\u7528\u57df\u7684\u9650\u5236\uff0c\u65e0\u6cd5\u8de8\u57df\u540d\u4f20\u9012\uff0c\u4e5f\u5c31\u662f\u8bf4\u5f53\u7528\u6237\u5728 app1.com \u4e2d\u767b\u5f55\u540e\uff0cSession ID \u4ec5\u5728\u6d4f\u89c8\u5668\u8bbf\u95ee app1.com \u65f6\u624d\u4f1a\u81ea\u52a8\u5728\u8bf7\u6c42\u5934\u4e2d\u643a\u5e26\uff0c\u800c\u5f53\u6d4f\u89c8\u5668\u8bbf\u95ee app2.com \u65f6\uff0cSession ID \u662f\u4e0d\u4f1a\u88ab\u5e26\u8fc7\u53bb\u7684\u3002\u5b9e\u73b0\u5355\u70b9\u767b\u5f55\u7684\u5173\u952e\u5728\u4e8e\uff0c\u5982\u4f55\u8ba9 Session ID\uff08\u6216 Token\uff09\u5728\u591a\u4e2a\u57df\u4e2d\u5171\u4eab\u3002<\/p>\n \u5b9e\u73b0\u65b9\u5f0f\u4e00\uff1a\u7236\u57df Cookie<\/strong><\/div>\n \u5728\u5c06\u5177\u4f53\u5b9e\u73b0\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u6765\u804a\u4e00\u804a Cookie \u7684\u4f5c\u7528\u57df\u3002<\/p>\n Cookie \u7684\u4f5c\u7528\u57df\u7531 domain \u5c5e\u6027\u548c path \u5c5e\u6027\u5171\u540c\u51b3\u5b9a\u3002domain \u5c5e\u6027\u7684\u6709\u6548\u503c\u4e3a\u5f53\u524d\u57df\u6216\u5176\u7236\u57df\u7684\u57df\u540d\/IP\u5730\u5740\uff0c\u5728 Tomcat \u4e2d\uff0cdomain \u5c5e\u6027\u9ed8\u8ba4\u4e3a\u5f53\u524d\u57df\u7684\u57df\u540d\/IP\u5730\u5740\u3002path \u5c5e\u6027\u7684\u6709\u6548\u503c\u662f\u4ee5\u201c\/\u201d\u5f00\u5934\u7684\u8def\u5f84\uff0c\u5728 Tomcat \u4e2d\uff0cpath \u5c5e\u6027\u9ed8\u8ba4\u4e3a\u5f53\u524d Web \u5e94\u7528\u7684\u4e0a\u4e0b\u6587\u8def\u5f84\u3002<\/p>\n \u5982\u679c\u5c06 Cookie \u7684 domain \u5c5e\u6027\u8bbe\u7f6e\u4e3a\u5f53\u524d\u57df\u7684\u7236\u57df\uff0c\u90a3\u4e48\u5c31\u8ba4\u4e3a\u5b83\u662f\u7236\u57df Cookie\u3002Cookie \u6709\u4e00\u4e2a\u7279\u70b9\uff0c\u5373\u7236\u57df\u4e2d\u7684 Cookie \u88ab\u5b50\u57df\u6240\u5171\u4eab\uff0c\u6362\u8a00\u4e4b\uff0c\u5b50\u57df\u4f1a\u81ea\u52a8\u7ee7\u627f\u7236\u57df\u4e2d\u7684Cookie\u3002<\/p>\n \u5229\u7528 Cookie \u7684\u8fd9\u4e2a\u7279\u70b9\uff0c\u4e0d\u96be\u60f3\u5230\uff0c\u5c06 Session ID\uff08\u6216 Token\uff09\u4fdd\u5b58\u5230\u7236\u57df\u4e2d\u4e0d\u5c31\u884c\u4e86\u3002\u6ca1\u9519\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06 Cookie \u7684 domain \u5c5e\u6027\u8bbe\u7f6e\u4e3a\u7236\u57df\u7684\u57df\u540d\uff08\u4e3b\u57df\u540d\uff09\uff0c\u540c\u65f6\u5c06 Cookie \u7684 path \u5c5e\u6027\u8bbe\u7f6e\u4e3a\u6839\u8def\u5f84\uff0c\u8fd9\u6837\u6240\u6709\u7684\u5b50\u57df\u5e94\u7528\u5c31\u90fd\u53ef\u4ee5\u8bbf\u95ee\u5230\u8fd9\u4e2a Cookie \u4e86\u3002<\/p>\n \u4e0d\u8fc7\u8fd9\u8981\u6c42\u5e94\u7528\u7cfb\u7edf\u7684\u57df\u540d\u9700\u5efa\u7acb\u5728\u4e00\u4e2a\u5171\u540c\u7684\u4e3b\u57df\u540d\u4e4b\u4e0b\uff0c\u5982 tieba.baidu.com \u548c map.baidu.com\uff0c\u5b83\u4eec\u90fd\u5efa\u7acb\u5728 baidu.com \u8fd9\u4e2a\u4e3b\u57df\u540d\u4e4b\u4e0b\uff0c\u90a3\u4e48\u5b83\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0\u5355\u70b9\u767b\u5f55\u3002<\/p>\n \u603b\u7ed3\uff1a\u6b64\u79cd\u5b9e\u73b0\u65b9\u5f0f\u6bd4\u8f83\u7b80\u5355\uff0c\u4f46\u4e0d\u652f\u6301\u8de8\u4e3b\u57df\u540d\u3002<\/p>\n \u5b9e\u73b0\u65b9\u5f0f\u4e8c\uff1a\u8ba4\u8bc1\u4e2d\u5fc3<\/strong><\/div>\n \u6211\u4eec\u53ef\u4ee5\u90e8\u7f72\u4e00\u4e2a\u8ba4\u8bc1\u4e2d\u5fc3\uff0c\u8ba4\u8bc1\u4e2d\u5fc3\u5c31\u662f\u4e00\u4e2a\u4e13\u95e8\u8d1f\u8d23\u5904\u7406\u767b\u5f55\u8bf7\u6c42\u7684\u72ec\u7acb\u7684 Web \u670d\u52a1\u3002<\/p>\n \u7528\u6237\u7edf\u4e00\u5728\u8ba4\u8bc1\u4e2d\u5fc3\u8fdb\u884c\u767b\u5f55\uff0c\u767b\u5f55\u6210\u529f\u540e\uff0c\u8ba4\u8bc1\u4e2d\u5fc3\u8bb0\u5f55\u7528\u6237\u7684\u767b\u5f55\u72b6\u6001\uff0c\u5e76\u5c06 Token \u5199\u5165 Cookie\u3002\uff08\u6ce8\u610f\u8fd9\u4e2a Cookie \u662f\u8ba4\u8bc1\u4e2d\u5fc3\u7684\uff0c\u5e94\u7528\u7cfb\u7edf\u662f\u8bbf\u95ee\u4e0d\u5230\u7684\u3002\uff09<\/p>\n \u5e94\u7528\u7cfb\u7edf\u68c0\u67e5\u5f53\u524d\u8bf7\u6c42\u6709\u6ca1\u6709 Token\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u8bf4\u660e\u7528\u6237\u5728\u5f53\u524d\u7cfb\u7edf\u4e2d\u5c1a\u672a\u767b\u5f55\uff0c\u90a3\u4e48\u5c31\u5c06\u9875\u9762\u8df3\u8f6c\u81f3\u8ba4\u8bc1\u4e2d\u5fc3\u3002\u7531\u4e8e\u8fd9\u4e2a\u64cd\u4f5c\u4f1a\u5c06\u8ba4\u8bc1\u4e2d\u5fc3\u7684 Cookie \u81ea\u52a8\u5e26\u8fc7\u53bb\uff0c\u56e0\u6b64\uff0c\u8ba4\u8bc1\u4e2d\u5fc3\u80fd\u591f\u6839\u636e Cookie \u77e5\u9053\u7528\u6237\u662f\u5426\u5df2\u7ecf\u767b\u5f55\u8fc7\u4e86\u3002<\/p>\n \u5982\u679c\u8ba4\u8bc1\u4e2d\u5fc3\u53d1\u73b0\u7528\u6237\u5c1a\u672a\u767b\u5f55\uff0c\u5219\u8fd4\u56de\u767b\u5f55\u9875\u9762\uff0c\u7b49\u5f85\u7528\u6237\u767b\u5f55\uff0c\u5982\u679c\u53d1\u73b0\u7528\u6237\u5df2\u7ecf\u767b\u5f55\u8fc7\u4e86\uff0c\u5c31\u4e0d\u4f1a\u8ba9\u7528\u6237\u518d\u6b21\u767b\u5f55\u4e86\uff0c\u800c\u662f\u4f1a\u8df3\u8f6c\u56de\u76ee\u6807 URL \uff0c\u5e76\u5728\u8df3\u8f6c\u524d\u751f\u6210\u4e00\u4e2a Token\uff0c\u62fc\u63a5\u5728\u76ee\u6807 URL \u7684\u540e\u9762\uff0c\u56de\u4f20\u7ed9\u76ee\u6807\u5e94\u7528\u7cfb\u7edf\u3002<\/p>\n \u5e94\u7528\u7cfb\u7edf\u62ff\u5230 Token \u4e4b\u540e\uff0c\u8fd8\u9700\u8981\u5411\u8ba4\u8bc1\u4e2d\u5fc3\u786e\u8ba4\u4e0b Token \u7684\u5408\u6cd5\u6027\uff0c\u9632\u6b62\u7528\u6237\u4f2a\u9020\u3002\u786e\u8ba4\u65e0\u8bef\u540e\uff0c\u5e94\u7528\u7cfb\u7edf\u8bb0\u5f55\u7528\u6237\u7684\u767b\u5f55\u72b6\u6001\uff0c\u5e76\u5c06 Token \u5199\u5165 Cookie\uff0c\u7136\u540e\u7ed9\u672c\u6b21\u8bbf\u95ee\u653e\u884c\u3002\uff08\u6ce8\u610f\u8fd9\u4e2a Cookie \u662f\u5f53\u524d\u5e94\u7528\u7cfb\u7edf\u7684\uff0c\u5176\u4ed6\u5e94\u7528\u7cfb\u7edf\u662f\u8bbf\u95ee\u4e0d\u5230\u7684\u3002\uff09\u5f53\u7528\u6237\u518d\u6b21\u8bbf\u95ee\u5f53\u524d\u5e94\u7528\u7cfb\u7edf\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u5e26\u4e0a\u8fd9\u4e2a Token\uff0c\u5e94\u7528\u7cfb\u7edf\u9a8c\u8bc1 Token \u53d1\u73b0\u7528\u6237\u5df2\u767b\u5f55\uff0c\u4e8e\u662f\u5c31\u4e0d\u4f1a\u6709\u8ba4\u8bc1\u4e2d\u5fc3\u4ec0\u4e48\u4e8b\u4e86\u3002<\/p>\n \u8fd9\u91cc\u987a\u4fbf\u4ecb\u7ecd\u4e24\u6b3e\u8ba4\u8bc1\u4e2d\u5fc3\u7684\u5f00\u6e90\u5b9e\u73b0\uff1a<\/p>\n Apereo CAS \u662f\u4e00\u4e2a\u4f01\u4e1a\u7ea7\u5355\u70b9\u767b\u5f55\u7cfb\u7edf\uff0c\u5176\u4e2d CAS \u7684\u610f\u601d\u662f\u201dCentral Authentication Service\u201c\u3002\u5b83\u6700\u521d\u662f\u8036\u9c81\u5927\u5b66\u5b9e\u9a8c\u5ba4\u7684\u9879\u76ee\uff0c\u540e\u6765\u8f6c\u8ba9\u7ed9\u4e86 JASIG \u7ec4\u7ec7\uff0c\u9879\u76ee\u66f4\u540d\u4e3a JASIG CAS\uff0c\u540e\u6765\u8be5\u7ec4\u7ec7\u5e76\u5165\u4e86Apereo \u57fa\u91d1\u4f1a\uff0c\u9879\u76ee\u4e5f\u968f\u4e4b\u66f4\u540d\u4e3a Apereo CAS\u3002<\/p>\n XXL-SSO \u662f\u4e00\u4e2a\u7b80\u6613\u7684\u5355\u70b9\u767b\u5f55\u7cfb\u7edf\uff0c\u7531\u5927\u4f17\u70b9\u8bc4\u5de5\u7a0b\u5e08\u8bb8\u96ea\u91cc\u4e2a\u4eba\u5f00\u53d1\uff0c\u4ee3\u7801\u6bd4\u8f83\u7b80\u5355\uff0c\u6ca1\u6709\u505a\u5b89\u5168\u63a7\u5236\uff0c\u56e0\u800c\u4e0d\u63a8\u8350\u76f4\u63a5\u5e94\u7528\u5728\u9879\u76ee\u4e2d\uff0c\u8fd9\u91cc\u5217\u51fa\u6765\u4ec5\u4f9b\u53c2\u8003\u3002<\/p>\n \u603b\u7ed3\uff1a\u6b64\u79cd\u5b9e\u73b0\u65b9\u5f0f\u76f8\u5bf9\u590d\u6742\uff0c\u652f\u6301\u8de8\u57df\uff0c\u6269\u5c55\u6027\u597d\uff0c\u662f\u5355\u70b9\u767b\u5f55\u7684\u6807\u51c6\u505a\u6cd5\u3002<\/p>\n \u5b9e\u73b0\u65b9\u5f0f\u4e09\uff1aLocalStorage \u8de8\u57df<\/strong><\/div>\n \u524d\u9762\uff0c\u6211\u4eec\u8bf4\u5b9e\u73b0\u5355\u70b9\u767b\u5f55\u7684\u5173\u952e\u5728\u4e8e\uff0c\u5982\u4f55\u8ba9 Session ID\uff08\u6216 Token\uff09\u5728\u591a\u4e2a\u57df\u4e2d\u5171\u4eab\u3002<\/p>\n \u7236\u57df Cookie \u786e\u5b9e\u662f\u4e00\u79cd\u4e0d\u9519\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u662f\u4e0d\u652f\u6301\u8de8\u57df\u3002\u90a3\u4e48\u6709\u6ca1\u6709\u4ec0\u4e48\u5947\u6deb\u6280\u5de7\u80fd\u591f\u8ba9 Cookie \u8de8\u57df\u4f20\u9012\u5462\uff1f<\/p>\n \u5f88\u9057\u61be\uff0c\u6d4f\u89c8\u5668\u5bf9 Cookie \u7684\u8de8\u57df\u9650\u5236\u8d8a\u6765\u8d8a\u4e25\u683c\u3002Chrome \u6d4f\u89c8\u5668\u8fd8\u7ed9 Cookie \u65b0\u589e\u4e86\u4e00\u4e2a SameSite \u5c5e\u6027\uff0c\u6b64\u4e3e\u51e0\u4e4e\u7981\u6b62\u4e86\u4e00\u5207\u8de8\u57df\u8bf7\u6c42\u7684 Cookie \u4f20\u9012\uff08\u8d85\u94fe\u63a5\u9664\u5916\uff09\uff0c\u5e76\u4e14\u53ea\u6709\u5f53\u4f7f\u7528 HTTPs \u534f\u8bae\u65f6\uff0c\u624d\u6709\u53ef\u80fd\u88ab\u5141\u8bb8\u5728 AJAX \u8de8\u57df\u8bf7\u6c42\u4e2d\u63a5\u53d7\u670d\u52a1\u5668\u4f20\u6765\u7684 Cookie\u3002<\/p>\n \u4e0d\u8fc7\uff0c\u5728\u524d\u540e\u7aef\u5206\u79bb\u7684\u60c5\u51b5\u4e0b\uff0c\u5b8c\u5168\u53ef\u4ee5\u4e0d\u4f7f\u7528 Cookie\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u5c06 Session ID \uff08\u6216 Token \uff09\u4fdd\u5b58\u5230\u6d4f\u89c8\u5668\u7684 LocalStorage \u4e2d\uff0c\u8ba9\u524d\u7aef\u5728\u6bcf\u6b21\u5411\u540e\u7aef\u53d1\u9001\u8bf7\u6c42\u65f6\uff0c\u4e3b\u52a8\u5c06 LocalStorage \u7684\u6570\u636e\u4f20\u9012\u7ed9\u670d\u52a1\u7aef\u3002\u8fd9\u4e9b\u90fd\u662f\u7531\u524d\u7aef\u6765\u63a7\u5236\u7684\uff0c\u540e\u7aef\u9700\u8981\u505a\u7684\u4ec5\u4ec5\u662f\u5728\u7528\u6237\u767b\u5f55\u6210\u529f\u540e\uff0c\u5c06 Session ID \uff08\u6216 Token \uff09\u653e\u5728\u54cd\u5e94\u4f53\u4e2d\u4f20\u9012\u7ed9\u524d\u7aef\u3002<\/p>\n \u5728\u8fd9\u6837\u7684\u573a\u666f\u4e0b\uff0c\u5355\u70b9\u767b\u5f55\u5b8c\u5168\u53ef\u4ee5\u5728\u524d\u7aef\u5b9e\u73b0\u3002\u524d\u7aef\u62ff\u5230 Session ID \uff08\u6216 Token \uff09\u540e\uff0c\u9664\u4e86\u5c06\u5b83\u5199\u5165\u81ea\u5df1\u7684 LocalStorage \u4e2d\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7279\u6b8a\u624b\u6bb5\u5c06\u5b83\u5199\u5165\u591a\u4e2a\u5176\u4ed6\u57df\u4e0b\u7684 LocalStorage \u4e2d\u3002<\/p>\n \u5173\u952e\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n \/\/ \u83b7\u53d6 token\r\nvar token = result.data.token;\r\n\r\n\/\/ \u52a8\u6001\u521b\u5efa\u4e00\u4e2a\u4e0d\u53ef\u89c1\u7684iframe\uff0c\u5728iframe\u4e2d\u52a0\u8f7d\u4e00\u4e2a\u8de8\u57dfHTML\r\nvar iframe = document.createElement(\"iframe\");\r\niframe.src = \"http:\/\/app1.com\/localstorage.html\";\r\ndocument.body.append(iframe);\r\n\/\/ \u4f7f\u7528postMessage()\u65b9\u6cd5\u5c06token\u4f20\u9012\u7ed9iframe\r\nsetTimeout(function () {\r\n iframe.contentWindow.postMessage(token, \"http:\/\/app1.com\");\r\n}, 4000);\r\nsetTimeout(function () {\r\n iframe.remove();\r\n}, 6000);\r\n\r\n\/\/ \u5728\u8fd9\u4e2aiframe\u6240\u52a0\u8f7d\u7684HTML\u4e2d\u7ed1\u5b9a\u4e00\u4e2a\u4e8b\u4ef6\u76d1\u542c\u5668\uff0c\u5f53\u4e8b\u4ef6\u88ab\u89e6\u53d1\u65f6\uff0c\u628a\u63a5\u6536\u5230\u7684token\u6570\u636e\u5199\u5165localStorage\r\nwindow.addEventListener('message', function (event) {\r\n localStorage.setItem('token', event.data)\r\n}, false);\r\n<\/pre>\n |