|
|
@@ -19,6 +19,9 @@ const validator = {
|
|
|
body('hideRestrictedByOwner').isBoolean(),
|
|
|
body('hideRestrictedByGroup').isBoolean(),
|
|
|
],
|
|
|
+ basicAuth: [
|
|
|
+ body('isSameUsernameTreatedAsIdenticalUser').isBoolean(),
|
|
|
+ ],
|
|
|
googleOAuth: [
|
|
|
body('googleClientId').isString(),
|
|
|
body('googleClientSecret').isString(),
|
|
|
@@ -52,21 +55,36 @@ const validator = {
|
|
|
* type: object
|
|
|
* GeneralSetting:
|
|
|
* type:object
|
|
|
- * restrictGuestMode:
|
|
|
- * type: string
|
|
|
- * description: type of restrictGuestMode
|
|
|
- * pageCompleteDeletionAuthority:
|
|
|
- * type: string
|
|
|
- * description: type of pageDeletionAuthority
|
|
|
- * wikiMode:
|
|
|
- * type: string
|
|
|
- * description: type of wikiMode
|
|
|
- * hideRestrictedByOwner:
|
|
|
+ * GuestModeParams:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * restrictGuestMode:
|
|
|
+ * type: string
|
|
|
+ * description: type of restrictGuestMode
|
|
|
+ * PageDeletionParams:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * pageCompleteDeletionAuthority:
|
|
|
+ * type: string
|
|
|
+ * description: type of pageDeletionAuthority
|
|
|
+ * Function:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * hideRestrictedByOwner:
|
|
|
+ * type: boolean
|
|
|
+ * description: enable hide by owner
|
|
|
+ * hideRestrictedByGroup:
|
|
|
+ * type: boolean
|
|
|
+ * description: enable hide by group
|
|
|
+ * BasicAuthSetting:
|
|
|
+ * type:object
|
|
|
+ * isSameUsernameTreatedAsIdenticalUser
|
|
|
* type: boolean
|
|
|
* description: enable hide by owner
|
|
|
* hideRestrictedByGroup:
|
|
|
* type: boolean
|
|
|
* description: enable hide by group
|
|
|
+ * description: local account automatically linked the email matched
|
|
|
* GitHubOAuthSetting:
|
|
|
* type:object
|
|
|
* githubClientId:
|
|
|
@@ -136,10 +154,14 @@ module.exports = (crowi) => {
|
|
|
wikiMode: await crowi.configManager.getConfig('crowi', 'security:wikiMode'),
|
|
|
},
|
|
|
generalAuth: {
|
|
|
+ isBasicEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-basic:isEnabled'),
|
|
|
isGoogleOAuthEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-google:isEnabled'),
|
|
|
isGithubOAuthEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-github:isEnabled'),
|
|
|
isTwitterOAuthEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-twitter:isEnabled'),
|
|
|
},
|
|
|
+ basicAuth: {
|
|
|
+ isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser'),
|
|
|
+ },
|
|
|
googleOAuth: {
|
|
|
googleClientId: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientId'),
|
|
|
googleClientSecret: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientSecret'),
|
|
|
@@ -224,6 +246,46 @@ 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/BasicAuthSetting'
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: Succeeded to google OAuth
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * $ref: '#/components/schemas/SecurityParams/BasicAuthSetting'
|
|
|
+ */
|
|
|
+ router.put('/basic', loginRequiredStrictly, adminRequired, csrf, validator.basicAuth, ApiV3FormValidator, async(req, res) => {
|
|
|
+ const requestParams = {
|
|
|
+ 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser': req.body.isSameUsernameTreatedAsIdenticalUser,
|
|
|
+ };
|
|
|
+
|
|
|
+ try {
|
|
|
+ await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
|
|
|
+ const securitySettingParams = {
|
|
|
+ isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser'),
|
|
|
+ };
|
|
|
+ return res.apiv3({ securitySettingParams });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ const msg = 'Error occurred in updating basicAuth';
|
|
|
+ logger.error('Error', err);
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'update-basicOAuth-failed'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
/**
|
|
|
* @swagger
|
|
|
*
|