ManageIQ/manageiq-ui-classic

View on GitHub
app/views/ops/_settings_authentication_tab.html.haml

Summary

Maintainability
Test Coverage
- if @sb[:active_tab] == "settings_authentication"
  - url = url_for_only_path(:action => 'settings_form_field_changed', :id => @sb[:active_tab].split('_').last)
  %h3
    = _("Authentication")
  .form-horizontal
    .form-group
      %label.col-md-2.control-label
        = _("Session Timeout")
      .col-md-8
        = select_tag('session_timeout_hours',
                      options_for_select(Array.new(25) { |i| i }, @edit[:new][:session][:timeout] / 3600),
                      :class    => "selectpicker selectWidth",
                      "data-miq_observe" => {:url => url}.to_json)
        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent('session_timeout_hours', "#{url}")
        %span h
        = select_tag('session_timeout_mins', options_for_select(Array.new(12) { |i| i * 5 }, @edit[:new][:session][:timeout] % 3600 / 60),
                      :class    => "selectpicker selectWidth",
                      "data-miq_observe" => {:url => url}.to_json)
        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent('session_timeout_mins', "#{url}")
        %span m
    .form-group
      %label.col-md-2.control-label{"for" => "authentication_mode"}
        = _("Mode")
      .col-md-8
        = select_tag('authentication_mode',
                      options_for_select([[_("Database"), "database"], [_("Amazon"), "amazon"], [_("External (httpd)"), "httpd"]],
                      @edit[:new][:authentication][:mode]),
                      :class    => "selectpicker")
        :javascript
          miqInitSelectPicker();
          miqSelectPickerEvent('authentication_mode', "#{url}")
    %hr
  = hidden_div_if(@edit[:new][:authentication][:mode] != "amazon", :id => "amazon_div") do
    %h3= _("Amazon Primary AWS Account Settings for IAM")
    .form-horizontal
      .form-group
        %label.col-md-2.control-label{"for" => "authentication_amazon_key"}
          = _("Access Key")
        .col-md-8
          = text_field_tag("authentication_amazon_key",
                            @edit[:new][:authentication][:amazon_key],
                            :maxlength => 50,
                            :class => "form-control",
                            "data-miq_observe" => {:interval => '.5', :url => url}.to_json)
      .form-group
        %label.col-md-2.control-label{"for" => "authentication_amazon_secret"}
          = _("Secret Key")
        .col-md-8
          = password_field_tag("authentication_amazon_secret", '',
                                :maxlength         => 50,
                                :placeholder       => placeholder_if_present(@edit[:new][:authentication][:amazon_secret]),
                                :class => "form-control",
                                "data-miq_observe" => {:interval => '.5', :url => url}.to_json)
    %hr

  = hidden_div_if(@edit[:new][:authentication][:mode] != "amazon", :id => "amazon_role_div") do
    %h3
      = _("Role Settings")
    .form-horizontal
      .form-group
        %label.col-md-2.control-label{"for" => "amazon_role"}
          = _("Get User Groups from Amazon")
        .col-md-8
          = check_box_tag("amazon_role", "1",
                          @edit[:new][:authentication][:amazon_role],
                          "data-miq_observe_checkbox" => {:url => url}.to_json)
      .form-group
        .col-md-10{:align => "right"}
          = render :partial => 'amazon_verify_button', :locals => {:id => @sb[:active_tab].split('_').last}
    %hr

  = hidden_div_if(@edit[:new][:authentication][:mode] != "httpd", :id => "httpd_div") do
    %h3
      = _("External Authentication (httpd) Settings")
    .form-horizontal
      .form-group
        %label.col-md-2.control-label{"for" => "sso_enabled"}
          = _("Enable Single Sign-On")
        .col-md-8
          = check_box_tag("sso_enabled", "1",
                          @edit[:new][:authentication][:sso_enabled],
                          "data-miq_observe_checkbox" => {:url => url}.to_json)
    .form-horizontal
      .form-group
        %label.control-label.col-md-2
          = _("Provider Type:")
        .col-md-8
          %label
            %input{:type              => 'radio',
                   :name              => 'provider_type',
                   :id                => 'provider_type_none',
                   :value             => 'none',
                   "data-miq_observe" => {:url => url}.to_json,
                   :checked           => @edit[:new][:authentication][:provider_type] == "none"}
            = _("None")
          %br
          %label
            %input{:type              => 'radio',
                   :name              => 'provider_type',
                   :id                => 'provider_type_saml',
                   :value             => 'saml',
                   "data-miq_observe" => {:url => url}.to_json,
                   :checked           => @edit[:new][:authentication][:provider_type] == "saml"}
            = _("Enable SAML")
          %br
          %label
            %input{:type              => 'radio',
                   :name              => 'provider_type',
                   :id                => 'provider_type_oidc',
                   :value             => 'oidc',
                   "data-miq_observe" => {:url => url}.to_json,
                   :checked           => @edit[:new][:authentication][:provider_type] == "oidc"}
            = _("Enable OpenID-Connect")

      = hidden_div_if(@edit[:new][:authentication][:provider_type] == "none", :id => "none_local_login_div") do
        .form-group
          %label.col-md-2.control-label{"for" => "local_login_disabled"}
            = _("Disable Local Login")
          .col-md-4
            = check_box_tag("local_login_disabled", "1",
                            @edit[:new][:authentication][:local_login_disabled],
                            "data-miq_observe_checkbox" => {:url => url}.to_json)
    %hr

  = hidden_div_if(@edit[:new][:authentication][:mode] != "httpd", :id => "httpd_role_div") do
    %h3
      = _("Role Settings")
    .form-horizontal
      .form-group
        %label.col-md-2.control-label{"for" => "httpd_role"}
          = _("Get User Groups from External Authentication (httpd)")
        .col-md-8
          = check_box_tag("httpd_role", "1",
                          @edit[:new][:authentication][:httpd_role],
                          "data-miq_observe_checkbox" => {:url => url}.to_json)
    %hr
  %script{:type => "text/javascript"}
    - if @edit[:new][:authentication][:user_type] == "samaccountname"
      if (miqDomElementExists('user_type_base')) $('#user_type_base').hide();
    - else
      if (miqDomElementExists('user_type_samaccountname')) $('#user_type_samaccountname').hide();