saml.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 = settingForm['security:passport-saml:isEnabled'] %}
  6. <div class="form-group">
  7. <label for="{{nameForIsSamlEnabled}}" class="col-xs-3 control-label">{{ t("security_setting.SAML.name") }}</label>
  8. <div class="col-xs-6">
  9. <div class="btn-group btn-toggle" data-toggle="buttons">
  10. <label class="btn btn-default btn-rounded btn-outline {% if isSamlEnabled %}active{% endif %}" data-active-class="primary">
  11. <input name="{{nameForIsSamlEnabled}}" value="true" type="radio"
  12. {% if true === isSamlEnabled %}checked{% endif %}> ON
  13. </label>
  14. <label class="btn btn-default btn-rounded btn-outline {% if !isSamlEnabled %}active{% endif %}" data-active-class="default">
  15. <input name="{{nameForIsSamlEnabled}}" value="false" type="radio"
  16. {% if !isSamlEnabled %}checked{% endif %}> OFF
  17. </label>
  18. </div>
  19. </div>
  20. </div>
  21. <fieldset id="passport-saml-hide-when-disabled" {%if !isSamlEnabled %}style="display: none;"{% endif %}>
  22. <div class="form-group">
  23. <label for="settingForm[security:passport-saml:entryPoint]" class="col-xs-3 control-label">{{ t("security_setting.SAML.entry_point") }}</label>
  24. <div class="col-xs-6">
  25. <input class="form-control" type="text" name="settingForm[security:passport-saml:entryPoint]" value="{{ settingForm['security:passport-saml:entryPoint'] || '' }}">
  26. <p class="help-block">
  27. <small>
  28. {{ t("security_setting.Use env var if empty", "SAML_ENTRY_POINT") }}
  29. </small>
  30. </p>
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label class="col-xs-3 control-label">{{ t("security_setting.callback_URL") }}</label>
  35. <div class="col-xs-6">
  36. <input class="form-control" type="text" value="{% if settingForm['app:siteUrl'] %}{{ settingForm['app:siteUrl'] }}{% else %}[INVALID] {% endif %}/passport/saml/callback" readonly>
  37. <p class="help-block small">{{ t("security_setting.desc_of_callback_URL", 'SAML Identity') }}</p>
  38. {% if !settingForm['app:siteUrl'] %}
  39. <div class="alert alert-danger">
  40. <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>') }}
  41. </div>
  42. {% endif %}
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label for="settingForm[security:passport-saml:issuer]" class="col-xs-3 control-label">{{ t("security_setting.SAML.issuer") }}</label>
  47. <div class="col-xs-6">
  48. <input class="form-control" type="text" name="settingForm[security:passport-saml:issuer]" value="{{ settingForm['security:passport-saml:issuer'] || '' }}">
  49. <p class="help-block">
  50. <small>
  51. {{ t("security_setting.Use env var if empty", "SAML_ISSUER") }}
  52. </small>
  53. </p>
  54. </div>
  55. </div>
  56. <h4>Attribute Mapping</h4>
  57. <div class="form-group">
  58. <label for="settingForm[security:passport-saml:attrMapId]" class="col-xs-3 control-label">Identifier</label>
  59. <div class="col-xs-6">
  60. <input class="form-control" type="text"
  61. name="settingForm[security:passport-saml:attrMapId]" value="{{ settingForm['security:passport-saml:attrMapId'] || '' }}">
  62. <p class="help-block">
  63. <small>
  64. {{ t("security_setting.SAML.id_detail") }}
  65. </small>
  66. </p>
  67. </div>
  68. </div>
  69. <div class="form-group">
  70. <label for="settingForm[security:passport-saml:attrMapUsername]" class="col-xs-3 control-label">Username</label>
  71. <div class="col-xs-6">
  72. <input class="form-control" type="text"
  73. name="settingForm[security:passport-saml:attrMapUsername]" value="{{ settingForm['security:passport-saml:attrMapUsername'] || '' }}">
  74. <p class="help-block">
  75. <small>
  76. {{ t("security_setting.SAML.username_detail") }}
  77. </small>
  78. </p>
  79. </div>
  80. </div>
  81. <div class="form-group">
  82. <div class="col-xs-6 col-xs-offset-3">
  83. <div class="checkbox checkbox-info">
  84. <input type="checkbox" id="bindByUserName-SAML" name="settingForm[security:passport-saml:isSameUsernameTreatedAsIdenticalUser]" value="1"
  85. {% if settingForm['security:passport-saml:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  86. <label for="bindByUserName-SAML">
  87. {{ t("security_setting.Treat username matching as identical", "username") }}
  88. </label>
  89. <p class="help-block">
  90. <small>
  91. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  92. </small>
  93. </p>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="form-group">
  98. <label for="settingForm[security:passport-saml:attrMapMail]" class="col-xs-3 control-label">Mail</label>
  99. <div class="col-xs-6">
  100. <input class="form-control" type="text"
  101. name="settingForm[security:passport-saml:attrMapMail]" value="{{ settingForm['security:passport-saml:attrMapMail'] || '' }}">
  102. <p class="help-block">
  103. <small>
  104. {{ t("security_setting.SAML.mapping_detail", t("Email")) }}
  105. </small>
  106. </p>
  107. </div>
  108. </div>
  109. <div class="form-group">
  110. <label for="settingForm[security:passport-saml:attrMapFirstName]" class="col-xs-3 control-label">{{ t("security_setting.SAML.First Name") }}</label>
  111. <div class="col-xs-6">
  112. <input class="form-control" type="text" placeholder="Default: firstName"
  113. name="settingForm[security:passport-saml:attrMapFirstName]" value="{{ settingForm['security:passport-saml:attrMapFirstName'] || '' }}">
  114. <p class="help-block">
  115. <small>
  116. {{ t("security_setting.SAML.mapping_detail", t("security_setting.SAML.First Name")) }}
  117. </small>
  118. </p>
  119. </div>
  120. </div>
  121. <div class="form-group">
  122. <label for="settingForm[security:passport-saml:attrMapLastName]" class="col-xs-3 control-label">{{ t("security_setting.SAML.Last Name") }}</label>
  123. <div class="col-xs-6">
  124. <input class="form-control" type="text" placeholder="Default: lastName"
  125. name="settingForm[security:passport-saml:attrMapLastName]" value="{{ settingForm['security:passport-saml:attrMapLastName'] || '' }}">
  126. <p class="help-block">
  127. <small>
  128. {{ t("security_setting.SAML.mapping_detail", t("security_setting.SAML.Last Name")) }}
  129. </small>
  130. </p>
  131. </div>
  132. </div>
  133. <h4>Options</h4>
  134. <div class="form-group">
  135. <label for="settingForm[security:passport-saml:cert]" class="col-xs-3 control-label">Certificate</label>
  136. <div class="col-xs-6">
  137. <textarea class="form-control input-sm" type="text" rows="5" name="settingForm[security:passport-saml:cert]">{{ settingForm['security:passport-saml:cert'] || '' }}</textarea>
  138. <p class="help-block">
  139. <small>
  140. {{ t("security_setting.SAML.cert_detail1") }}<br>
  141. {{ t("security_setting.SAML.cert_detail2") }}
  142. </small>
  143. </p>
  144. <p>
  145. <small>
  146. e.g.
  147. <pre>-----BEGIN CERTIFICATE-----
  148. MIICBzCCAXACCQD4US7+0A/b/zANBgkqhkiG9w0BAQsFADBIMQswCQYDVQQGEwJK
  149. UDEOMAwGA1UECAwFVG9reW8xFTATBgNVBAoMDFdFU0VFSywgSW5jLjESMBAGA1UE
  150. ...
  151. crmVwBzbloUO2l6k1ibwD2WVwpdxMKIF5z58HfKAvxZAzCHE7kMEZr1ge30WRXQA
  152. pWVdnzS1VCO8fKsJ7YYIr+JmHvseph3kFUOI5RqkCcMZlKUv83aUThsTHw==
  153. -----END CERTIFICATE-----</pre>
  154. </small>
  155. </p>
  156. </div>
  157. </div>
  158. </fieldset>
  159. <div class="form-group" id="btn-update">
  160. <div class="col-xs-offset-3 col-xs-6">
  161. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  162. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  163. </div>
  164. </div>
  165. </form>
  166. <script>
  167. $('input[name="settingForm[security:passport-saml:isEnabled]"]').change(function() {
  168. const isEnabled = ($(this).val() === "true");
  169. if (isEnabled) {
  170. $('#passport-saml-hide-when-disabled').show(400);
  171. }
  172. else {
  173. $('#passport-saml-hide-when-disabled').hide(400);
  174. }
  175. });
  176. </script>