Sha256: 837bdfc0d8bc350420109b93eb6648e0117a998d9f8598704c64a0f70e0b0bcc

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

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

require 'dotenv/load'

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

# Rack Protection
require 'rack/protection'
use Rack::Protection::RemoteToken
use Rack::Protection::SessionHijacking

map '/_proxes' do
  require 'ditty/components/app'
  Ditty.component :app

  require 'ditty/controllers/application'
  Ditty::Application.set :map_path, '/_proxes'

  require 'omniauth'
  require 'omniauth/identity'
  OmniAuth.config.logger = Ditty::Services::Logger.instance
  OmniAuth.config.on_failure = proc { |env|
    OmniAuth::FailureEndpoint.new(env).redirect_to_failure
  }

  require 'ditty/controllers/main'
  require 'ditty/models/identity'
  use OmniAuth::Builder do
    # The identity provider is used by the App.
    provider :identity,
             fields: [:username],
             callback_path: '/auth/identity/callback',
             model: Ditty::Identity,
             on_login: Ditty::Main,
             on_registration: Ditty::Main,
             locate_conditions: ->(req) { { username: req['username'] } }
  end

  # Management App
  require 'proxes'
  Ditty.component :proxes

  run Rack::URLMap.new Ditty::Components.routes
end

require 'sidekiq/web'
map '/_sidekiq' do
  run Sidekiq::Web
end

map '/' do
  # Proxy all Elasticsearch requests
  require 'proxes/security'
  require 'proxes/forwarder'

  # Security
  use ProxES::Security, Ditty::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.8.6 config.ru
proxes-0.8.5 config.ru