security.html 11 KB

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