security.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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" id="admin-security-setting">
  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('security_setting.Guest Users Access') }}</label>
  38. <div class="col-xs-6">
  39. {% set selectedValue = guestModeValue %}
  40. <select class="form-control selectpicker" {% if isWikiModeForced %}disabled{% endif %}
  41. name="settingForm[security:restrictGuestMode]" value="{{ getConfig('crowi', 'security:restrictGuestMode') }}">
  42. {% for modeValue, modeLabel in consts.restrictGuestMode %}
  43. <option value="{{ t(modeValue) }}" {% if modeValue == selectedValue %}selected{% endif %}>{{ t(modeLabel) }}</option>
  44. {% endfor %}
  45. </select>
  46. {% if isWikiModeForced %}
  47. <p class="alert alert-warning mt-2">
  48. <i class="icon-exclamation icon-fw"></i><b>FIXED</b><br>
  49. {{ t('security_setting.Fixed by env var', 'FORCE_WIKI_MODE', getConfig('crowi', 'security:wikiMode')) }}
  50. </p>
  51. {% endif %}
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. {% set configName = 'settingForm[security:list-policy:hideRestrictedByOwner]' %}
  56. {% set configValue = getConfig('crowi', 'security:list-policy:hideRestrictedByOwner') %}
  57. {% set isEnabled = !configValue %}
  58. <label for="{{configName}}" class="col-xs-3 control-label">{{ t("security_setting.page_listing_1") }}</label>
  59. <div class="col-xs-9">
  60. <div class="btn-group btn-toggle" data-toggle="buttons">
  61. <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
  62. <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
  63. </label>
  64. <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
  65. <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
  66. </label>
  67. </div>
  68. <p class="help-block small">
  69. {{ t("security_setting.page_listing_1_desc") }}
  70. </p>
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. {% set configName = 'settingForm[security:list-policy:hideRestrictedByGroup]' %}
  75. {% set configValue = getConfig('crowi', 'security:list-policy:hideRestrictedByGroup') %}
  76. {% set isEnabled = !configValue %}
  77. <label for="{{configName}}" class="col-xs-3 control-label">{{ t("security_setting.page_listing_2") }}</label>
  78. <div class="col-xs-9">
  79. <div class="btn-group btn-toggle" data-toggle="buttons">
  80. <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
  81. <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
  82. </label>
  83. <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
  84. <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
  85. </label>
  86. </div>
  87. <p class="help-block small">
  88. {{ t("security_setting.page_listing_2_desc") }}
  89. </p>
  90. </div>
  91. </div>
  92. <div class="form-group">
  93. {% set configName = 'settingForm[security:pageCompleteDeletionAuthority]' %}
  94. {% set configValue = getConfig('crowi','security:pageCompleteDeletionAuthority') %}
  95. <label for="{{configName}}" class="col-xs-3 control-label">{{ t('security_setting.complete_deletion') }}</label>
  96. <div class="col-xs-6">
  97. <select class="form-control selectpicker" name="settingForm[security:pageCompleteDeletionAuthority]" value="{{ configValue }}">
  98. <option value="anyOne" {% if configValue == "anyOne" %}selected{% endif %}>{{ t('security_setting.anyone') }}</option>
  99. <option value="adminOnly" {% if configValue =="adiminOnly" %}selected{% endif %}>{{ t('security_setting.admin_only') }}</option>
  100. <option value="adminAndAuthor" {% if configValue == "adminAndAuthor" %}selected{% endif %}>{{ t('security_setting.admin_and_author') }}</option>
  101. </select>
  102. <p class="help-block small">
  103. {{ t('security_setting.complete_deletion_explain') }}
  104. </p>
  105. </div>
  106. </div>
  107. <div class="form-group">
  108. <div class="col-xs-offset-3 col-xs-6">
  109. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  110. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  111. </div>
  112. </div>
  113. </fieldset>
  114. </form>
  115. <!-- prevent XSS link -->
  116. <div class="mt-5">
  117. <legend>{{ t('security_setting.xss_prevent_setting') }}</legend>
  118. <div class="text-center">
  119. <a class="flexbox" style="font-size: large;" href="/admin/markdown/#preventXSS">
  120. <i class="fa-fw icon-login"></i> {{ t('security_setting.xss_prevent_setting_link') }}
  121. </a>
  122. </div>
  123. </div>
  124. <div class="auth-mechanism-configurations m-t-10">
  125. <legend>{{ t('security_setting.Authentication mechanism settings') }}</legend>
  126. {#
  127. # passport settings nav
  128. #}
  129. <div class="passport-settings">
  130. <ul class="nav nav-tabs" role="tablist">
  131. <li class="active">
  132. <a href="#passport-local" data-toggle="tab" role="tab"><i class="fa fa-users"></i> ID/Pass</a>
  133. </li>
  134. <li>
  135. <a href="#passport-ldap" data-toggle="tab" role="tab"><i class="fa fa-sitemap"></i> LDAP</a>
  136. </li>
  137. <li>
  138. <a href="#passport-saml" data-toggle="tab" role="tab"><i class="fa fa-key"></i> SAML</a>
  139. </li>
  140. <li>
  141. <a href="#passport-oidc" data-toggle="tab" role="tab"><i class="fa fa-openid"></i> OIDC</a>
  142. </li>
  143. <li>
  144. <a href="#passport-basic" data-toggle="tab" role="tab"><i class="fa fa-lock"></i> Basic</a>
  145. </li>
  146. <li>
  147. <a href="#passport-google-oauth" data-toggle="tab" role="tab"><i class="fa fa-google"></i> Google</a>
  148. </li>
  149. <li>
  150. <a href="#passport-github" data-toggle="tab" role="tab"><i class="fa fa-github"></i> GitHub</a>
  151. </li>
  152. <li>
  153. <a href="#passport-twitter" data-toggle="tab" role="tab"><i class="fa fa-twitter"></i> Twitter</a>
  154. </li>
  155. <li class="tbd">
  156. <a href="#passport-facebook" data-toggle="tab" role="tab"><i class="fa fa-facebook"></i> (TBD) Facebook</a>
  157. </li>
  158. </ul>
  159. <div class="tab-content p-t-10">
  160. <div id="passport-local" class="tab-pane active" role="tabpanel" >
  161. {% include './widget/passport/local.html' %}
  162. </div>
  163. <div id="passport-ldap" class="tab-pane" role="tabpanel" >
  164. {% include './widget/passport/ldap.html' with { settingForm: settingForm } %}
  165. </div>
  166. <div id="passport-saml" class="tab-pane" role="tabpanel" >
  167. {% include './widget/passport/saml.html' %}
  168. </div>
  169. <div id="passport-oidc" class="tab-pane" role="tabpanel">
  170. {% include './widget/passport/oidc.html' %}
  171. </div>
  172. <div id="passport-basic" class="tab-pane" role="tabpanel">
  173. {% include './widget/passport/basic.html' %}
  174. </div>
  175. <div id="passport-google-oauth" class="tab-pane" role="tabpanel">
  176. {% include './widget/passport/google-oauth.html' %}
  177. </div>
  178. <div id="passport-facebook" class="tab-pane" role="tabpanel">
  179. {% include './widget/passport/facebook.html' %}
  180. </div>
  181. <div id="passport-twitter" class="tab-pane" role="tabpanel">
  182. {% include './widget/passport/twitter.html' %}
  183. </div>
  184. <div id="passport-github" class="tab-pane" role="tabpanel">
  185. {% include './widget/passport/github.html' %}
  186. </div>
  187. </div><!-- /.tab-content -->
  188. </div>
  189. </div><!-- /.auth-mechanism-configurations -->
  190. </div>
  191. </div>
  192. <script>
  193. $('#generalSetting, #localSetting, #samlSetting, #basicSetting, #googleSetting, #githubSetting, #twitterSetting, #oidcSetting').each(function() {
  194. $(this).submit(function()
  195. {
  196. function showMessage(formId, msg, status) {
  197. $('#' + formId + ' > .alert').remove();
  198. $('#' + formId ).find('.alert').remove();
  199. if (!status) {
  200. status = 'success';
  201. }
  202. var $message = $('<p class="alert"></p>');
  203. $message.addClass('alert-' + status);
  204. $message.html(msg.replace(/\n/g, '<br>'));
  205. $message.insertAfter('#' + formId + ' .alert-anchor');
  206. if (status == 'success') {
  207. setTimeout(function()
  208. {
  209. $message.fadeOut({
  210. complete: function() {
  211. $message.remove();
  212. }
  213. });
  214. }, 5000);
  215. }
  216. }
  217. var $form = $(this);
  218. var $id = $form.attr('id');
  219. var $button = $('button', this);
  220. $button.attr('disabled', 'disabled');
  221. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  222. {
  223. if (data.status) {
  224. showMessage($id, '更新しました Updated');
  225. } else {
  226. showMessage($id, data.message, 'danger');
  227. }
  228. })
  229. .fail(function() {
  230. showMessage($id, 'エラーが発生しました Error', 'danger');
  231. })
  232. .always(function() {
  233. $button.prop('disabled', false);
  234. });
  235. return false;
  236. });
  237. });
  238. </script>
  239. </div>
  240. {% endblock content_main %}
  241. {% block content_footer %}
  242. {% endblock content_footer %}