<commit_before>require 'actionwebservice'

class VmdbwsController < ApplicationController
  acts_as_web_service
  web_service_api VmdbwsApi
  before_filter :authenticate

  include VmdbwsOps

  protected

  def authenticate
    ws_security = get_vmdb_config.fetch_path(:webservices, :integrate, :security)
    # require client side cert, so let them through
    if request.headers["SERVER_PORT"] == "8443" || ws_security == 'none'
      @username = VmdbwsSupport::SYSTEM_USER
      return true
    end

    # Default to basic authentication
    # Block must return false to fail authentication
    authenticate_or_request_with_http_basic do |username, password|
      authenticated, @username = User.authenticate_with_http_basic(username, password, request)
      authenticated
    end
  end
end
<commit_msg>Updated REST and SOAP API's to support External Authentication.<commit_after>require 'actionwebservice'

class VmdbwsController < ApplicationController
  acts_as_web_service
  web_service_api VmdbwsApi
  before_filter :authenticate

  include VmdbwsOps

  protected

  def authenticate
    ws_security = get_vmdb_config.fetch_path(:webservices, :integrate, :security)
    # require client side cert, so let them through
    if request.headers["SERVER_PORT"] == "8443" || ws_security == 'none'
      @username = VmdbwsSupport::SYSTEM_USER
      return true
    end

    # Default to basic authentication
    # Block must return false to fail authentication
    authenticate_or_request_with_http_basic do |username, password|
      authenticate_options = {:require_user => true}

      timeout = get_vmdb_config.fetch_path(:webservices, :authentication_timeout)
      authenticate_options[:timeout] = timeout.to_i_with_method if timeout

      authenticated, @username = User.authenticate_with_http_basic(username, password, request, authenticate_options)
      authenticated
    end
  end
end

{'fraction_non_alphanumeric': 0.06368421052631579, 'fraction_numerical': 0.004210526315789474, 'mean_word_length': 4.510144927536232, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1202739', 'n_tokens_mistral': 574, 'n_tokens_neox': 533, 'n_words': 141}