Browse Source

fixes to new config security

shinoka7 6 years ago
parent
commit
6347049dfa

+ 1 - 1
resource/locales/en-US/translation.json

@@ -467,7 +467,7 @@
     },
     "registration_mode": {
       "open": "Anyone",
-      "restricted": "Reuqire Admin permission",
+      "restricted": "Require Admin permission",
       "closed": "Invitation Only"
     },
     "configuration": " Configuration",

+ 0 - 7
src/server/crowi/express-init.js

@@ -11,7 +11,6 @@ module.exports = function(crowi, app) {
   const passport = require('passport');
   const expressSession = require('express-session');
   const sanitizer = require('express-sanitizer');
-  const basicAuth = require('basic-auth-connect');
   const flash = require('connect-flash');
   const swig = require('swig-templates');
   const webpackAssets = require('express-webpack-assets');
@@ -127,12 +126,6 @@ module.exports = function(crowi, app) {
       return next();
     }
 
-    const basicName = getConfig('crowi', 'security:basicName');
-    const basicSecret = getConfig('crowi', 'security:basicSecret');
-    if (basicName && basicSecret) {
-      return basicAuth(basicName, basicSecret)(req, res, next);
-    }
-
     next();
   });
 

+ 0 - 2
src/server/form/admin/securityGeneral.js

@@ -5,8 +5,6 @@ const stringToArray = require('../../util/formUtil').stringToArrayFilter;
 const normalizeCRLF = require('../../util/formUtil').normalizeCRLFFilter;
 
 module.exports = form(
-  field('settingForm[security:basicName]'),
-  field('settingForm[security:basicSecret]'),
   field('settingForm[security:restrictGuestMode]').required(),
   field('settingForm[security:registrationMode]').required(),
   field('settingForm[security:registrationWhiteList]').custom(normalizeCRLF).custom(stringToArray),

+ 0 - 6
src/server/routes/admin.js

@@ -890,12 +890,6 @@ module.exports = function(crowi, app) {
 
     const form = req.form.settingForm;
     if (aclService.getIsPublicWikiOnly()) {
-      const basicName = form['security:basicName'];
-      const basicSecret = form['security:basicSecret'];
-      if (basicName !== '' || basicSecret !== '') {
-        req.form.errors.push('Public Wikiのため、Basic認証は利用できません。');
-        return res.json({ status: false, message: req.form.errors.join('\n') });
-      }
       const guestMode = form['security:restrictGuestMode'];
       if (guestMode === 'Deny') {
         req.form.errors.push('Private Wikiへの設定変更はできません。');

+ 3 - 3
src/server/service/acl.js

@@ -11,7 +11,7 @@ class AclService {
       SECURITY_RESTRICT_GUEST_MODE_DENY: 'Deny',
       SECURITY_RESTRICT_GUEST_MODE_READONLY: 'Readonly',
       SECURITY_REGISTRATION_MODE_OPEN: 'Open',
-      SECURITY_REGISTRATION_MODE_RESTRICTED: 'Resricted',
+      SECURITY_REGISTRATION_MODE_RESTRICTED: 'Restricted',
       SECURITY_REGISTRATION_MODE_CLOSED: 'Closed',
     };
   }
@@ -49,8 +49,8 @@ class AclService {
 
   getRegistrationModeLabels() {
     const labels = {};
-    labels[this.labelsSECURITY_REGISTRATION_MODE_OPEN] = 'security_setting.registration_mode.open';
-    labels[this.labelsSECURITY_REGISTRATION_MODE_RESTRICTED] = 'security_setting.registration_mode.restricted';
+    labels[this.labels.SECURITY_REGISTRATION_MODE_OPEN] = 'security_setting.registration_mode.open';
+    labels[this.labels.SECURITY_REGISTRATION_MODE_RESTRICTED] = 'security_setting.registration_mode.restricted';
     labels[this.labels.SECURITY_REGISTRATION_MODE_CLOSED] = 'security_setting.registration_mode.closed';
 
     return labels;

+ 2 - 24
src/server/views/admin/security.html

@@ -40,28 +40,6 @@
         <fieldset>
         <legend class="alert-anchor">{{ t('security_setting.Security settings') }}</legend>
 
-          <div class="form-group">
-            <label for="settingForm[security:registrationMode]" class="col-xs-3 control-label">{{ t('Basic authentication') }}</label>
-            <div class="col-xs-3">
-              <label for="">ID</label>
-              <input class="form-control" type="text" name="settingForm[security:basicName]" value="{{ getConfig('crowi', 'security:basicName') | default('') }}" autocomplete="nope" {% if not aclService.getIsPublicWikiOnly()  %}readonly{% endif%}>
-            </div>
-            <div class="col-xs-3">
-              <label for="">{{ t('Password') }}</label>
-              <input class="form-control" type="text" name="settingForm[security:basicSecret]" value="{{ getConfig('crowi', 'security:basicSecret') | default('') }}" autocomplete="nope" {% if not aclService.getIsPublicWikiOnly()  %}readonly{% endif%}>
-            </div>
-            <div class="col-xs-offset-3 col-xs-9">
-              <p class="help-block small">
-                {% if not aclService.getIsPublicWikiOnly() %}
-                  {{ t("security_setting.basic_acl_disable") }}<br>
-                {% else %}
-                  {{ t("security_setting.common_authentication") }}<br>
-                  {{ t("security_setting.without_encryption") }}<br>
-                {% endif %}
-              </p>
-            </div>
-          </div>
-
           <div class="form-group">
             <label for="settingForm[security:restrictGuestMode]" class="col-xs-3 control-label">{{ t('Guest users access') }}</label>
             <div class="col-xs-6">
@@ -123,10 +101,10 @@
             <div class="col-xs-9">
               <div class="btn-group btn-toggle" data-toggle="buttons">
                 <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
-                  <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
+                  <input name="{{configName}}" value="true" type="radio" {% if isEnabled %}checked{% endif %}> ON
                 </label>
                 <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
-                  <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
+                  <input name="{{configName}}" value="false" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
                 </label>
               </div>
 

+ 1 - 1
src/test/models/config.test.js

@@ -12,7 +12,7 @@ describe('Config model test', () => {
   describe('.CONSTANTS', () => {
     test('AclService has constants', async() => {
       expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_OPEN).toBe('Open');
-      expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_RESTRICTED).toBe('Resricted');
+      expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_RESTRICTED).toBe('Restricted');
       expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_CLOSED).toBe('Closed');
     });
   });