ldap_settings_test.mustache 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <%
  19. ldap_tests = []
  20. ldap_tests << OpenStruct.new(
  21. test_type: :connection,
  22. label: t(:test_ldap_connection_label, "Testing connection..."),
  23. help_header: t(:test_ldap_connection_help_header,
  24. "Canvas can't connect to your LDAP server"),
  25. help_body: t(:test_ldap_connection_help_body,
  26. "The connection either timed out or was refused. "\
  27. "Things to consider:"),
  28. help: [
  29. t(:test_ldap_connection_help_fixes_1,
  30. "Canvas is connecting to %{ips}",
  31. ips: presenter.ldap_ips),
  32. t(:test_ldap_connection_help_fixes_2, "This was only a connection test. "\
  33. "SSL certificates were not validated."),
  34. t(:test_ldap_connection_help_fixes_3, "Check your firewall settings. "\
  35. "Are all Canvas IP address allowed to"\
  36. " access your server?")
  37. ],
  38. url: account_test_ldap_connections_url(account)
  39. )
  40. ldap_tests << OpenStruct.new(
  41. test_type: :bind,
  42. label: t(:test_ldap_bind_label, "Testing LDAP bind..."),
  43. help_header: t(:test_ldap_bind_help_header,
  44. "Canvas can't bind (login) to your LDAP server"),
  45. help_body: t(:test_ldap_bind_help_body,
  46. "Your LDAP server rejected the bind attempt. Things to consider:"),
  47. help: [
  48. t(:test_ldap_bind_help_fixes_1,
  49. "Verify the provided filter string (i.e. '(sAMAccountName={{login}})')."),
  50. t(:test_ldap_bind_help_fixes_2,
  51. "Does the username require more scoping information? "\
  52. "(i.e. 'cn=Canvas,ou=people,dc=example,dc=com').")
  53. ],
  54. url: account_test_ldap_binds_url(account)
  55. )
  56. ldap_tests << OpenStruct.new(
  57. test_type: :search,
  58. label: t(:test_ldap_search_label, "Testing LDAP search..."),
  59. help_header: t(:test_ldap_search_help_header,
  60. "Canvas can't search your LDAP instance"),
  61. help_body: t(:test_ldap_search_help_body,
  62. "The search either failed or returned 0 results. "\
  63. "Things to consider:"),
  64. help: [
  65. t(:test_ldap_search_help_fixes_1,
  66. "Verify the provided filter string (i.e. '(sAMAccountName={{login}})')."),
  67. t(:test_ldap_search_help_fixes_2,
  68. "Verify the provided search base (i.e. 'ou=people,dc=example,dc=com')."),
  69. t(:test_ldap_search_help_fixes_3,
  70. "Verify that the user object in LDAP has search privileges for the"\
  71. " provided search base.")
  72. ],
  73. url: account_test_ldap_searches_url(account)
  74. )
  75. %>
  76. <div style="display: none;width:100%">
  77. <div id="test_ldap_dialog" style="padding-top:10px;">
  78. <h3>
  79. {{#t}}Testing Your LDAP Configuration{{/t}}
  80. </h3>
  81. <table style="margin-left:20px">
  82. <% ldap_tests.each do |test| %>
  83. <tr>
  84. <td><h4 style="width: 400px"><%= test.label %></h4></td>
  85. <td><div id="ldap_<%= test.test_type %>_result"></div></td>
  86. </tr>
  87. <tr>
  88. <td colspan="2">
  89. <div id="ldap_<%= test.test_type %>_help"
  90. style="padding-left:15px;display:none">
  91. <h4><%= test.help_header %></h4>
  92. <p>
  93. <%= test.help_body %>
  94. <ul>
  95. <% test.help.each do |help| %>
  96. <li><%= help %></li>
  97. <% end %>
  98. </ul>
  99. </p>
  100. </div>
  101. </td>
  102. </tr>
  103. <% end %>
  104. <tr>
  105. <td><h4>{{#t}}Test user login...{{/t}}</h4></td>
  106. <td><div id="ldap_login_result"></div></td>
  107. </tr>
  108. <tr>
  109. <td colspan="2">
  110. <div id="ldap_login_form"
  111. style="padding-left:15px;padding-bottom:10px;display:none;">
  112. <h4>
  113. <%= t(:test_ldap_login_form_header,
  114. "Supply a valid LDAP username/password to test login:") %>
  115. </h4>
  116. <form id="ldap_test_login_form" action="">
  117. <table>
  118. <tr>
  119. <td style="width:86px;">
  120. <%= blabel :ldap_test_login, :user, en: "Username" %>
  121. </td>
  122. <td>
  123. <%= text_field :ldap_test_login, :user, style: "width:170px" %>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td>
  128. <%= blabel :ldap_test_login, :pass, en: "Password" %>
  129. </td>
  130. <td>
  131. <%= password_field :ldap_test_login, :pass, style: "width:170px" %>
  132. </td>
  133. <td style="padding-left:26px;">
  134. <input type="submit"
  135. value="{{#t}}Test Login{{/t}}"/>
  136. </td>
  137. </tr>
  138. </table>
  139. </form>
  140. </div>
  141. </td>
  142. </tr>
  143. <tr>
  144. <td colspan="2">
  145. <div id="ldap_login_help" style="padding-left:15px;display:none">
  146. <p id="ldap_login_help_error" style='color:red'>
  147. <%= t(:test_ldap_login_help_header,
  148. "The LDAP server denied your credentials") %>
  149. </p>
  150. </div>
  151. </td>
  152. </tr>
  153. </table>
  154. <button type="button" class="btn submit_button ldap_test_close" style="float:right">
  155. {{#t}}Close{{/t}}
  156. </button>
  157. </div>
  158. </div>
  159. <% js_env LDAP_TESTS: ldap_tests.map{|t|t.send(:table)},
  160. LOGIN_TEST_URL: account_test_ldap_logins_url(account) %>
  161. <% js_bundle :ldap_settings_test %>