<%
# Copyright (C) 2015 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<h2><%= t 'SSO Settings' %></h2>
<div class="content-box">
  <div class="grid-row">
    <div class="col-xs-12 col-lg-11 off-lg-1">
      <%= form_for(account, as: :sso_settings,
                   url: account_update_sso_settings_path(account),
                   method: :put,
                   html: { class: "ic-Form ic-Form--horizontal" }) do |f| %>
        <div class="ic-Form-control">
          <%= f.label :login_handle_name, t("Login Label"),
                      class: 'ic-Label' %>
          <%= f.text_field :login_handle_name,
                           placeholder: presenter.login_placeholder,
                           :class => 'ic-Input',
                           'aria-describedby' => 'login_handle_name_description' %>
          <div class="ic-Form-help-text" id="login_handle_name_description">
            <%= t(:login_handle_name_description,
                  "The label used for unique login identifiers. Examples: "\
                  "Login, Username, Student ID, etc.") %>
          </div>
        </div>
        <div class="ic-Form-control">
          <%= f.label :change_password_url, t("Forgot Password URL"),
                      class: 'ic-Label' %>
          <%= f.text_field :change_password_url,
                           :class => 'ic-Input',
                           'aria-describedby' => 'change_password_url_description' %>
          <div class="ic-Form-help-text" id="change_password_url_description">
            <%= t(:change_password_url_help,
                  "Leave blank for default Canvas behavior") %>
          </div>
        </div>
        <div class="ic-Form-control">
          <%= f.label :auth_discovery_url, t("Discovery URL"),
                      class: 'ic-Label' %>
          <%= f.text_field :auth_discovery_url,
                           :class => 'ic-Input',
                           'aria-describedby' => 'auth_discovery_url_description' %>
          <div class="ic-Form-help-text" id="auth_discovery_url_description">
            <%= t('discovery_url_description', <<-TEXT)
If a discovery URL is set, Canvas will forward all users to that URL when they need to be authenticated.
That page will need to then help the user figure out where they need to go to log in.
If no discovery URL is configured, the first configuration will be used to attempt to authenticate the user.
                TEXT
            %>
          </div>
        </div>
        <% if presenter.needs_unknown_user_url? %>
          <div class="ic-Form-control">
            <%= f.label :unknown_user_url, t("Unknown User URL"),
                        class: 'ic-Label' %>
            <%= f.text_field :unknown_user_url,
                             placeholder: login_url,
                             :class => 'ic-Input',
                             'aria-describedby' => 'unknown_user_url_description' %>
            <div class="ic-Form-help-text" id="unknown_user_url_description">
              <%= t(:unknown_user_url_description,
                    "The url to redirect to when an authenticated user is not "\
                    "found in Canvas.") %>
            </div>
          </div>
        <% end %>
        <div class="ic-Form-actions">
          <%= f.button t('Save'), class: "Button Button--primary" %>
        </div>
      <% end %>
    </div>
  </div>
</div>
