opf/openproject

View on GitHub
app/views/admin/settings/authentication_settings/show.html.erb

Summary

Maintainability
Test Coverage
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2024 the OpenProject GmbH

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See COPYRIGHT and LICENSE files for more details.

++#%>
<% html_title t(:label_administration), t(:label_authentication) -%>

<%= toolbar title: t(:label_authentication) %>

<%= styled_form_tag(admin_settings_authentication_path, method: :patch) do %>
  <section class="form--section">
    <fieldset class="form--fieldset">
      <legend class="form--fieldset-legend"><%= I18n.t(:general, scope: [:settings]) %></legend>
      <div class="form--field"><%= setting_check_box :login_required %></div>

      <div class="form--field"><%= setting_select :self_registration, [[t(:label_disabled), Setting::SelfRegistration.disabled.to_s],
                                                [t(:label_registration_activation_by_email), Setting::SelfRegistration.by_email.to_s],
                                                [t(:label_registration_manual_activation), Setting::SelfRegistration.manual.to_s],
                                                [t(:label_registration_automatic_activation), Setting::SelfRegistration.automatic.to_s]],
                                                container_class: '-middle' %>
      </div>

      <div class="form--field">
        <%= setting_check_box :email_login, title: I18n.t("tooltip.setting_email_login") %>
      </div>

      <%= render Settings::NumericSettingComponent.new("invitation_expiration_days", unit: "days") %>
    </fieldset>

    <fieldset class="form--fieldset">
      <fieldset id="registration_footer" class="form--fieldset">
        <legend class="form--fieldset-legend"><%= I18n.t(:setting_registration_footer) %></legend>
        <%= render Settings::TextSettingComponent.new(I18n.locale, name: "registration_footer") %>
      </fieldset>
    </fieldset>

    <fieldset class="form--fieldset">
      <legend class="form--fieldset-legend"><%= I18n.t(:passwords, scope: [:settings]) %></legend>
      <% if !OpenProject::Configuration.disable_password_login? %>
        <div class="form--field -wide-label"><%= setting_text_field :password_min_length, size: 6, container_class: '-xslim' %></div>
        <div class="form--field -wide-label">
          <% rules = OpenProject::Passwords::Evaluator.known_rules.map do |rule|
            [t("label_password_rule_#{rule}"), rule]
          end %>
          <%= setting_multiselect :password_active_rules, rules %>
        </div>
        <div class="form--field -wide-label"><%= setting_text_field :password_min_adhered_rules, size: 6, container_class: '-xslim' %></div>
        <div class="form--field -wide-label"><%= setting_text_field :password_days_valid, size: 6, container_class: '-xslim' %>
          <span class="form--field-instructions">
            <%= t(:text_hint_disable_with_0) %>
          </span>
        </div>
        <div class="form--field -wide-label"><%= setting_text_field :password_count_former_banned, size: 6, container_class: '-xslim' %></div>
        <div class="form--field -wide-label"><%= setting_check_box :lost_password, label: :label_password_lost %></div>
      <% else %>
        <div class="form--field -wide-label">
          <label><b><%= I18n.t :note %>: </b>
            <%=
              url = 'https://www.openproject.org/docs/installation-and-operations/configuration/#disable-password-login'

              explanation = I18n.t :note_password_login_disabled,
                                   configuration: "<a target=\"_blank\" href=\"#{url}\"> #{I18n.t('label_configuration')}</a>"

              explanation.html_safe
            %>
          </label>
        </div>
      <% end %>
    </fieldset>

    <% unless OpenProject::Configuration.disable_password_login? %>
      <fieldset class="form--fieldset">
        <legend class="form--fieldset-legend"><%= I18n.t(:brute_force_prevention, scope: [:settings]) %></legend>
        <div class="form--field -wide-label"><%= setting_text_field :brute_force_block_after_failed_logins, container_class: '-xslim' %>
          <span class="form--field-instructions">
            <%= t(:text_hint_disable_with_0) %>
          </span>
        </div>
        <div class="form--field -wide-label"><%= setting_text_field :brute_force_block_minutes, unit: t(:label_minute_plural), container_class: '-xslim' %></div>
      </fieldset>
    <% end %>

    <fieldset class="form--fieldset">
      <legend class="form--fieldset-legend"><%= I18n.t(:session, scope: [:settings]) %></legend>
      <div class="form--field -wide-label"><%= setting_select :autologin,
                 ([[t(:label_disabled), 0]] +
                   Settings::Definition[:autologin].allowed.collect do |days|
                    [t('datetime.distance_in_words.x_days', count: days),
                    days.to_s]
                  end),
                  container_class: '-xslim' %>
      </div>
      <div class="form--field -wide-label"><%= setting_check_box :session_ttl_enabled %></div>
      <div class="form--field -wide-label" id="settings_session_ttl_container" style="display:none;">
        <%= setting_text_field :session_ttl, unit: t(:label_minute_plural), container_class: '-xslim' %>
        <span class="form--field-instructions">
          <%= I18n.t('setting_session_ttl_hint') %>
        </span>
      </div>
    </fieldset>

    <fieldset class="form--fieldset">
      <legend class="form--fieldset-legend"><%= I18n.t(:other, scope: [:settings]) %></legend>
      <div class="form--field -wide-label"><%= setting_check_box :log_requesting_user %></div>
    </fieldset>
  </section>
  <% unless OpenProject::Configuration.disable_password_login? %>
    <div style="float:right;">
      <%= link_to t(:label_ldap_authentication), {controller: '/ldap_auth_sources', action: 'index'}, class: 'icon icon-server-key' %>
    </div>
  <% end %>
  <%= styled_button_tag t(:button_save), class: '-primary -with-icon icon-checkmark' %>
<% end %>