saml.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <form action="/_api/admin/security/passport-saml" method="post" class="form-horizontal passportStrategy" id="samlSetting" role="form"
  2. {% if isRestartingServerNeeded %}style="opacity: 0.4;"{% endif %}>
  3. <legend class="alert-anchor">{{ t("security_setting.SAML.name") }} {{ t("security_setting.configuration") }}</legend>
  4. {% set nameForIsSamlEnabled = "settingForm[security:passport-saml:isEnabled]" %}
  5. {% set isSamlEnabled = getConfig('crowi', 'security:passport-saml:isEnabled') %}
  6. <style>
  7. .authentication-settings-table {
  8. table-layout: fixed;
  9. }
  10. .authentication-settings-table .item-name{
  11. width: 150px;
  12. }
  13. .authentication-settings-table.use-only-env-vars .from-env-vars {
  14. background-color: rgba(0, 159, 187, 0.1);
  15. }
  16. </style>
  17. <div class="form-group">
  18. <label class="col-xs-3 control-label">{{ t("security_setting.SAML.name") }}</label>
  19. <div class="col-xs-6">
  20. <div class="btn-group btn-toggle" data-toggle="buttons">
  21. <label class="btn btn-default btn-rounded btn-outline {% if isSamlEnabled %}active{% endif %}" data-active-class="primary">
  22. <input name="{{nameForIsSamlEnabled}}" value="true" type="radio"
  23. {% if true === isSamlEnabled %}checked{% endif %}> ON
  24. </label>
  25. <label class="btn btn-default btn-rounded btn-outline {% if !isSamlEnabled %}active{% endif %}" data-active-class="default">
  26. <input name="{{nameForIsSamlEnabled}}" value="false" type="radio"
  27. {% if !isSamlEnabled %}checked{% endif %}> OFF
  28. </label>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <label class="col-xs-3 control-label">{{ t("security_setting.callback_URL") }}</label>
  34. <div class="col-xs-6">
  35. <input class="form-control"
  36. type="text"
  37. value="{% if settingForm['app:siteUrl'] %}{{ settingForm['app:siteUrl'] }}{% else %}[INVALID] {% endif %}/passport/saml/callback"
  38. readonly>
  39. <p class="help-block small">{{ t("security_setting.desc_of_callback_URL", 'SAML Identity') }}</p>
  40. {% if !settingForm['app:siteUrl'] %}
  41. <div class="alert alert-danger">
  42. <i class="icon-exclamation"></i> {{ t("security_setting.alert_siteUrl_is_not_set", '<a href="/admin/app">' + t('App settings') + '<i class="icon-login"></i></a>') }}
  43. </div>
  44. {% endif %}
  45. </div>
  46. </div>
  47. <fieldset id="passport-saml-hide-when-disabled" {%if !isSamlEnabled %}style="display: none;"{% endif %}>
  48. <h4>Basic Settings</h4>
  49. <table class="table authentication-settings-table">
  50. <colgroup>
  51. <col class="item-name">
  52. <col class="from-db">
  53. <col class="from-env-vars">
  54. </colgroup>
  55. <thead>
  56. <tr><th></th><th>Database</th><th>Environment variables</th></tr>
  57. </thead>
  58. <tbody>
  59. <tr>
  60. <th>{{ t("security_setting.SAML.entry_point") }}</th>
  61. <td>
  62. <input class="form-control"
  63. type="text"
  64. name="settingForm[security:passport-saml:entryPoint]"
  65. value="{{ getConfigFromDB('crowi', 'security:passport-saml:entryPoint') || '' }}">
  66. <p class="help-block">
  67. <small>
  68. {{ t("security_setting.Use env var if empty", "SAML_ENTRY_POINT") }}
  69. </small>
  70. </p>
  71. </td>
  72. <td>
  73. <input class="form-control"
  74. type="text"
  75. value="{{ getConfigFromEnvVars('crowi', 'security:passport-saml:entryPoint') || '' }}"
  76. readonly>
  77. </td>
  78. </tr>
  79. <tr>
  80. <th>{{ t("security_setting.SAML.issuer") }}</th>
  81. <td>
  82. <input class="form-control"
  83. type="text"
  84. name="settingForm[security:passport-saml:issuer]"
  85. value="{{ getConfigFromDB('crowi', 'security:passport-saml:issuer') || '' }}">
  86. <p class="help-block">
  87. <small>
  88. {{ t("security_setting.Use env var if empty", "SAML_ISSUER") }}
  89. </small>
  90. </p>
  91. </td>
  92. <td>
  93. <input class="form-control"
  94. type="text"
  95. value="{{ getConfigFromEnvVars('crowi', 'security:passport-saml:issuer') || '' }}"
  96. readonly>
  97. </td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. <h4>Attribute Mapping</h4>
  102. <table class="table authentication-settings-table">
  103. <colgroup>
  104. <col class="item-name">
  105. <col class="from-db">
  106. <col class="from-env-vars">
  107. </colgroup>
  108. <thead>
  109. <tr><th></th><th>Database</th><th>Environment variables</th></tr>
  110. </thead>
  111. <tbody>
  112. <tr>
  113. <th>Identifier</th>
  114. <td>
  115. <input class="form-control"
  116. type="text"
  117. name="settingForm[security:passport-saml:attrMapId]"
  118. value="{{ getConfigFromDB('security:passport-saml:attrMapId') || '' }}">
  119. <p class="help-block">
  120. <small>
  121. {{ t("security_setting.SAML.id_detail") }}
  122. </small>
  123. </p>
  124. </td>
  125. <td>
  126. <input class="form-control"
  127. type="text"
  128. value="{{ getConfigFromEnvVars('security:passport-saml:attrMapId') || '' }}"
  129. readonly>
  130. </td>
  131. </tr>
  132. <tr>
  133. <th>Username</th>
  134. <td>
  135. <input class="form-control"
  136. type="text"
  137. name="settingForm[security:passport-saml:attrMapUsername]"
  138. value="{{ getConfigFromDB('security:passport-saml:attrMapUsername') || '' }}">
  139. <p class="help-block">
  140. <small>
  141. {{ t("security_setting.SAML.username_detail") }}
  142. </small>
  143. </p>
  144. </td>
  145. <td>
  146. <input class="form-control"
  147. type="text"
  148. value="{{ getConfigFromEnvVars('security:passport-saml:attrMapUsername') || '' }}"
  149. readonly>
  150. </td>
  151. </tr>
  152. <tr>
  153. <th>Mail</th>
  154. <td>
  155. <input class="form-control"
  156. type="text"
  157. name="settingForm[security:passport-saml:attrMapMail]"
  158. value="{{ getConfigFromDB('security:passport-saml:attrMapMail') || '' }}">
  159. <p class="help-block">
  160. <small>
  161. {{ t("security_setting.SAML.mapping_detail", t("Email")) }}
  162. </small>
  163. </td>
  164. <td>
  165. <input class="form-control"
  166. type="text"
  167. value="{{ getConfigFromEnvVars('security:passport-saml:attrMapMail') || '' }}"
  168. readonly>
  169. </td>
  170. </tr>
  171. <tr>
  172. <th>{{ t("security_setting.SAML.First Name") }}</th>
  173. <td>
  174. <input class="form-control"
  175. type="text"
  176. placeholder="Default: firstName"
  177. name="settingForm[security:passport-saml:attrMapFirstName]"
  178. value="{{ getConfigFromDB('security:passport-saml:attrMapFirstName') || '' }}">
  179. <p class="help-block">
  180. <small>
  181. {{ t("security_setting.SAML.mapping_detail", t("security_setting.SAML.First Name")) }}
  182. </small>
  183. </p>
  184. </td>
  185. <td>
  186. <input class="form-control"
  187. type="text"
  188. value="{{ getConfigFromEnvVars('security:passport-saml:attrMapFirstName') || '' }}"
  189. readonly>
  190. </td>
  191. </tr>
  192. <tr>
  193. <th>{{ t("security_setting.SAML.Last Name") }}</th>
  194. <td>
  195. <input class="form-control"
  196. type="text"
  197. placeholder="Default: lastName"
  198. name="settingForm[security:passport-saml:attrMapLastName]"
  199. value="{{ getConfigFromDB('security:passport-saml:attrMapLastName') || '' }}">
  200. <p class="help-block">
  201. <small>
  202. {{ t("security_setting.SAML.mapping_detail", t("security_setting.SAML.Last Name")) }}
  203. </small>
  204. </p>
  205. </td>
  206. <td>
  207. <input class="form-control"
  208. type="text"
  209. value="{{ getConfigFromEnvVars('security:passport-saml:attrMapLastName') || '' }}"
  210. readonly>
  211. </td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. <h4>Attribute Mapping Options</h4>
  216. <div class="form-group">
  217. <div class="col-xs-offset-1">
  218. <div class="checkbox checkbox-info">
  219. <input id="bindByUserName-SAML"
  220. type="checkbox"
  221. name="settingForm[security:passport-saml:isSameUsernameTreatedAsIdenticalUser]"
  222. value="1"
  223. {% if settingForm['security:passport-saml:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  224. <label for="bindByUserName-SAML">
  225. {{ t("security_setting.Treat username matching as identical", "username") }}
  226. </label>
  227. <p class="help-block">
  228. <small>
  229. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  230. </small>
  231. </p>
  232. </div>
  233. </div>
  234. </div>
  235. <div class="form-group">
  236. <div class="col-xs-offset-1">
  237. <div class="checkbox checkbox-info">
  238. <input id="bindByEmail-SAML"
  239. type="checkbox"
  240. name="settingForm[security:passport-saml:isSameEmailTreatedAsIdenticalUser]"
  241. value="1"
  242. {% if settingForm['security:passport-saml:isSameEmailTreatedAsIdenticalUser'] %}checked{% endif %} />
  243. <label for="bindByEmail-SAML">
  244. {{ t("security_setting.Treat email matching as identical", "email") }}
  245. </label>
  246. <p class="help-block">
  247. <small>
  248. {{ t("security_setting.Treat email matching as identical_warn", "email") }}
  249. </small>
  250. </p>
  251. </div>
  252. </div>
  253. </div>
  254. <h4>Options</h4>
  255. <table class="table authentication-settings-table">
  256. <colgroup>
  257. <col class="item-name">
  258. <col class="from-db">
  259. <col class="from-env-vars">
  260. </colgroup>
  261. <thead>
  262. <tr><th></th><th>Database</th><th>Environment variables</th></tr>
  263. </thead>
  264. <tbody>
  265. <tr>
  266. <th>Certificate</th>
  267. <td>
  268. <textarea class="form-control input-sm"
  269. type="text"
  270. rows="5"
  271. name="settingForm[security:passport-saml:cert]"
  272. >{{ getConfigFromDB('security:passport-saml:cert') || '' }}</textarea>
  273. <p class="help-block">
  274. <small>
  275. {{ t("security_setting.SAML.cert_detail1") }}<br>
  276. {{ t("security_setting.SAML.cert_detail2") }}
  277. </small>
  278. </p>
  279. <p>
  280. <small>
  281. e.g.
  282. <pre>-----BEGIN CERTIFICATE-----
  283. MIICBzCCAXACCQD4US7+0A/b/zANBgkqhkiG9w0BAQsFADBIMQswCQYDVQQGEwJK
  284. UDEOMAwGA1UECAwFVG9reW8xFTATBgNVBAoMDFdFU0VFSywgSW5jLjESMBAGA1UE
  285. ...
  286. crmVwBzbloUO2l6k1ibwD2WVwpdxMKIF5z58HfKAvxZAzCHE7kMEZr1ge30WRXQA
  287. pWVdnzS1VCO8fKsJ7YYIr+JmHvseph3kFUOI5RqkCcMZlKUv83aUThsTHw==
  288. -----END CERTIFICATE-----</pre>
  289. </small>
  290. </p>
  291. </td>
  292. <td>
  293. <textarea class="form-control input-sm"
  294. type="text"
  295. rows="5"
  296. readonly>
  297. {{ getConfigFromEnvVars('security:passport-saml:cert') || '' }}
  298. </textarea>
  299. </td>
  300. </tr>
  301. </tbody>
  302. </table>
  303. </fieldset>
  304. <div class="form-group" id="btn-update">
  305. <div class="col-xs-offset-3 col-xs-6">
  306. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  307. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  308. </div>
  309. </div>
  310. </form>
  311. <script>
  312. $('input[name="settingForm[security:passport-saml:isEnabled]"]').change(function() {
  313. const isEnabled = ($(this).val() === "true");
  314. if (isEnabled) {
  315. $('#passport-saml-hide-when-disabled').show(400);
  316. }
  317. else {
  318. $('#passport-saml-hide-when-disabled').hide(400);
  319. }
  320. });
  321. </script>