提交 b6d22c63 authored 作者: vipcxj's avatar vipcxj

增加api doc模块

上级 0b4cc019
......@@ -4301,6 +4301,11 @@
"integrity": "sha512-h6E/OkkvcBw/JimbL0p8dIaxrcuQn3QmIYGC/GtJlRYif5LTKBYPHXYwqluJpfS/kOXoz0go+9mkmOVC0M+zWw==",
"dev": true
},
"bail": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bail/-/bail-1.0.2.tgz",
"integrity": "sha1-99bBcxYwqfnw1NNe0fli4gdKF2Q="
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
......@@ -4918,6 +4923,21 @@
"supports-color": "5.3.0"
}
},
"character-entities": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.1.tgz",
"integrity": "sha1-92hxvl72bdt/j440eOzDdMJ9bco="
},
"character-entities-legacy": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.1.tgz",
"integrity": "sha1-9Ad53xoQGHK7UQo9KV4fzPFHIC8="
},
"character-reference-invalid": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.1.tgz",
"integrity": "sha1-lCg191Dk7GGjCOYMLvjMEBEgLvw="
},
"chardet": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz",
......@@ -5332,6 +5352,11 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true
},
"collapse-white-space": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.3.tgz",
"integrity": "sha1-S5BvZw5aljqHt2sOFolkM0G2Ajw="
},
"collection-visit": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
......@@ -7699,8 +7724,7 @@
"extend": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=",
"dev": true
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ="
},
"extend-shallow": {
"version": "3.0.2",
......@@ -9208,6 +9232,11 @@
"assert-plus": "1.0.0"
}
},
"github-markdown-css": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-2.10.0.tgz",
"integrity": "sha512-RX5VUC54uX6Lvrm226M9kMzsNeOa81MnKyxb3J0G5KLjyoOySOZgwyKFkUpv6iUhooiUZdogk+OTwQPJ4WttYg=="
},
"glamor": {
"version": "2.20.40",
"resolved": "https://registry.npmjs.org/glamor/-/glamor-2.20.40.tgz",
......@@ -10179,8 +10208,7 @@
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
"version": "1.3.5",
......@@ -10323,6 +10351,20 @@
"integrity": "sha512-shgfrdy8XKTUCAT5vWBgP+DisuV87+eVVBuDoIwy0PIq/HtDDijsV5cCEuzzzJZvI8zkkjuZrkBQvpjeib0YIQ==",
"dev": true
},
"is-alphabetical": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.1.tgz",
"integrity": "sha1-x3B5zJHU76x3W+EDS/LSQ/lebwg="
},
"is-alphanumerical": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.1.tgz",
"integrity": "sha1-37SqTRCF4zvbYcLe6cgOnGwZ9Ts=",
"requires": {
"is-alphabetical": "1.0.1",
"is-decimal": "1.0.1"
}
},
"is-arrayish": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
......@@ -10347,8 +10389,7 @@
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"dev": true
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"is-builtin-module": {
"version": "1.0.0",
......@@ -10403,6 +10444,11 @@
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
"dev": true
},
"is-decimal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.1.tgz",
"integrity": "sha1-9ftqlJlq2ejjdh+/vQkfH8qMToI="
},
"is-descriptor": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
......@@ -10500,6 +10546,11 @@
"is-extglob": "1.0.0"
}
},
"is-hexadecimal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.1.tgz",
"integrity": "sha1-bghLvJIGH7sJcexYts5tQE4k2mk="
},
"is-installed-globally": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz",
......@@ -10581,8 +10632,7 @@
"is-plain-obj": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=",
"dev": true
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
},
"is-plain-object": {
"version": "2.0.4",
......@@ -10697,12 +10747,22 @@
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
"dev": true
},
"is-whitespace-character": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.1.tgz",
"integrity": "sha1-muAXbzKCtlRXoZks2whPil+DPjs="
},
"is-windows": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
"integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==",
"dev": true
},
"is-word-character": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.1.tgz",
"integrity": "sha1-WgP6HqkazopusMfNdw64bWXIvvs="
},
"is-wsl": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz",
......@@ -12287,6 +12347,11 @@
"object-visit": "1.0.1"
}
},
"markdown-escapes": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.1.tgz",
"integrity": "sha1-GZTfLTr0gR3lmmcUk0wrIpJzRRg="
},
"markdown-loader": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/markdown-loader/-/markdown-loader-2.0.2.tgz",
......@@ -13404,6 +13469,19 @@
"pbkdf2": "3.0.14"
}
},
"parse-entities": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.1.1.tgz",
"integrity": "sha1-gRLYhHExnyerrk1klksSL+ThuJA=",
"requires": {
"character-entities": "1.2.1",
"character-entities-legacy": "1.1.1",
"character-reference-invalid": "1.1.1",
"is-alphanumerical": "1.0.1",
"is-decimal": "1.0.1",
"is-hexadecimal": "1.0.1"
}
},
"parse-glob": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz",
......@@ -15841,6 +15919,12 @@
"unpipe": "1.0.0"
}
},
"raw-loader": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz",
"integrity": "sha1-DD0L6u2KAclm2Xh793goElKpeao=",
"dev": true
},
"rc": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.6.tgz",
......@@ -16494,6 +16578,18 @@
"prop-types": "15.6.1"
}
},
"react-markdown": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-3.3.0.tgz",
"integrity": "sha512-eVpQZ8D7NBnms95OhpIrNj6QSuiguSLm27hh1gOeBKZzap6Cr9gl+RXAzpEQpljIqopF6FS0EVkSDCiJEAp77A==",
"requires": {
"prop-types": "15.6.1",
"remark-parse": "5.0.0",
"unified": "6.1.6",
"unist-util-visit": "1.3.0",
"xtend": "4.0.1"
}
},
"react-modal": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.3.2.tgz",
......@@ -16971,6 +17067,28 @@
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=",
"dev": true
},
"remark-parse": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-5.0.0.tgz",
"integrity": "sha512-b3iXszZLH1TLoyUzrATcTQUZrwNl1rE70rVdSruJFlDaJ9z5aMkhrG43Pp68OgfHndL/ADz6V69Zow8cTQu+JA==",
"requires": {
"collapse-white-space": "1.0.3",
"is-alphabetical": "1.0.1",
"is-decimal": "1.0.1",
"is-whitespace-character": "1.0.1",
"is-word-character": "1.0.1",
"markdown-escapes": "1.0.1",
"parse-entities": "1.1.1",
"repeat-string": "1.6.1",
"state-toggle": "1.0.0",
"trim": "0.0.1",
"trim-trailing-lines": "1.1.0",
"unherit": "1.1.0",
"unist-util-remove-position": "1.1.1",
"vfile-location": "2.0.2",
"xtend": "4.0.1"
}
},
"remove-trailing-separator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
......@@ -17007,8 +17125,7 @@
"repeat-string": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
"dev": true
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
},
"repeating": {
"version": "2.0.1",
......@@ -17019,6 +17136,11 @@
"is-finite": "1.0.2"
}
},
"replace-ext": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs="
},
"req-all": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/req-all/-/req-all-0.1.0.tgz",
......@@ -18325,6 +18447,11 @@
"integrity": "sha1-M6qE8Rd6VUjIk1Uzy/6zQgl19aQ=",
"dev": true
},
"state-toggle": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.0.tgz",
"integrity": "sha1-0g+aYWu08MO5i5GSLSW2QKorxCU="
},
"static-extend": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
......@@ -19368,6 +19495,11 @@
}
}
},
"trim": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz",
"integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0="
},
"trim-newlines": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz",
......@@ -19380,6 +19512,16 @@
"integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=",
"dev": true
},
"trim-trailing-lines": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.0.tgz",
"integrity": "sha1-eu+7eAjfnWafbaLkOMrIxGradoQ="
},
"trough": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/trough/-/trough-1.0.1.tgz",
"integrity": "sha1-qf2LA5Swro//guBjOgo2zK1bX4Y="
},
"tryer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.0.tgz",
......@@ -19857,6 +19999,15 @@
"integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ=",
"dev": true
},
"unherit": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.0.tgz",
"integrity": "sha1-a5qu379z3xdWrZ4xbdmBiFhAzX0=",
"requires": {
"inherits": "2.0.3",
"xtend": "4.0.1"
}
},
"unicode-canonical-property-names-ecmascript": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.3.tgz",
......@@ -19885,6 +20036,20 @@
"integrity": "sha512-TdDmDOTxEf2ad1g3ZBpM6cqKIb2nJpVlz1Q++casDryKz18tpeMBhSng9hjC1CTQCkOV9Rw2knlSB6iRo7ad1w==",
"dev": true
},
"unified": {
"version": "6.1.6",
"resolved": "https://registry.npmjs.org/unified/-/unified-6.1.6.tgz",
"integrity": "sha512-pW2f82bCIo2ifuIGYcV12fL96kMMYgw7JKVEgh7ODlrM9rj6vXSY3BV+H6lCcv1ksxynFf582hwWLnA1qRFy4w==",
"requires": {
"bail": "1.0.2",
"extend": "3.0.1",
"is-plain-obj": "1.1.0",
"trough": "1.0.1",
"vfile": "2.3.0",
"x-is-function": "1.0.4",
"x-is-string": "0.1.0"
}
},
"union-value": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
......@@ -19968,6 +20133,32 @@
"crypto-random-string": "1.0.0"
}
},
"unist-util-is": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.1.tgz",
"integrity": "sha1-DDEmKeP5YMZukx6BLT2A53AQlHs="
},
"unist-util-remove-position": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.1.tgz",
"integrity": "sha1-WoXBVV/BugwQG4ZwfRXlD6TIcbs=",
"requires": {
"unist-util-visit": "1.3.0"
}
},
"unist-util-stringify-position": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.1.tgz",
"integrity": "sha1-PMvcU2ee7W7PN3fdf14yKcG2qjw="
},
"unist-util-visit": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.3.0.tgz",
"integrity": "sha512-9ntYcxPFtl44gnwXrQKZ5bMqXMY0ZHzUpqMFiU4zcc8mmf/jzYm8GhYgezuUlX4cJIM1zIDYaO6fG/fI+L6iiQ==",
"requires": {
"unist-util-is": "2.1.1"
}
},
"universalify": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
......@@ -20283,6 +20474,30 @@
"extsprintf": "1.3.0"
}
},
"vfile": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-2.3.0.tgz",
"integrity": "sha512-ASt4mBUHcTpMKD/l5Q+WJXNtshlWxOogYyGYYrg4lt/vuRjC1EFQtlAofL5VmtVNIZJzWYFJjzGWZ0Gw8pzW1w==",
"requires": {
"is-buffer": "1.1.6",
"replace-ext": "1.0.0",
"unist-util-stringify-position": "1.1.1",
"vfile-message": "1.0.0"
}
},
"vfile-location": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.2.tgz",
"integrity": "sha1-02dcWch3SY5JK0dW/2Xkrxp1IlU="
},
"vfile-message": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.0.0.tgz",
"integrity": "sha512-HPREhzTOB/sNDc9/Mxf8w0FmHnThg5CRSJdR9VRFkD2riqYWs+fuXlj5z8mIpv2LrD7uU41+oPWFOL4Mjlf+dw==",
"requires": {
"unist-util-stringify-position": "1.1.1"
}
},
"vm-browserify": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
......@@ -20952,6 +21167,16 @@
"safe-buffer": "5.1.1"
}
},
"x-is-function": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/x-is-function/-/x-is-function-1.0.4.tgz",
"integrity": "sha1-XSlNw9Joy90GJYDgxd93o5HR+h4="
},
"x-is-string": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz",
"integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI="
},
"xdg-basedir": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz",
......@@ -20987,8 +21212,7 @@
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
"dev": true
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
},
"y18n": {
"version": "4.0.0",
......
......@@ -20,6 +20,7 @@
"dva-loading": "^1.0.4",
"fastjson_ref_resolver": "latest",
"fingerprintjs": "^0.5.3",
"github-markdown-css": "^2.10.0",
"history": "latest",
"is-promise": "^2.1.0",
"lodash": "^4.17.4",
......@@ -30,6 +31,7 @@
"react-async-wrapper": "^0.0.7",
"react-dom": "^16.2.0",
"react-json-view": "^1.11.4",
"react-markdown": "^3.3.0",
"react-router-4-compat": "^0.1.4",
"resolve-pathname": "^2.1.0",
"uuid": "^3.1.0",
......@@ -62,6 +64,7 @@
"markdown-loader": "^2.0.2",
"mockjs": "^1.0.1-beta3",
"path": "^0.12.7",
"raw-loader": "^0.5.1",
"react-test-renderer": "^16.2.0",
"redbox-react": "^1.5.0",
"roadhog": "^2.3.0-beta.1"
......
......@@ -5,7 +5,6 @@ const route = (routes) => {
return children || null;
};
Wrapper.route = {
...routes,
indexRoute: {
onEnter(nextState, replace) {
if (routes && routes.childRoutes && routes.childRoutes.length > 0) {
......@@ -14,6 +13,7 @@ const route = (routes) => {
}
},
},
...routes,
};
return Wrapper;
};
......
@charset "utf-8";
* {
/** {
margin: 0;
padding: 0;
}
}*/
html {
color: #000;
background: #FFF;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form,
/*body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form,
fieldset, input, textarea, p, blockquote, th, td {
margin: 0;
padding: 0;
......@@ -61,11 +67,12 @@ li {
input, img {
border: none;
}
}*/
:global(#root) {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
export default {
namespace: 'apiDoc',
state: {},
reducers: {},
effects: {},
subscriptions: {},
};
/* eslint-disable */
export default [/*{
export default [{
name: 'test-menu',
showName: '测试',
modules: [{
name: 'test-module',
showName: '测试',
layout: {
route: 'task',
route: 'api-doc',
},
}],
}*/];
}];
/* eslint-disable react/no-danger */
import React from 'react';
import PropTypes from 'prop-types';
class MarkDown extends React.Component {
render() {
return (
<div dangerouslySetInnerHTML={{
__html: this.props.markdown,
}}
/>
);
}
}
MarkDown.propTypes = {
markdown: PropTypes.string,
};
MarkDown.defaultProps = {
markdown: '',
};
export default MarkDown;
# 登录与认证
登录分为2个步骤。
第一步通过用户名或其他用户标识符确定用户的存在性,
并获得一个未认证的token(令牌)。
同时返回的还有该用户需要经过哪些认证方式才能真正登录。
第二步使用上一步获得的令牌,并根据给予的验证需求,使用对应的方式予以认证。
所有验证需求都验证通过后,才正式登录成功,并且token变为有效。
之后所有的api调用都会用到此token。
## 获取一个未验证token
- **URL**:
/api/auth/login
- **Method**:
POST
- **Accept**: application/json
```
{
type: string, //登录方式
data: string, //登录方式对应的登录数据
tokenInfo: { //令牌信息
productId: string, //产品ID
deviceId: string //设备ID
},
authRequest: { //验证请求,可选
type: string, //验证方式
parameters: Map //验证参数
}
}
```
> - *type*: 登录方式, 可选值为`userName`,`email`,分别表示用户名登录和邮箱登录。
> - *data*: 登录方式对应的登录数据, `userName`对应的登录数据即为用户名,`email`对应的登录数据即为邮箱地址
> - *tokenInfo*: 登录必备的信息,为权限验证所需。
> - *productId*: 产品ID,表示要登录的产品。
> - *deviceId*: 设备ID,一条可以用来唯一标识客户端的字符串,生成规则不限,只要保证唯一性和不变性即可。
> - *authRequest*: 验证请求,为了简化接口,登录的同时也可以一起进行验证。
前提是事先知道对应用户需要用哪种方式进行验证。因为用户所需的验证方式是后台可配置,
不是一成不变的,所以不建议登录验证同时进行的api调用方式。
> - *type*: 验证方式。可选值为`password`,表示密码登录
> - *parameters*: 验证参数。`password`对应的验证参数为
`{ cipher: string }`,表示用户密码。
- **Content-Type**:
application/json
```
{
tokenId: string,
authResponse: {
type: string,
status: string,
data: any,
remainedAuthRequirements: {
requirements: [{
authTypes: [string]
}]
}
},
remainedAuthRequirements: {
requirements: [{
authTypes: [string]
}]
}
}
```
> - *tokenId*: 未加密的原始token字符串,该token在服务器存在内存中,
若超过30分钟没有使用该token,该token将失效。
> - *authResponse*: 验证响应,请求体中包含`authRequest`字段时,响应体中才会有此字段。
- *type*: 验证类型,与请求体中`authRequest.type`值相同。
- *status*: 验证状态,可能值为:`authed`,`rejected`,`skipped`等。
`authed`表示验证通过,`rejected`表示验证未通过,`skipped`表示不需要此步验证。
以上3种可能值为所有验证方式共有。其他可能值依赖于各自的验证方式。
- *data*: 验证响应数据。其含义依赖于验证方式。
- *remainedAuthRequirements*: 剩余的验证需求。
- *requirements*: 若干个验证需求,逻辑关系为和。
若为空数组,表示所有验证需求均已满足,即全部验证成功。
- *authTypes*: 若干个验证方式,逻辑关系为或,
只要其中一个验证方式验证成功,该验证条件即满足。
> - *remainedAuthRequirements*: 同`authResponse.remainedAuthRequirements`。
不同之处在于请求体中不需要包含`authRequest`,该字段也存在。
- **note**:
获取后的token,不能直接使用,需要使用公钥进行非对称加密。加密方式如下:
1. 直接使用token,或包装成令牌对象:
```
{
tkId: string, //令牌
ett: long, //令牌发出时间,从1970/1/1 UTC至今的毫秒数
life: long //令牌对象有效期,单位毫秒
}
```
2. 将token字符串本身或包装成的令牌对象的json字符串表示转为utf-8字节数组。
3. 使用给定公钥,以**RSA/None/PKCS1Padding**方式进行加密。然后对加密结果进行base64urlsafing方式转码
(先进行普通的base64转码,然后去除尾部'=',然后用'-'替换所有'+',用'_'替换所有'/')
- **公钥**:
`-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+/Rs6dYmdtETjHCZq4LF3QjLM/DocRAXrqtMULZf+579dAn+CiM8noLplZT/DRwvfK822eq8sypH+a4NqP7942pPVjOudVvKfiJvmm2TOQHvQ7vi3iyZVdlsxX72JNFo1Ocqwj48aIC/OJ4bMf/VyCKrmKrU2iXND+I4BN8cfhwIDAQAB-----END PUBLIC KEY-----`
## 验证token
- **URL**:
/api/auth/authorize
- **Method**:
POST
- **Accept**:
application/json
```
{
tkId: string,
request: {
type: string, //验证方式
parameters: Map //验证参数
}
}
```
- *tkId*: 加密后的令牌
- *request*: 验证请求
- *type*: 验证方式。可选值为`password`,表示密码登录
- *parameters*: 验证参数。`password`对应的验证参数为
`{ cipher: string }`,表示用户密码。
- **Content-Type**:
application/json
```
{
type: string,
status: string,
data: any,
remainedAuthRequirements: {
requirements: [{
authTypes: [string]
}]
}
}
```
- *type*: 验证类型,与请求体中`authRequest.type`值相同。
- *status*: 验证状态,可能值为:`authed`,`rejected`,`skipped`等。
`authed`表示验证通过,`rejected`表示验证未通过,`skipped`表示不需要此步验证。
以上3种可能值为所有验证方式共有。其他可能值依赖于各自的验证方式。
- *data*: 验证响应数据。其含义依赖于验证方式。
- *remainedAuthRequirements*: 剩余的验证需求。
- *requirements*: 若干个验证需求,逻辑关系为和。
若为空数组,表示所有验证需求均已满足,即全部验证成功。
- *authTypes*: 若干个验证方式,逻辑关系为或,
只要其中一个验证方式验证成功,该验证条件即满足。
## 登出
- **URL**:
/api/auth/logout
- **Method**:
POST
- **Accept**:
application/json
`empty` (只包含前置说明中提到的token,即`{ token: string }`, 之后不再重复说明。)
- **Content-Type**:
application/json
`null` (并不是真正的空,仅仅是如前置说明中提到那样,`data`字段为`null`, 之后不再重复说明。)
.markdown {
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
width: 100%;
color:#444;
font-family:Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
font-size:12px;
line-height:1.5em;
padding:1em;
background:#fefefe;
a{ color: #0645ad; text-decoration:none;}
a:visited{ color: #0b0080; }
a:hover{ color: #06e; }
a:active{ color:#faa700; }
a:focus{ outline: thin dotted; }
a:hover, a:active{ outline: 0; }
::-moz-selection{background:rgba(255,255,0,0.3);color:#000}
::selection{background:rgba(255,255,0,0.3);color:#000}
a::-moz-selection{background:rgba(255,255,0,0.3);color:#0645ad}
a::selection{background:rgba(255,255,0,0.3);color:#0645ad}
p{
margin:1em 0;
}
img{
max-width:100%;
}
h1,h2,h3,h4,h5,h6{
font-weight:normal;
color:#111;
line-height:1em;
}
h4,h5,h6{ font-weight: bold; }
h1{ font-size:2.5em; }
h2{ font-size:2em; }
h3{ font-size:1.5em; }
h4{ font-size:1.2em; }
h5{ font-size:1em; }
h6{ font-size:0.9em; }
blockquote{
color:#666666;
margin:0;
padding-left: 3em;
border-left: 0.5em #EEE solid;
}
hr { display: block; height: 2px; border: 0; border-top: 1px solid #aaa;border-bottom: 1px solid #eee; margin: 1em 0; padding: 0; }
pre, code, kbd, samp { color: #000; font-family: monospace, monospace; _font-family: 'courier new', monospace; font-size: 0.98em; }
pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
b, strong { font-weight: bold; }
dfn { font-style: italic; }
ins { background: #ff9; color: #000; text-decoration: none; }
mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
ul, ol { margin: 1em 0; padding: 0 0 0 2em; }
li p:last-child { margin:0 }
dd { margin: 0 0 0 2em; }
img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
}
th { border-bottom: 1px solid black; }
td { vertical-align: top; }
@media only screen and (min-width: 480px) {
font-size:14px;
}
@media only screen and (min-width: 768px) {
font-size:16px;
}
@media print {
* { background: transparent !important; color: black !important; filter:none !important; -ms-filter: none !important; }
font-size:12pt; max-width:100%;
a, a:visited { text-decoration: underline; }
hr { height: 1px; border:0; border-bottom:1px solid black; }
a[href]:after { content: " (" attr(href) ")"; }
abbr[title]:after { content: " (" attr(title) ")"; }
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
pre, blockquote { border: 1px solid #999; padding-right: 1em; page-break-inside: avoid; }
tr, img { page-break-inside: avoid; }
img { max-width: 100% !important; }
@page :left { margin: 15mm 20mm 15mm 10mm; }
@page :right { margin: 15mm 10mm 15mm 20mm; }
p, h2, h3 { orphans: 3; widows: 3; }
h2, h3 { page-break-after: avoid; }
}
}
import React from 'react';
import { connect } from 'dva';
import ReactMarkdown from 'react-markdown';
import 'github-markdown-css';
import mdIndex from './index.md';
import mdAuth from './auth.md';
import route from '../../../../components/hoc/routes';
const md = mdString => () => <ReactMarkdown className="markdown-body" source={mdString} />;
export default connect(({ apiDoc }) => ({ apiDoc }))(route({
indexRoute: {
component: md(mdIndex),
},
childRoutes: [
{
path: 'auth',
name: '登录与验证',
component: md(mdAuth),
},
],
}));
# API Document
# 前置说明
1. 接口的返回基本都是json格式,并且有如下形式:
```
{
errorCode: long,
data: any,
message: string
}
```
> - *errorCode*: 错误码,0表示成功,无错误
> - *data*: 真正的返回数据,后续文档如无特别说明,对于返回形式的描述都是指的data的格式。
另外,发生错误时,这个字段也可能保护错误相关信息。
> - *message*: 错误消息,`errorCode`为0时,不使用这个字段。
2. 除了登录接口(获取token的接口),所有其他接口都要使用令牌(token)进行权限验证。
token使用方式目前统一为:
- 若为GET或DELETE方法接口,token加密后作为query参数拼接在url上,参数名为token。
- 若为POST方法接口,并且请求体是json格式的,若无特别说明,都保护一个token属性,值为加密后的token。
- token的加密方式在登录部分会提及。
3. 服务端使用fastjson进行json的解析,
该框架支持循环引用的json序列化,
并且对于json树中的同一个引用,
可能会使用特殊的表示方式。具体见[循环引用](https://github.com/alibaba/fastjson/wiki/%E5%BE%AA%E7%8E%AF%E5%BC%95%E7%94%A8)
所以返回的json数据里部分属性可能以引用的形式存在。需要进一步解析。
若使用java,可以用fastjson的[JSONPath](https://github.com/alibaba/fastjson/wiki/JSONPath)来进行解析。
若使用javascript,可以用npm上的一个库[fastjson_ref_resolver](https://www.npmjs.com/package/fastjson_ref_resolver)来进一步处理。
## 目录
- [登录与验证](auth)
......@@ -43,16 +43,23 @@ function pickDeep(collection, ...args) {
module.exports = function webpack(config) {
config.module.rules.push({
test: /\.ejs$/,
loader: 'ejs-loader',
loader: require.resolve('ejs-loader'),
});
config.module.rules = config.module.rules.map((rule) => {
if (!rule.test && rule.exclude) {
rule.exclude = [...rule.exclude, /\.md$/];
}
return rule;
});
config.module.rules.push({
test: /\.md$/,
use: [
'html-loader',
'highlight-loader',
'markdown-loader',
// require.resolve('html-loader'),
// require.resolve('highlight-loader'),
require.resolve('raw-loader'),
],
});
// console.log(config.module.rules);
let cleanedConfig = omit(config, 'plugins');
cleanedConfig.resolve = omit(cleanedConfig.resolve, 'plugins');
cleanedConfig = pickDeep(cleanedConfig, v => !isFunction(v) && !isUndefined(v));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论