pdf_search 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/web_server.rb +22 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44d5c7c69ebe317bcd1c609a1a93c33f2f180839f58e98180d984b1ab170cb1c
4
- data.tar.gz: 2d607c5f7e6ffeb8b8667821486855f657681fc3c8332aebd315c3d5da8dc686
3
+ metadata.gz: 3d33439a4266cb68c08fcf67484f09ecc7ac39228387a8e8b0a54758f1569c84
4
+ data.tar.gz: 84f39eb8a771abaf45d5b5d38a1342065ba562a664afa2b8e99dbab1f651624a
5
5
  SHA512:
6
- metadata.gz: 23bfdd1a6cf8da807f26e68aa48093d0afd610bf44aa580b4018c7a41de70da36a198746876287b5dcd1deb60d9aef9301b130b792ead9a77013db6d1bd24713
7
- data.tar.gz: c5e50bb4a3b7f4c54fd69ff249feddc484ca32b4060873dfd63967b21cf09374e0ab6af9329f60d1500a1199b74afdc0d0b6665c4169a4ea0192f013d8df37f5
6
+ metadata.gz: 84064889972907aa6c5a81ca08a88be0acf43de33ada6bf3d2dad8c44b90dc2e856554de64b9ab44ea29f62dce0e1e670c335a3f8f283de017460cf6702bf372
7
+ data.tar.gz: 3f0396b7533dfe0c8d48abd95a96cbafd9066fcffa937b8d4a71f2fab420f49d33a69ecef5004a6346effd94403ec1584588d660c0709b57cf2e1eeb434c8933
@@ -4,11 +4,33 @@ require 'json'
4
4
  class PdfSearch::WebServer
5
5
  attr_accessor :daemon
6
6
 
7
+ def basic_auth
8
+ return @basic_auth if @basic_auth != nil
9
+
10
+ config = { :Realm => 'BanalBI Pdf-Search' }
11
+
12
+ htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'banalbi-pdf-search'
13
+ htpasswd.set_passwd config[:Realm], ENV['PDF_SEARCH_USERNAME'] , ENV['PDF_SEARCH_PASSWORD']
14
+ htpasswd.flush
15
+
16
+ config[:UserDB] = htpasswd
17
+
18
+ puts config.inspect
19
+
20
+ @basic_auth = WEBrick::HTTPAuth::BasicAuth.new config
21
+ end
22
+
7
23
  def start
8
24
  start_server = lambda do
9
25
  server = WEBrick::HTTPServer.new(:Port => 80, :DocumentRoot => ::PdfSearch.relative_to_gem_path(['html']))
10
26
 
11
27
  server.mount_proc '/search' do |request, response|
28
+ if [ENV['PDF_SEARCH_USERNAME'], ENV['PDF_SEARCH_PASSWORD']].all? do |env_var|
29
+ env_var != nil && env_var != ''
30
+ end
31
+
32
+ basic_auth.authenticate(request, response)
33
+ end
12
34
  query = request.query["query"]
13
35
  elastic_response = ::PdfSearch::ElasticSearchClient.search q: "text:#{query}"
14
36
  response.body = response_html(elastic_response)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Arno Korfmann