security.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. {% extends '../layout/admin.html' %}
  2. {% block html_title %}{{ customizeService.generateCustomTitle(t('security_settings')) }} · {% endblock %}
  3. {% block content_header %}
  4. <div class="header-wrap">
  5. <header id="page-header">
  6. <h1 id="admin-title" class="title">{{ t('security_settings') }}</h1>
  7. </header>
  8. </div>
  9. {% endblock %}
  10. {% block content_main %}
  11. <div class="content-main admin-security">
  12. <div class="row">
  13. <div class="col-md-3">
  14. {% include './widget/menu.html' with {current: 'security'} %}
  15. </div>
  16. <div class="col-md-9">
  17. {% set smessage = req.flash('successMessage') %}
  18. {% if smessage.length %}
  19. <div class="alert alert-success">
  20. {% for e in smessage %}
  21. {{ e }}<br>
  22. {% endfor %}
  23. </div>
  24. {% endif %}
  25. {% set emessage = req.flash('errorMessage') %}
  26. {% if emessage.length %}
  27. <div class="alert alert-danger">
  28. {% for e in emessage %}
  29. {{ e }}<br>
  30. {% endfor %}
  31. </div>
  32. {% endif %}
  33. <form action="/_api/admin/security/general" method="post" class="form-horizontal" id="generalSetting" role="form">
  34. <fieldset>
  35. <legend class="alert-anchor">{{ t('security_settings') }}</legend>
  36. <div class="form-group">
  37. <label for="settingForm[security:restrictGuestMode]" class="col-xs-3 control-label">{{ t('Guest users access') }}</label>
  38. <div class="col-xs-6">
  39. <select class="form-control selectpicker" name="settingForm[security:restrictGuestMode]" value="{{ getConfig('crowi', 'security:restrictGuestMode') }}">
  40. {% for modeValue, modeLabel in consts.restrictGuestMode %}
  41. <option value="{{ t(modeValue) }}" {% if modeValue == getConfig('crowi', 'security:restrictGuestMode') %}selected{% endif %} >{{ t(modeLabel) }}</option>
  42. {% endfor %}
  43. </select>
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <label for="settingForm[security:registrationMode]" class="col-xs-3 control-label">{{ t('Register limitation') }}</label>
  48. <div class="col-xs-6">
  49. <select class="form-control selectpicker" name="settingForm[security:registrationMode]" value="{{ getConfig('crowi', 'security:registrationMode') }}">
  50. {% for modeValue, modeLabel in consts.registrationMode %}
  51. <option value="{{ t(modeValue) }}" {% if modeValue == getConfig('crowi', 'security:registrationMode') %}selected{% endif %} >{{ t(modeLabel) }}</option>
  52. {% endfor %}
  53. </select>
  54. <p class="help-block small">{{ t('The contents entered here will be shown in the header etc') }}</p>
  55. </div>
  56. </div>
  57. <div class="form-group">
  58. <label for="settingForm[security:registrationWhiteList]" class="col-xs-3 control-label">{{ t('The whitelist of registration permission E-mail address') }}</label>
  59. <div class="col-xs-8">
  60. <textarea class="form-control" type="textarea" name="settingForm[security:registrationWhiteList]" placeholder="{{ t('security_setting.example') }}: @growi.org">{{ getConfig('crowi', 'security:registrationWhiteList') | join('&#13') | raw }}</textarea>
  61. <p class="help-block small">{{ t("security_setting.restrict_emails") }}{{ t("security_setting.for_instance") }}<code>@growi.org</code>{{ t("security_setting.only_those") }}<br>
  62. {{ t("security_setting.insert_single") }}</p>
  63. </div>
  64. </div>
  65. <div class="form-group">
  66. {% set configName = 'settingForm[security:list-policy:hideRestrictedByOwner]' %}
  67. {% set configValue = getConfig('crowi', 'security:list-policy:hideRestrictedByOwner') %}
  68. {% set isEnabled = !configValue %}
  69. <label for="{{configName}}" class="col-xs-3 control-label">{{ t("security_setting.page_listing_1") }}</label>
  70. <div class="col-xs-9">
  71. <div class="btn-group btn-toggle" data-toggle="buttons">
  72. <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
  73. <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
  74. </label>
  75. <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
  76. <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
  77. </label>
  78. </div>
  79. <p class="help-block small">
  80. {{ t("security_setting.page_listing_1_desc") }}
  81. </p>
  82. </div>
  83. </div>
  84. <div class="form-group">
  85. {% set configName = 'settingForm[security:list-policy:hideRestrictedByGroup]' %}
  86. {% set configValue = getConfig('crowi', 'security:list-policy:hideRestrictedByGroup') %}
  87. {% set isEnabled = !configValue %}
  88. <label for="{{configName}}" class="col-xs-3 control-label">{{ t("security_setting.page_listing_2") }}</label>
  89. <div class="col-xs-9">
  90. <div class="btn-group btn-toggle" data-toggle="buttons">
  91. <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
  92. <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
  93. </label>
  94. <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
  95. <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
  96. </label>
  97. </div>
  98. <p class="help-block small">
  99. {{ t("security_setting.page_listing_2_desc") }}
  100. </p>
  101. </div>
  102. </div>
  103. <div class="form-group">
  104. {% set configName = 'settingForm[security:pageCompleteDeletionAuthority]' %}
  105. {% set configValue = getConfig('crowi','security:pageCompleteDeletionAuthority') %}
  106. <label for="{{configName}}" class="col-xs-3 control-label">{{ t('security_setting.complete_deletion') }}</label>
  107. <div class="col-xs-6">
  108. <select class="form-control selectpicker" name="settingForm[security:pageCompleteDeletionAuthority]" value="{{ configValue }}">
  109. <option value="anyOne" {% if configValue == "anyOne" %}selected{% endif %}>{{ t('security_setting.anyone') }}</option>
  110. <option value="adminOnly" {% if configValue =="adiminOnly" %}selected{% endif %}>{{ t('security_setting.admin_only') }}</option>
  111. <option value="adminAndAuthor" {% if configValue == "adminAndAuthor" %}selected{% endif %}>{{ t('security_setting.admin_and_author') }}</option>
  112. </select>
  113. <p class="help-block small">
  114. {{ t('security_setting.complete_deletion_explain') }}
  115. </p>
  116. </div>
  117. </div>
  118. <div class="form-group">
  119. <div class="col-xs-offset-3 col-xs-6">
  120. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  121. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  122. </div>
  123. </div>
  124. </fieldset>
  125. </form>
  126. <!-- prevent XSS link -->
  127. <div class="mt-5">
  128. <legend>{{ t('security_setting.xss_prevent_setting') }}</legend>
  129. <div class="text-center">
  130. <a class="flexbox" style="font-size: large;" href="/admin/markdown/#preventXSS">
  131. <i class="fa-fw icon-login"></i> {{ t('security_setting.xss_prevent_setting_link') }}
  132. </a>
  133. </div>
  134. </div>
  135. <div class="auth-mechanism-configurations m-t-10">
  136. <legend>{{ t('security_setting.Authentication mechanism settings') }}</legend>
  137. {#
  138. # passport settings nav
  139. #}
  140. <div class="passport-settings">
  141. <ul class="nav nav-tabs" role="tablist">
  142. <li class="active">
  143. <a href="#passport-ldap" data-toggle="tab" role="tab"><i class="fa fa-sitemap"></i> LDAP</a>
  144. </li>
  145. <li>
  146. <a href="#passport-saml" data-toggle="tab" role="tab"><i class="fa fa-key"></i> SAML</a>
  147. </li>
  148. <li>
  149. <a href="#passport-google-oauth" data-toggle="tab" role="tab"><i class="fa fa-google"></i> Google</a>
  150. </li>
  151. <li>
  152. <a href="#passport-github" data-toggle="tab" role="tab"><i class="fa fa-github"></i> GitHub</a>
  153. </li>
  154. <li>
  155. <a href="#passport-twitter" data-toggle="tab" role="tab"><i class="fa fa-twitter"></i> Twitter</a>
  156. </li>
  157. <li>
  158. <a href="#passport-oidc" data-toggle="tab" role="tab"><i class="fa fa-openid"></i> OIDC</a>
  159. </li>
  160. <li>
  161. <a href="#passport-basic" data-toggle="tab" role="tab"><i class="fa fa-sign-in"></i> Basic</a>
  162. </li>
  163. <li class="tbd">
  164. <a href="#passport-facebook" data-toggle="tab" role="tab"><i class="fa fa-facebook"></i> (TBD) Facebook</a>
  165. </li>
  166. </ul>
  167. <div class="tab-content p-t-10">
  168. <div id="passport-ldap" class="tab-pane active" role="tabpanel" >
  169. {% include './widget/passport/ldap.html' with { settingForm: settingForm } %}
  170. </div>
  171. <div id="passport-saml" class="tab-pane" role="tabpanel" >
  172. {% include './widget/passport/saml.html' %}
  173. </div>
  174. <div id="passport-google-oauth" class="tab-pane" role="tabpanel">
  175. {% include './widget/passport/google-oauth.html' %}
  176. </div>
  177. <div id="passport-facebook" class="tab-pane" role="tabpanel">
  178. {% include './widget/passport/facebook.html' %}
  179. </div>
  180. <div id="passport-twitter" class="tab-pane" role="tabpanel">
  181. {% include './widget/passport/twitter.html' %}
  182. </div>
  183. <div id="passport-oidc" class="tab-pane" role="tabpanel">
  184. {% include './widget/passport/oidc.html' %}
  185. </div>
  186. <div id="passport-github" class="tab-pane" role="tabpanel">
  187. {% include './widget/passport/github.html' %}
  188. </div>
  189. <div id="passport-basic" class="tab-pane" role="tabpanel">
  190. {% include './widget/passport/basic.html' %}
  191. </div>
  192. </div><!-- /.tab-content -->
  193. </div>
  194. </div><!-- /.auth-mechanism-configurations -->
  195. </div>
  196. </div>
  197. <script>
  198. $('#generalSetting, #samlSetting, #googleSetting, #mechanismSetting, #githubSetting, #twitterSetting, #oidcSetting').each(function() {
  199. $(this).submit(function()
  200. {
  201. function showMessage(formId, msg, status) {
  202. $('#' + formId + ' > .alert').remove();
  203. $('#' + formId ).find('.alert').remove();
  204. if (!status) {
  205. status = 'success';
  206. }
  207. var $message = $('<p class="alert"></p>');
  208. $message.addClass('alert-' + status);
  209. $message.html(msg.replace(/\n/g, '<br>'));
  210. $message.insertAfter('#' + formId + ' .alert-anchor');
  211. if (status == 'success') {
  212. setTimeout(function()
  213. {
  214. $message.fadeOut({
  215. complete: function() {
  216. $message.remove();
  217. }
  218. });
  219. }, 5000);
  220. }
  221. }
  222. var $form = $(this);
  223. var $id = $form.attr('id');
  224. var $button = $('button', this);
  225. $button.attr('disabled', 'disabled');
  226. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  227. {
  228. if (data.status) {
  229. showMessage($id, '更新しました Updated');
  230. } else {
  231. showMessage($id, data.message, 'danger');
  232. }
  233. })
  234. .fail(function() {
  235. showMessage($id, 'エラーが発生しました Error', 'danger');
  236. })
  237. .always(function() {
  238. $button.prop('disabled', false);
  239. });
  240. return false;
  241. });
  242. });
  243. </script>
  244. </div>
  245. {% endblock content_main %}
  246. {% block content_footer %}
  247. {% endblock content_footer %}