saml.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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">User ID</label>
  59. <div class="col-xs-6">
  60. <input class="form-control" type="text" placeholder="Default: id"
  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.mapping_detail", "User ID") }}
  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" placeholder="Default: username"
  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.mapping_detail", "Username") }}
  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:attrMapFirstName]" class="col-xs-3 control-label">First Name</label>
  99. <div class="col-xs-6">
  100. <input class="form-control" type="text" placeholder="Default: firstName"
  101. name="settingForm[security:passport-saml:attrMapFirstName]" value="{{ settingForm['security:passport-saml:attrMapFirstName'] || '' }}">
  102. <p class="help-block">
  103. <small>
  104. {{ t("security_setting.SAML.mapping_detail", "First Name") }}
  105. </small>
  106. </p>
  107. </div>
  108. </div>
  109. <div class="form-group">
  110. <label for="settingForm[security:passport-saml:attrMapLastName]" class="col-xs-3 control-label">Last Name</label>
  111. <div class="col-xs-6">
  112. <input class="form-control" type="text" placeholder="Default: lastName"
  113. name="settingForm[security:passport-saml:attrMapLastName]" value="{{ settingForm['security:passport-saml:attrMapLastName'] || '' }}">
  114. <p class="help-block">
  115. <small>
  116. {{ t("security_setting.SAML.mapping_detail", "Last Name") }}
  117. </small>
  118. </p>
  119. </div>
  120. </div>
  121. </fieldset>
  122. <div class="form-group" id="btn-update">
  123. <div class="col-xs-offset-3 col-xs-6">
  124. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  125. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  126. </div>
  127. </div>
  128. </form>
  129. <script>
  130. $('input[name="settingForm[security:passport-saml:isEnabled]"]').change(function() {
  131. const isEnabled = ($(this).val() === "true");
  132. if (isEnabled) {
  133. $('#passport-saml-hide-when-disabled').show(400);
  134. }
  135. else {
  136. $('#passport-saml-hide-when-disabled').hide(400);
  137. }
  138. });
  139. </script>