提交 018987c8 编写于 作者: C chenruilong

feat(uni-id-co): 请求鉴权支持 uni-cloud-s2s

上级 6d4ffa9f
...@@ -40,7 +40,7 @@ const ERROR = { ...@@ -40,7 +40,7 @@ const ERROR = {
UNSUPPORTED_REQUEST: 'uni-id-unsupported-request', UNSUPPORTED_REQUEST: 'uni-id-unsupported-request',
ILLEGAL_REQUEST: 'uni-id-illegal-request', ILLEGAL_REQUEST: 'uni-id-illegal-request',
CONFIG_FIELD_REQUIRED: 'uni-id-config-field-required', CONFIG_FIELD_REQUIRED: 'uni-id-config-field-required',
CONFIG_FIELD_INVALID: 'uni-frv-config-field-invalid', CONFIG_FIELD_INVALID: 'uni-id-config-field-invalid',
FRV_FAIL: 'uni-id-frv-fail', FRV_FAIL: 'uni-id-frv-fail',
FRV_PROCESSING: 'uni-id-frv-processing', FRV_PROCESSING: 'uni-id-frv-processing',
REAL_NAME_VERIFIED: 'uni-id-realname-verified', REAL_NAME_VERIFIED: 'uni-id-realname-verified',
......
const crypto = require('crypto') const crypto = require('crypto')
const createConfig = require('uni-config-center')
const { verifyHttpInfo } = require('uni-cloud-s2s')
const { ERROR } = require('../common/error') const { ERROR } = require('../common/error')
const s2sConfig = createConfig({
pluginId: 'uni-cloud-s2s'
})
const needSignFunctions = new Set([ const needSignFunctions = new Set([
'externalRegister', 'externalRegister',
'externalLogin', 'externalLogin',
...@@ -20,6 +26,27 @@ module.exports = function () { ...@@ -20,6 +26,27 @@ module.exports = function () {
} }
} }
// 支持 uni-cloud-s2s 验证请求
if (s2sConfig.hasFile('config.json')) {
try {
if (!verifyHttpInfo(this.getHttpInfo())) {
throw {
errCode: ERROR.ILLEGAL_REQUEST
}
}
} catch (e) {
if (e.errSubject === 'uni-cloud-s2s') {
throw {
errCode: ERROR.ILLEGAL_REQUEST,
errMsg: e.errMsg
}
}
throw e
}
return
}
if (!this.config.requestAuthSecret || typeof this.config.requestAuthSecret !== 'string') { if (!this.config.requestAuthSecret || typeof this.config.requestAuthSecret !== 'string') {
throw { throw {
errCode: ERROR.CONFIG_FIELD_REQUIRED, errCode: ERROR.CONFIG_FIELD_REQUIRED,
......
{ {
"name": "uni-id-co", "name": "uni-id-co",
"version": "1.1.8", "version": "1.1.9",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"keywords": [], "keywords": [],
...@@ -11,11 +11,12 @@ ...@@ -11,11 +11,12 @@
"uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha", "uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha",
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center", "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center",
"uni-id-common": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common", "uni-id-common": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common",
"uni-open-bridge-common": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common" "uni-open-bridge-common": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common",
"uni-cloud-s2s": "file:../../../../uni-cloud-s2s/uniCloud/cloudfunctions/common/uni-cloud-s2s"
}, },
"extensions": { "extensions": {
"uni-cloud-sms": {},
"uni-cloud-redis": {}, "uni-cloud-redis": {},
"uni-cloud-sms": {},
"uni-cloud-verify": {} "uni-cloud-verify": {}
}, },
"cloudfunction-config": { "cloudfunction-config": {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册