strelka 0.0.1.pre.254 → 0.0.1.pre.257

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,12 +1,50 @@
1
+ 2012-06-04 Mahlon E. Smith <mahlon@martini.nu>
2
+
3
+ * lib/strelka/app/auth.rb, lib/strelka/authprovider/hostaccess.rb,
4
+ spec/strelka/authprovider/hostaccess_spec.rb:
5
+ Fix required arguments for the hostaccess auth provider.
6
+ [4a20533a0551] [tip]
7
+
8
+ 2012-06-01 Michael Granger <ged@FaerieMUD.org>
9
+
10
+ * examples/Procfile, examples/config.yml,
11
+ examples/static/examples.html, lib/strelka/authprovider/basic.rb:
12
+ Applied fixes for the examples/.
13
+ [d52a6f2ddc3d]
14
+
15
+ 2012-06-01 Mahlon E. Smith <mahlon@martini.nu>
16
+
17
+ * lib/strelka/app/auth.rb, lib/strelka/session/db.rb,
18
+ lib/strelka/session/default.rb, spec/strelka/app/auth_spec.rb,
19
+ spec/strelka/session/db_spec.rb:
20
+ Allow the configured auth provider to work with inherited
21
+ subhandlers. Require connection string configuration for the DB
22
+ session class.
23
+ [c1bb99c6ba36]
24
+
1
25
  2012-05-31 Michael Granger <ged@FaerieMUD.org>
2
26
 
27
+ * lib/strelka/session/db.rb, lib/strelka/session/default.rb:
28
+ Move .configure method to the bottom of class methods to avoid
29
+ calling them before they're defined.
30
+ [b80079d190c2]
31
+
32
+ * lib/strelka.rb, lib/strelka/app.rb, lib/strelka/app/auth.rb,
33
+ lib/strelka/app/sessions.rb:
34
+ Load-order bugfixes for Configurability API.
35
+ [3c639d92e751]
36
+
37
+ * Manifest.txt:
38
+ Updating the manifest
39
+ [b4fcae2e5d2b]
40
+
3
41
  * .tm_properties, lib/strelka/app/auth.rb,
4
42
  lib/strelka/authprovider/basic.rb,
5
43
  lib/strelka/authprovider/hostaccess.rb,
6
44
  spec/strelka/app/auth_spec.rb,
7
45
  spec/strelka/authprovider/basic_spec.rb:
8
46
  Rewriting auth plugin to work app-agnostically
9
- [f569df3baa60] [tip]
47
+ [f569df3baa60]
10
48
 
11
49
  * lib/strelka/app/sessions.rb, lib/strelka/cookie.rb,
12
50
  lib/strelka/session/db.rb, lib/strelka/session/default.rb,
@@ -88,7 +126,7 @@
88
126
  * bin/strelka:
89
127
  Load the apps in bin/strelka before dumping the config so
90
128
  Configurability defaults for them show up
91
- [726ed30cb34e]
129
+ [726ed30cb34e] [github/master]
92
130
 
93
131
  * .rvm.gems, Rakefile:
94
132
  Add dependency on Foreman
@@ -700,7 +738,7 @@
700
738
 
701
739
  * lib/strelka/app/errors.rb, spec/strelka/app/errors_spec.rb:
702
740
  Add documentation for the Errors plugin, improve test coverage.
703
- [ff3ef6e5a7a1]
741
+ [ff3ef6e5a7a1] [github/master@default]
704
742
 
705
743
  * Manifest.txt:
706
744
  Add session files to the manifest
data/examples/Procfile CHANGED
@@ -1,8 +1,8 @@
1
1
  # Foreman procfile
2
2
  mongrel: m2sh.rb -c mongrel2.sqlite start
3
- helloworld: ../bin/strelka -l info -c config.yml start hello-world
4
- auth: ../bin/strelka -l info -c config.yml start auth-demo
5
- auth2: ../bin/strelka -l info -c config.yml start auth-demo2
6
- sessions: ../bin/strelka -l info -c config.yml start sessions-demo
3
+ helloworld: ../bin/strelka -D . -l warn -c config.yml start hello-world
4
+ auth: ../bin/strelka -D . -l warn -c config.yml start auth-demo
5
+ auth2: ../bin/strelka -D . -l warn -c config.yml start auth-demo2
6
+ sessions: ../bin/strelka -D . -l debug -c config.yml start sessions-demo
7
7
  # ws: ../bin/strelka -l info -c config.yml start ws-echo
8
8
 
data/examples/config.yml CHANGED
@@ -7,14 +7,17 @@ auth:
7
7
  basicauth:
8
8
  realm: Examples
9
9
  users:
10
- ged: "iEPX+SQWIR3p67lj/0zigSWTKHg="
10
+ ged: "dn44fsIrKF6KmBw0im4GIJktSpM="
11
11
  jblack: "1pAnQNSVtpL1z88QwXV4sG8NMP8="
12
12
  kmurgen: "MZj9+VhZ8C9+aJhmwp+kWBL76Vs="
13
13
 
14
14
  sessions:
15
15
  type: default
16
- options:
17
- cookie-name: "session-demo"
16
+
17
+ defaultsession:
18
+ cookie_name: "session-demo"
19
+ cookie_options:
20
+ expires: +5m
18
21
 
19
22
  templates:
20
23
  template_paths:
@@ -24,6 +24,7 @@
24
24
  <li><a href="/hello">Hello World</a> - A super-basic handler.</li>
25
25
  <li><a href="/sessions">Sessions Demo</a> - Demo of the <code>:sessions</code> plugin.</li>
26
26
  <li><a href="/auth">Auth Demo</a> - Demo of the <code>:auth</code> plugin.</li>
27
+ <li><a href="/formauth">Form Auth Demo</a> - Demo of the <code>:auth</code> plugin with the :errors plugin for auth failure management.</li>
27
28
  </ul>
28
29
 
29
30
  </body>
@@ -123,11 +123,12 @@ require 'strelka/authprovider'
123
123
  # Sometimes simple authentication isn't sufficient for accessing some
124
124
  # resources, especially if you have some kind of permissions system that
125
125
  # dictates who can see/use what. That's where the second stage of the
126
- # authentification process comes into play: Authorization.
126
+ # auth process comes into play: Authorization.
127
127
  #
128
- # The AuthProvider you're using may provide some form of general authorization
129
- # itself (especially a custom one), but typically authorization is particular to an application and
130
- # even particular actions within the application.
128
+ # The AuthProvider you're using may provide some form of general
129
+ # authorization itself (especially a custom one), but typically
130
+ # authorization is particular to an application and even particular
131
+ # actions within the application.
131
132
  #
132
133
  # To facilitate mapping out what actions are available to whom, there is a
133
134
  # declaration similar to require_auth_for that can define a set of permissions
@@ -257,10 +258,10 @@ module Strelka::App::Auth
257
258
  ### Configurability API -- configure the Auth plugin via the 'auth' section of the
258
259
  ### unified config.
259
260
  def self::configure( config=nil )
260
- if config && config.provider?
261
+ if config && config[:provider]
261
262
  self.log.debug "Setting up the %p AuthProvider for apps: %p" %
262
- [ config.provider, self.extended_apps ]
263
- self.extended_apps.each {|app| app.auth_provider = config.provider }
263
+ [ config[:provider], self.extended_apps ]
264
+ self.extended_apps.each {|app| app.auth_provider = config[:provider] }
264
265
  else
265
266
  self.log.warn "Setting up the default AuthProvider for apps %p" % [ self.extended_apps ]
266
267
  self.extended_apps.each {|app| app.auth_provider = DEFAULT_AUTH_PROVIDER }
@@ -306,6 +307,7 @@ module Strelka::App::Auth
306
307
  ### Extension callback -- add instance variables to extending objects.
307
308
  def inherited( subclass )
308
309
  super
310
+ Strelka::App::Auth.extended_apps << subclass
309
311
  subclass.instance_variable_set( :@auth_provider, @auth_provider )
310
312
  subclass.instance_variable_set( :@positive_auth_criteria, @positive_auth_criteria.dup )
311
313
  subclass.instance_variable_set( :@negative_auth_criteria, @negative_auth_criteria.dup )
@@ -24,6 +24,9 @@ require 'strelka/mixins'
24
24
  #
25
25
  # --
26
26
  # auth:
27
+ # provider: basic
28
+ #
29
+ # basicauth:
27
30
  # realm: Acme Admin Console
28
31
  # users:
29
32
  # mgranger: "9d5lIumnMJXmVT/34QrMuyj+p0E="
@@ -77,7 +77,7 @@ class Strelka::AuthProvider::HostAccess < Strelka::AuthProvider
77
77
 
78
78
  ### Check authorization for the specified +request+ by testing its the IP in its
79
79
  ### X-forwarded-for header against the allowed_netblocks.
80
- def authorize( _, request )
80
+ def authorize( _, request, _ )
81
81
  client_ip = request.header.x_forwarded_for or
82
82
  raise "No X-Forwarded-For header?!"
83
83
  addr = IPAddr.new( client_ip )
@@ -66,12 +66,12 @@ class Strelka::Session::Db < Strelka::Session::Default
66
66
  ### attribute to a Sequel dataset on the configured DB table.
67
67
  ###
68
68
  def self::initialize_sessions_table
69
- if self.db.table_exists?( self.table_name )
69
+ if self.db.table_exists?( self.table_name.to_sym )
70
70
  self.log.debug "Using existing sessions table for %p" % [ db ]
71
71
 
72
72
  else
73
73
  self.log.debug "Creating new sessions table for %p" % [ db ]
74
- self.db.create_table( self.table_name ) do
74
+ self.db.create_table( self.table_name.to_sym ) do
75
75
  text :session_id, :index => true
76
76
  text :session
77
77
  timestamp :created
@@ -134,19 +134,15 @@ class Strelka::Session::Db < Strelka::Session::Default
134
134
  def self::configure( options=nil )
135
135
  super
136
136
 
137
- if options
138
- self.table_name = options[:table_name]
139
- self.db = options[ :connect ].nil? ?
140
- Mongrel2::Config.in_memory_db :
141
- Sequel.connect( options[:connect] )
142
- else
143
- self.table_name = CONFIG_DEFAULTS[:table_name]
144
- self.db = Mongrel2::Config.in_memory_db
145
- end
137
+ if options && options[:connect]
138
+ self.log.warn "Configuring dbsession with: %p" % [ options ]
139
+ self.table_name = options[:table_name] || CONFIG_DEFAULTS[:table_name]
140
+ self.db = Sequel.connect( options[:connect] )
146
141
 
147
- self.db.logger = Loggability[ Mongrel2 ].proxy_for( self.db )
148
- self.db.sql_log_level = :debug
149
- self.initialize_sessions_table
142
+ self.db.logger = Loggability[ Mongrel2 ].proxy_for( self.db )
143
+ self.db.sql_log_level = :debug
144
+ self.initialize_sessions_table
145
+ end
150
146
  end
151
147
 
152
148
 
@@ -182,7 +182,7 @@ class Strelka::Session::Default < Strelka::Session
182
182
  session_cookie = Strelka::Cookie.new(
183
183
  self.class.cookie_name,
184
184
  self.session_id,
185
- self.class.cookie_options
185
+ self.class.cookie_options || {}
186
186
  )
187
187
 
188
188
  response.cookies << session_cookie
@@ -47,7 +47,6 @@ describe Strelka::App::Auth do
47
47
  app.auth_provider.should < Strelka::AuthProvider
48
48
  end
49
49
 
50
-
51
50
  it "adds the Auth mixin to the request class" do
52
51
  app = Class.new( Strelka::App ) do
53
52
  plugins :auth
@@ -116,6 +115,12 @@ describe Strelka::App::Auth do
116
115
  req.authenticated_user.should == 'anonymous'
117
116
  end
118
117
 
118
+ it "has its configured auth provider inherited by subclasses" do
119
+ Strelka::App::Auth.configure( :provider => 'basic' )
120
+ subclass = Class.new( @app )
121
+ subclass.auth_provider.should == Strelka::AuthProvider::Basic
122
+ end
123
+
119
124
  it "has its auth config inherited by subclasses" do
120
125
  subclass = Class.new( @app )
121
126
 
@@ -56,13 +56,13 @@ describe Strelka::AuthProvider::HostAccess do
56
56
 
57
57
  it "allows a request that originates from one of its allowed netblocks" do
58
58
  req = @request_factory.get( '/admin/console', :x_forwarded_for => '127.0.0.1' )
59
- @provider.authorize( nil, req ).should be_true()
59
+ @provider.authorize( nil, req, nil ).should be_true()
60
60
  end
61
61
 
62
62
 
63
63
  it "doesn't allow a request which is not from one of its allowed netblocks" do
64
64
  req = @request_factory.get( '/admin/console', :x_forwarded_for => '8.8.8.8' )
65
- @provider.authorize( nil, req ).should be_false()
65
+ @provider.authorize( nil, req, nil ).should be_false()
66
66
  end
67
67
 
68
68
 
@@ -31,20 +31,22 @@ describe Strelka::Session::Db do
31
31
  :hurrrg => true
32
32
  }
33
33
  }
34
+ @default_config = {
35
+ cookie_name: 'chunkers',
36
+ connect: {
37
+ adapter: Mongrel2::Config.sqlite_adapter
38
+ }
39
+ }
34
40
  end
35
41
 
36
42
  before( :each ) do
37
- Strelka.log.debug "BEFORE each"
43
+ described_class.configure( @default_config )
38
44
  @cookie_name = described_class.cookie_name
39
- described_class.configure
40
- Strelka.log.debug "/BEFORE each"
41
45
  end
42
46
 
43
47
  after( :each ) do
44
- Strelka.log.debug "AFTER each"
45
48
  described_class.db.drop_table( :sessions ) if
46
49
  described_class.db.table_exists?( :sessions )
47
- Strelka.log.debug "/AFTER each"
48
50
  end
49
51
 
50
52
  after( :all ) do
@@ -58,7 +60,7 @@ describe Strelka::Session::Db do
58
60
 
59
61
 
60
62
  it "can change the default table name" do
61
- described_class.configure( :table_name => :brothy )
63
+ described_class.configure( @default_config.merge(:table_name => :brothy) )
62
64
  described_class.db.table_exists?( :brothy ).should be_true()
63
65
  described_class.db.drop_table( :brothy )
64
66
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strelka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.254
4
+ version: 0.0.1.pre.257
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-05-31 00:00:00.000000000 Z
39
+ date: 2012-06-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: trollop
metadata.gz.sig CHANGED
Binary file