{#
 # ---------------------------------------------------------------------
 #
 # GLPI - Gestionnaire Libre de Parc Informatique
 #
 # http://glpi-project.org
 #
 # @copyright 2015-2025 Teclib' and contributors.
 # @licence   https://www.gnu.org/licenses/gpl-3.0.html
 #
 # ---------------------------------------------------------------------
 #
 # LICENSE
 #
 # This file is part of GLPI.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program 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 General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #
 # ---------------------------------------------------------------------
 #}

{% import 'components/form/fields_macros.html.twig' as fields %}
{% import 'components/form/basic_inputs_macros.html.twig' as inputs %}

<div class="asset card">
   <form name="cas" action="{{ path('/front/auth.others.php') }}" method="post">
      <div class="card-body d-flex flex-wrap px-0">
         <div class="col-12 col-xxl-12 flex-column">
            <div class="d-flex flex-row flex-wrap flex-xl-nowrap">
               <div class="row flex-row align-items-start flex-grow-1 mx-0">
                  <div class="row flex-row mx-0">
                     {{ fields.smallTitle(__('CAS authentication')) }}
                     {% if config['cas_host'] is not empty %}
                        <div class="alert alert-info">{{ _x('authentication', 'Enabled') }}</div>
                     {% endif %}
                     {{ fields.textField('cas_host', config['cas_host'], __('CAS Host')) }}
                     {{ fields.htmlField('', call('Auth::dropdownCasVersion', [config['cas_version'], {
                        display: false
                     }]), __('CAS Version')) }}
                     {{ fields.textField('cas_port', config['cas_port'], _n('Port', 'Ports', 1)) }}
                     {{ fields.textField('cas_uri', config['cas_uri'], __('Root directory (optional)')) }}
                     {{ fields.textField('cas_logout', config['cas_logout'], __('Log out fallback URL')) }}

                     {{ fields.smallTitle(__('x509 certificate authentication')) }}
                     {% if config['x509_email_field'] is not empty %}
                        <div class="alert alert-info">{{ _x('authentication', 'Enabled') }}</div>
                     {% endif %}
                     {{ fields.textField(
                        'x509_email_field',
                        config['x509_email_field'],
                        __('Email attribute for x509 authentication')
                     ) }}
                     {{ fields.textField(
                        'x509_ou_restrict',
                        config['x509_ou_restrict'],
                        __('Restrict %s field for x509 authentication (separator $)')|format('OU')
                     ) }}
                     {{ fields.textField(
                        'x509_cn_restrict',
                        config['x509_cn_restrict'],
                        __('Restrict %s field for x509 authentication (separator $)')|format('CN')
                     ) }}
                     {{ fields.textField(
                        'x509_o_restrict',
                        config['x509_o_restrict'],
                        __('Restrict %s field for x509 authentication (separator $)')|format('O')
                     ) }}

                     {{ fields.smallTitle(__('Other authentication sent in the HTTP request')) }}
                     {% if config['ssovariables_id'] is not empty and config['ssovariables_id'] != 0 %}
                        <div class="alert alert-info">{{ _x('authentication', 'Enabled') }}</div>
                     {% endif %}
                     {{ fields.dropdownField('SsoVariable', 'ssovariables_id', config['ssovariables_id'], 'SsoVariable'|itemtype_name(1)) }}
                     {{ fields.textField('ssologout_url', config['ssologout_url'], __('SSO logout url')) }}
                     {{ fields.dropdownYesNo(
                        'existing_auth_server_field_clean_domain',
                        config['existing_auth_server_field_clean_domain'],
                        __('Remove the domain of logins like login@domain')
                     ) }}
                     {{ fields.textField('realname_ssofield', config['realname_ssofield'], __('Surname')) }}
                     {{ fields.textField('firstname_ssofield', config['firstname_ssofield'], __('First name')) }}
                     {{ fields.textField('comment_ssofield', config['comment_ssofield'], __('Comments')) }}
                     {{ fields.textField(
                        'registration_number_ssofield',
                        config['registration_number_ssofield'],
                        _x('user', 'Administrative number')
                     ) }}
                     {{ fields.textField('email1_ssofield', config['email1_ssofield'], _n('Email', 'Emails', 1)) }}
                     {{ fields.textField(
                        'email2_ssofield',
                        config['email2_ssofield'],
                        __('%1$s %2$s')|format(_n('Email', 'Emails', 1), '2')
                     ) }}
                     {{ fields.textField(
                        'email3_ssofield',
                        config['email3_ssofield'],
                        __('%1$s %2$s')|format(_n('Email', 'Emails', 1), '3')
                     ) }}
                     {{ fields.textField(
                        'email4_ssofield',
                        config['email4_ssofield'],
                        __('%1$s %2$s')|format(_n('Email', 'Emails', 1), '4')
                     ) }}
                     {{ fields.textField('phone_ssofield', config['phone_ssofield'], 'Phone'|itemtype_name(1)) }}
                     {{ fields.textField(
                        'phone2_ssofield',
                        config['phone2_ssofield'],
                        __('%1$s %2$s')|format('Phone'|itemtype_name(1), '2')
                     ) }}
                     {{ fields.textField('mobile_ssofield', config['mobile_ssofield'], __('Mobile phone')) }}
                     {{ fields.textField('title_ssofield', config['title_ssofield'], _x('person', 'Title')) }}
                     {{ fields.textField('category_ssofield', config['category_ssofield'], _n('Category', 'Categories', 1)) }}
                     {{ fields.textField('language_ssofield', config['language_ssofield'], __('Language')) }}

                     <div class="right">
                        {{ inputs.hidden('_glpi_csrf_token', csrf_token()) }}
                        {{ inputs.submit('update', __('Save'), 1, {
                           icon: 'ti ti-device-floppy'
                        }) }}
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </form>
</div>
