|
@@ -34,7 +34,7 @@ const validator = {
|
|
|
authenticationSetting: [
|
|
authenticationSetting: [
|
|
|
body('isEnabled').if(value => value != null).isBoolean(),
|
|
body('isEnabled').if(value => value != null).isBoolean(),
|
|
|
body('authId').isString().isIn([
|
|
body('authId').isString().isIn([
|
|
|
- 'local', 'ldap', 'saml', 'oidc', 'basic', 'google', 'github', 'twitter',
|
|
|
|
|
|
|
+ 'local', 'ldap', 'saml', 'oidc', 'google', 'github', 'twitter',
|
|
|
]),
|
|
]),
|
|
|
],
|
|
],
|
|
|
localSetting: [
|
|
localSetting: [
|
|
@@ -91,9 +91,6 @@ const validator = {
|
|
|
body('isSameUsernameTreatedAsIdenticalUser').if(value => value != null).isBoolean(),
|
|
body('isSameUsernameTreatedAsIdenticalUser').if(value => value != null).isBoolean(),
|
|
|
body('isSameEmailTreatedAsIdenticalUser').if(value => value != null).isBoolean(),
|
|
body('isSameEmailTreatedAsIdenticalUser').if(value => value != null).isBoolean(),
|
|
|
],
|
|
],
|
|
|
- basicAuth: [
|
|
|
|
|
- body('isSameUsernameTreatedAsIdenticalUser').if(value => value != null).isBoolean(),
|
|
|
|
|
- ],
|
|
|
|
|
googleOAuth: [
|
|
googleOAuth: [
|
|
|
body('googleClientId').if(value => value != null).isString(),
|
|
body('googleClientId').if(value => value != null).isString(),
|
|
|
body('googleClientSecret').if(value => value != null).isString(),
|
|
body('googleClientSecret').if(value => value != null).isString(),
|
|
@@ -291,12 +288,6 @@ const validator = {
|
|
|
* isSameEmailTreatedAsIdenticalUser:
|
|
* isSameEmailTreatedAsIdenticalUser:
|
|
|
* type: boolean
|
|
* type: boolean
|
|
|
* description: local account automatically linked the email matched
|
|
* description: local account automatically linked the email matched
|
|
|
- * BasicAuthSetting:
|
|
|
|
|
- * type: object
|
|
|
|
|
- * properties:
|
|
|
|
|
- * isSameUsernameTreatedAsIdenticalUser:
|
|
|
|
|
- * type: boolean
|
|
|
|
|
- * description: local account automatically linked the email matched
|
|
|
|
|
* GitHubOAuthSetting:
|
|
* GitHubOAuthSetting:
|
|
|
* type: object
|
|
* type: object
|
|
|
* properties:
|
|
* properties:
|
|
@@ -398,7 +389,6 @@ module.exports = (crowi) => {
|
|
|
isLdapEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-ldap:isEnabled'),
|
|
isLdapEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-ldap:isEnabled'),
|
|
|
isSamlEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-saml:isEnabled'),
|
|
isSamlEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-saml:isEnabled'),
|
|
|
isOidcEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-oidc:isEnabled'),
|
|
isOidcEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-oidc:isEnabled'),
|
|
|
- isBasicEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-basic:isEnabled'),
|
|
|
|
|
isGoogleEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-google:isEnabled'),
|
|
isGoogleEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-google:isEnabled'),
|
|
|
isGitHubEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-github:isEnabled'),
|
|
isGitHubEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-github:isEnabled'),
|
|
|
isTwitterEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-twitter:isEnabled'),
|
|
isTwitterEnabled: await crowi.configManager.getConfig('crowi', 'security:passport-twitter:isEnabled'),
|
|
@@ -461,9 +451,6 @@ module.exports = (crowi) => {
|
|
|
isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-oidc:isSameUsernameTreatedAsIdenticalUser'),
|
|
isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-oidc:isSameUsernameTreatedAsIdenticalUser'),
|
|
|
isSameEmailTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-oidc:isSameEmailTreatedAsIdenticalUser'),
|
|
isSameEmailTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-oidc:isSameEmailTreatedAsIdenticalUser'),
|
|
|
},
|
|
},
|
|
|
- basicAuth: {
|
|
|
|
|
- isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser'),
|
|
|
|
|
- },
|
|
|
|
|
googleOAuth: {
|
|
googleOAuth: {
|
|
|
googleClientId: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientId'),
|
|
googleClientId: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientId'),
|
|
|
googleClientSecret: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientSecret'),
|
|
googleClientSecret: await crowi.configManager.getConfig('crowi', 'security:passport-google:clientSecret'),
|
|
@@ -562,13 +549,6 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
parameters.action = SupportedAction.ACTION_ADMIN_AUTH_OIDC_DISABLED;
|
|
parameters.action = SupportedAction.ACTION_ADMIN_AUTH_OIDC_DISABLED;
|
|
|
break;
|
|
break;
|
|
|
- case 'basic':
|
|
|
|
|
- if (isEnabled) {
|
|
|
|
|
- parameters.action = SupportedAction.ACTION_ADMIN_AUTH_BASIC_ENABLED;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- parameters.action = SupportedAction.ACTION_ADMIN_AUTH_BASIC_DISABLED;
|
|
|
|
|
- break;
|
|
|
|
|
case 'google':
|
|
case 'google':
|
|
|
if (isEnabled) {
|
|
if (isEnabled) {
|
|
|
parameters.action = SupportedAction.ACTION_ADMIN_AUTH_GOOGLE_ENABLED;
|
|
parameters.action = SupportedAction.ACTION_ADMIN_AUTH_GOOGLE_ENABLED;
|
|
@@ -1100,49 +1080,6 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @swagger
|
|
|
|
|
- *
|
|
|
|
|
- * /_api/v3/security-setting/basic:
|
|
|
|
|
- * put:
|
|
|
|
|
- * tags: [SecuritySetting, apiv3]
|
|
|
|
|
- * description: Update basic
|
|
|
|
|
- * requestBody:
|
|
|
|
|
- * required: true
|
|
|
|
|
- * content:
|
|
|
|
|
- * application/json:
|
|
|
|
|
- * schema:
|
|
|
|
|
- * $ref: '#/components/schemas/BasicAuthSetting'
|
|
|
|
|
- * responses:
|
|
|
|
|
- * 200:
|
|
|
|
|
- * description: Succeeded to update basic
|
|
|
|
|
- * content:
|
|
|
|
|
- * application/json:
|
|
|
|
|
- * schema:
|
|
|
|
|
- * $ref: '#/components/schemas/BasicAuthSetting'
|
|
|
|
|
- */
|
|
|
|
|
- router.put('/basic', loginRequiredStrictly, adminRequired, addActivity, validator.basicAuth, apiV3FormValidator, async(req, res) => {
|
|
|
|
|
- const requestParams = {
|
|
|
|
|
- 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser': req.body.isSameUsernameTreatedAsIdenticalUser,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- await updateAndReloadStrategySettings('basic', requestParams);
|
|
|
|
|
-
|
|
|
|
|
- const securitySettingParams = {
|
|
|
|
|
- isSameUsernameTreatedAsIdenticalUser: await crowi.configManager.getConfig('crowi', 'security:passport-basic:isSameUsernameTreatedAsIdenticalUser'),
|
|
|
|
|
- };
|
|
|
|
|
- const parameters = { action: SupportedAction.ACTION_ADMIN_AUTH_BASIC_UPDATE };
|
|
|
|
|
- activityEvent.emit('update', res.locals.activity._id, parameters);
|
|
|
|
|
- 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
|
|
* @swagger
|
|
|
*
|
|
*
|