|
@@ -19,6 +19,11 @@ const validator = {
|
|
|
body('hideRestrictedByOwner').isBoolean(),
|
|
body('hideRestrictedByOwner').isBoolean(),
|
|
|
body('hideRestrictedByGroup').isBoolean(),
|
|
body('hideRestrictedByGroup').isBoolean(),
|
|
|
],
|
|
],
|
|
|
|
|
+ googleOAuth: [
|
|
|
|
|
+ body('googleClientId').isString(),
|
|
|
|
|
+ body('googleClientSecret').isString(),
|
|
|
|
|
+ body('isSameUsernameTreatedAsIdenticalUser').isBoolean(),
|
|
|
|
|
+ ],
|
|
|
githubOAuth: [
|
|
githubOAuth: [
|
|
|
body('githubClientId').isString(),
|
|
body('githubClientId').isString(),
|
|
|
body('githubClientSecret').isString(),
|
|
body('githubClientSecret').isString(),
|
|
@@ -215,6 +220,50 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @swagger
|
|
|
|
|
+ *
|
|
|
|
|
+ * /security-setting/google-oauth:
|
|
|
|
|
+ * put:
|
|
|
|
|
+ * tags: [SecuritySetting]
|
|
|
|
|
+ * description: Update google OAuth
|
|
|
|
|
+ * requestBody:
|
|
|
|
|
+ * required: true
|
|
|
|
|
+ * content:
|
|
|
|
|
+ * application/json:
|
|
|
|
|
+ * schema:
|
|
|
|
|
+ * $ref: '#/components/schemas/SecurityParams/GoogleOAuthSetting'
|
|
|
|
|
+ * responses:
|
|
|
|
|
+ * 200:
|
|
|
|
|
+ * description: Succeeded to google OAuth
|
|
|
|
|
+ * content:
|
|
|
|
|
+ * application/json:
|
|
|
|
|
+ * schema:
|
|
|
|
|
+ * $ref: '#/components/schemas/SecurityParams/GoogleOAuthSetting'
|
|
|
|
|
+ */
|
|
|
|
|
+ router.put('/google-oauth', loginRequiredStrictly, adminRequired, csrf, validator.googleOAuth, ApiV3FormValidator, async(req, res) => {
|
|
|
|
|
+ const requestParams = {
|
|
|
|
|
+ 'security:passport-google:clientId': req.body.googleClientId,
|
|
|
|
|
+ 'security:passport-google:clientSecret': req.body.googleClientSecret,
|
|
|
|
|
+ 'security:passport-google:isSameUsernameTreatedAsIdenticalUser': req.body.isSameUsernameTreatedAsIdenticalUser,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
|
|
|
|
|
+ const securitySettingParams = {
|
|
|
|
|
+ googleClientId: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientId'),
|
|
|
|
|
+ googleClientSecret: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientSecret'),
|
|
|
|
|
+ isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-google:isSameUsernameTreatedAsIdenticalUser'),
|
|
|
|
|
+ };
|
|
|
|
|
+ return res.apiv3({ securitySettingParams });
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ const msg = 'Error occurred in updating googleOAuth';
|
|
|
|
|
+ logger.error('Error', err);
|
|
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'update-googleOAuth-failed'));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|
|
@@ -230,7 +279,7 @@ module.exports = (crowi) => {
|
|
|
* $ref: '#/components/schemas/SecurityParams/GitHubOAuthSetting'
|
|
* $ref: '#/components/schemas/SecurityParams/GitHubOAuthSetting'
|
|
|
* responses:
|
|
* responses:
|
|
|
* 200:
|
|
* 200:
|
|
|
- * description: Succeeded to update function
|
|
|
|
|
|
|
+ * description: Succeeded to github OAuth
|
|
|
* content:
|
|
* content:
|
|
|
* application/json:
|
|
* application/json:
|
|
|
* schema:
|
|
* schema:
|
|
@@ -274,7 +323,7 @@ module.exports = (crowi) => {
|
|
|
* $ref: '#/components/schemas/SecurityParams/TwitterOAuthSetting'
|
|
* $ref: '#/components/schemas/SecurityParams/TwitterOAuthSetting'
|
|
|
* responses:
|
|
* responses:
|
|
|
* 200:
|
|
* 200:
|
|
|
- * description: Succeeded to update function
|
|
|
|
|
|
|
+ * description: Succeeded to update twitter OAuth
|
|
|
* content:
|
|
* content:
|
|
|
* application/json:
|
|
* application/json:
|
|
|
* schema:
|
|
* schema:
|