geminabox-secure 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  # Gem in a Box Secure
2
2
 
3
- ![screen shot](http://i50.tinypic.com/2yknxnr.png)
3
+ ![screen shot](http://i.imgur.com/FS9lw.png)
4
4
 
5
5
  ## Really simple secure rubygem hosting
6
6
 
7
- Gem in a Box secure is a very basic branch of the awesome [Gem in a box][geminabox] - a simple [sinatra][sinatra] app to allow you to host your own in-house gems. The main difference here is the secure flavor provides forced SSL and HTTP basic auth.
7
+ Gem in a Box Secure is a very basic branch of the awesome [Gem in a box][geminabox] - a simple [sinatra][sinatra] app to allow you to host your own in-house gems. The main difference here is the secure flavor provides configurable forced SSL and HTTP basic auth.
8
8
 
9
9
  ## Server Setup
10
10
 
@@ -16,11 +16,12 @@ Create a config.ru as follows:
16
16
  require "geminabox-secure"
17
17
 
18
18
  GeminaboxSecure.data = "/var/geminabox-data" # …or wherever
19
+ GeminaboxSecure.force_ssl = true #if you want SSL redirects enabled
19
20
  run GeminaboxSecure
20
21
 
21
- Set environment variables for your username and password: GEMBOX_USER and GEMBOX_PASSWORD, respectively.
22
+ Set environment variables for your username and password: GEMBOX_USER and GEMBOX_PASSWORD, respectively. Gem in a Box Secure defaults to "admin" and "s3cret" respectively if these are not set.
22
23
 
23
- Set up your SSL certificates.
24
+ Set up your SSL certificates for your server of choice.
24
25
 
25
26
  And finally, hook up the config.ru as you normally would ([passenger][passenger], [thin][thin], [unicorn][unicorn], whatever floats your boat).
26
27
 
@@ -17,10 +17,20 @@ class GeminaboxSecure < Sinatra::Base
17
17
  set :data, File.join(File.dirname(__FILE__), *%w[.. data])
18
18
  set :views, File.join(File.dirname(__FILE__), *%w[.. views])
19
19
  set :allow_replace, false
20
+ set :force_ssl, false
21
+
20
22
  use Hostess
21
- use Rack::SslEnforcer
23
+
24
+ #defaults for SSL and basic HTTP Auth
25
+ if settings.force_ssl
26
+ use Rack::SslEnforcer
27
+ end
28
+ sec_user = ENV['GEMBOX_USER'].nil? ? 'admin' : ENV['GEMBOX_USER']
29
+ sec_pw = ENV['GEMBOX_PASSWORD'].nil? ? 's3cret' : ENV['GEMBOX_PASSWORD']
30
+
31
+ #setup HTTP Auth
22
32
  use Rack::Auth::Basic, "Restricted Area" do |username, password|
23
- [username, password] == [ENV['GEMBOX_USER'],ENV['GEMBOX_PASSWORD']]
33
+ [username, password] == [sec_user,sec_pw]
24
34
  end
25
35
 
26
36
  class << self
@@ -61,9 +71,9 @@ class GeminaboxSecure < Sinatra::Base
61
71
 
62
72
  tmpfile.binmode
63
73
 
64
- Dir.mkdir(File.join(options.data, "gems")) unless File.directory? File.join(options.data, "gems")
74
+ Dir.mkdir(File.join(settings.data, "gems")) unless File.directory? File.join(settings.data, "gems")
65
75
 
66
- dest_filename = File.join(options.data, "gems", File.basename(name))
76
+ dest_filename = File.join(settings.data, "gems", File.basename(name))
67
77
 
68
78
 
69
79
  if GeminaboxSecure.disallow_replace? and File.exist?(dest_filename)
@@ -102,16 +112,16 @@ HTML
102
112
  end
103
113
 
104
114
  def reindex
105
- Gem::Indexer.new(options.data).generate_index
115
+ Gem::Indexer.new(settings.data).generate_index
106
116
  end
107
117
 
108
118
  def file_path
109
- File.expand_path(File.join(options.data, *request.path_info))
119
+ File.expand_path(File.join(settings.data, *request.path_info))
110
120
  end
111
121
 
112
122
  def load_gems
113
123
  %w(specs prerelease_specs).inject(GemVersionCollection.new){|gems, specs_file_type|
114
- specs_file_path = File.join(options.data, "#{specs_file_type}.#{Gem.marshal_version}.gz")
124
+ specs_file_path = File.join(settings.data, "#{specs_file_type}.#{Gem.marshal_version}.gz")
115
125
  if File.exists?(specs_file_path)
116
126
  gems + Marshal.load(Gem.gunzip(Gem.read_binary(specs_file_path)))
117
127
  else
@@ -126,7 +136,7 @@ HTML
126
136
 
127
137
  helpers do
128
138
  def spec_for(gem_name, version)
129
- spec_file = File.join(options.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
139
+ spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
130
140
  Marshal.load(Gem.inflate(File.read(spec_file))) if File.exists? spec_file
131
141
  end
132
142
 
@@ -2,7 +2,7 @@ require 'sinatra/base'
2
2
 
3
3
  class Hostess < Sinatra::Base
4
4
  def serve
5
- send_file(File.expand_path(File.join(Geminabox.data, *request.path_info)), :type => response['Content-Type'])
5
+ send_file(File.expand_path(File.join(GeminaboxSecure.data, *request.path_info)), :type => response['Content-Type'])
6
6
  end
7
7
 
8
8
  %w[/specs.4.8.gz
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geminabox-secure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &2153239700 !ruby/object:Gem::Requirement
16
+ requirement: &2164731940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153239700
24
+ version_requirements: *2164731940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: builder
27
- requirement: &2153238920 !ruby/object:Gem::Requirement
27
+ requirement: &2164729960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: '2.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153238920
35
+ version_requirements: *2164729960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack-ssl-enforcer
38
- requirement: &2153237920 !ruby/object:Gem::Requirement
38
+ requirement: &2164728620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153237920
46
+ version_requirements: *2164728620
47
47
  description: Gem in a box with basic HTTP authentication and forced SSL, designed
48
48
  for use on Heroku or other cloud-based hosting services
49
49
  email: judd+contrib@euclidelements.com