Sha256: 5dc56017e2045eb4dbdbfa8064999d8628c9e85211408acbc472d582a8970e37

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true
libdir = File.expand_path(File.dirname(__FILE__) + '/lib')
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)

raise 'Unconfigured' unless ENV['ELASTICSEARCH_URL']

require 'proxes'
require 'proxes/omniauth'
use Rack::Session::Cookie,
    key: '_ProxES_session',
    #:secure=>!TEST_MODE, # Uncomment if only allowing https:// access
    secret: File.read('.session_secret')

use OmniAuth::Builder do
  # The identity provider is used by the App.
  provider :identity,
           fields: [:username],
           callback_path: '/_proxes/auth/identity/callback',
           model: ProxES::Identity,
           on_login: ProxES::AuthIdentity,
           on_registration: ProxES::AuthIdentity,
           locate_conditions: ->(req) { { username: req['username'] } }
end
OmniAuth.config.on_failure = ProxES::AuthIdentity

# Management App
map '/_proxes' do
  run Rack::URLMap.new ProxES::Container.routes
end

# Proxy all Elasticsearch requests
require 'proxes/security'
require 'proxes/forwarder'
map '/' do
  # Security
  use ProxES::Security, ProxES::Services::Logger.instance
  use Rack::ContentLength

  # Forward requests to ES
  run ProxES::Forwarder.new(backend: ENV['ELASTICSEARCH_URL'])
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxes-0.3.3 config.ru
proxes-0.3.2 config.ru