ldap.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <form action="/_api/admin/security/ldap" method="post" class="form-horizontal passportStrategy" id="ldapSetting" role="form">
  2. <fieldset>
  3. <legend>LDAP Configuration</legend>
  4. {% set nameForIsLdapEnabled = "passportSetting[security:passport-ldap:isEnabled]" %}
  5. {% set isLdapEnabled = passportSetting['security:passport-ldap:isEnabled'] %}
  6. <div class="form-group">
  7. <label for="{{nameForIsLdapEnabled}}" class="col-xs-3 control-label">Use LDAP</label>
  8. <div class="col-xs-6">
  9. <div class="btn-group btn-toggle" data-toggle="buttons">
  10. <label class="btn btn-default {% if isLdapEnabled %}active{% endif %}" data-active-class="primary">
  11. <input name="{{nameForIsLdapEnabled}}" value="true" type="radio"
  12. {% if true === isLdapEnabled %}checked{% endif %}> Enable
  13. </label>
  14. <label class="btn btn-default {% if !isLdapEnabled %}active{% endif %}" data-active-class="primary">
  15. <input name="{{nameForIsLdapEnabled}}" value="false" type="radio"
  16. {% if !isLdapEnabled %}checked{% endif %}> Disable
  17. </label>
  18. </div>
  19. </div>
  20. </div>
  21. <div class="passport-ldap-hide-when-disabled" {%if !isLdapEnabled %}style="display: none;"{% endif %}>
  22. <div class="form-group">
  23. <label for="passportSetting[security:passport-ldap:serverUrl]" class="col-xs-3 control-label">Server URL</label>
  24. <div class="col-xs-6">
  25. <input class="form-control" type="text"
  26. name="passportSetting[security:passport-ldap:serverUrl]" value="{{ passportSetting['security:passport-ldap:serverUrl'] }}">
  27. <p class="help-block">
  28. <small>
  29. The LDAP URL of the directory service in the format <code>ldap://host:port/DN</code> or <code>ldaps://host:port/DN</code>.<br>
  30. Example: <code>ldaps://ldap.company.com/ou=people,dc=company,dc=com</code>
  31. </small>
  32. </p>
  33. </div>
  34. </div>
  35. {% set nameForIsUserBind = "passportSetting[security:passport-ldap:isUserBind]" %}
  36. {% set isUserBind = passportSetting['security:passport-ldap:isUserBind'] %}
  37. <div class="form-group">
  38. <label for="{{nameForIsUserBind}}" class="col-xs-3 control-label">Binding Mode</label>
  39. <div class="col-xs-6">
  40. <div class="btn-group btn-toggle" data-toggle="buttons">
  41. <label class="btn btn-default {% if !isUserBind %}active{% endif %}" data-active-class="primary">
  42. <input name="{{nameForIsUserBind}}" value="false" type="radio"
  43. {% if !isUserBind %}checked{% endif %}> Manager Bind
  44. </label>
  45. <label class="btn btn-default {% if isUserBind %}active{% endif %}" data-active-class="primary">
  46. <input name="{{nameForIsUserBind}}" value="true" type="radio"
  47. {% if isUserBind %}checked{% endif %}> User Bind
  48. </label>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <label for="passportSetting[security:passport-ldap:bindDN]" class="col-xs-3 control-label">Bind DN</label>
  54. <div class="col-xs-6">
  55. <input class="form-control" type="text"
  56. name="passportSetting[security:passport-ldap:bindDN]" value="{{ passportSetting['security:passport-ldap:bindDN'] }}">
  57. <p class="help-block passport-ldap-managerbind" {% if isUserBind %}style="display: none;"{% endif %}>
  58. <small>
  59. The DN of the account that authenticates and queries the directory service
  60. </small>
  61. </p>
  62. <p class="help-block passport-ldap-userbind" {% if !isUserBind %}style="display: none;"{% endif %}>
  63. <small>
  64. The query used to bind with the directory service.<br>
  65. Use <code>{% raw %}{{username}}{% endraw %}</code> to reference the username entered in the login page.<br>
  66. Example: <code>uid={% raw %}{{username}}{% endraw %},dc=domain,dc=com</code><br>
  67. </small>
  68. </p>
  69. </div>
  70. </div>
  71. <div class="form-group">
  72. <label for="passportSetting[security:passport-ldap:bindDNPassword]" class="col-xs-3 control-label">Bind DN Password</label>
  73. <div class="col-xs-6">
  74. <input class="form-control passport-ldap-managerbind" type="text" {% if isUserBind %}style="display: none;"{% endif %}
  75. name="passportSetting[security:passport-ldap:bindDNPassword]" value="{{ passportSetting['security:passport-ldap:bindDNPassword'] }}">
  76. <p class="help-block passport-ldap-managerbind">
  77. <small>
  78. The password for the Bind DN account.
  79. </small>
  80. </p>
  81. <p class="help-block passport-ldap-userbind" {% if !isUserBind %}style="display: none;"{% endif %}>
  82. <small>
  83. The password that is entered in the login page will be used to bind.
  84. </small>
  85. </p>
  86. </div>
  87. </div>
  88. <div class="form-group">
  89. <label for="passportSetting[security:passport-ldap:searchFilter]" class="col-xs-3 control-label">Search Filter</label>
  90. <div class="col-xs-6">
  91. <input class="form-control" type="text" placeholder="(uid={% raw %}{{username}}{% endraw %})"
  92. name="passportSetting[security:passport-ldap:searchFilter]" value="{{ passportSetting['security:passport-ldap:searchFilter'] }}">
  93. <p class="help-block">
  94. <small>
  95. The query used to locate the authenticated user.<br>
  96. Use <code>{% raw %}{{username}}{% endraw %}</code> to reference the username entered in the login page.<br>
  97. If empty, the filter <code>(uid={% raw %}{{username}}{% endraw %})</code> is used.<br>
  98. <br>
  99. Example to match with 'uid' or 'mail': <code>(|(uid={% raw %}{{username}}{% endraw %})(mail={% raw %}{{username}}{% endraw %}))</code>
  100. </small>
  101. </p>
  102. </div>
  103. </div>
  104. </div><!-- /.passport-ldap-configurations -->
  105. <div class="form-group">
  106. <div class="col-xs-offset-3 col-xs-6">
  107. <button type="submit" class="btn btn-default passport-ldap-hide-when-disabled" {%if !isLdapEnabled %}style="display: none;"{% endif %}>
  108. (TBD) Test to bind
  109. </button>
  110. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  111. </div>
  112. </div>
  113. </fieldset>
  114. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  115. </form>
  116. <script>
  117. // switch display according to on / off of radio buttons
  118. $('input[name="{{nameForIsLdapEnabled}}"]:radio').change(function() {
  119. const isEnabled = ($(this).val() === "true");
  120. if (isEnabled) {
  121. $('.passport-ldap-hide-when-disabled').show(400);
  122. }
  123. else {
  124. $('.passport-ldap-hide-when-disabled').hide(400);
  125. }
  126. });
  127. // switch display according to on / off of radio buttons
  128. $('input[name="{{nameForIsUserBind}}"]:radio').change(function() {
  129. const isUserBind = ($(this).val() === "true");
  130. if (isUserBind) {
  131. $('input.passport-ldap-managerbind').hide();
  132. $('.help-block.passport-ldap-managerbind').hide();
  133. $('.help-block.passport-ldap-userbind').show();
  134. }
  135. else {
  136. $('input.passport-ldap-managerbind').show();
  137. $('.help-block.passport-ldap-managerbind').show();
  138. $('.help-block.passport-ldap-userbind').hide();
  139. }
  140. });
  141. </script>