strelka 0.0.1.pre.301 → 0.0.1.pre.303

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,46 @@
1
+ 2012-09-18 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * lib/strelka/authprovider/basic.rb,
4
+ spec/strelka/authprovider/basic_spec.rb:
5
+ Simplified Strelka::AuthProvider::Basic.
6
+
7
+ - removed the pbkdf2_hmac stuff for simplicity
8
+ - made it easier to use it as a base class for other auth providers.
9
+ [dbb4523ad258] [tip]
10
+
11
+ * Rakefile:
12
+ Update dependencies
13
+ [1962465c2c92]
14
+
15
+ 2012-09-05 Michael Granger <ged@FaerieMUD.org>
16
+
17
+ * lib/strelka/cookie.rb:
18
+ Pull up cookie value method into a protected method for overriding.
19
+
20
+ This was done to facilitate the creation of specialized cookie
21
+ classes.
22
+ [6f6203c7f0aa]
23
+
24
+ * README.rdoc:
25
+ Small README fixes
26
+ [0c7cd9948e64]
27
+
28
+ 2012-08-24 Michael Granger <ged@FaerieMUD.org>
29
+
30
+ * Deploying.rdoc, Manifest.txt, Plugins.rdoc, README.rdoc,
31
+ Tutorial.rdoc, manual/src/deploying.page, manual/src/plugins.page,
32
+ manual/src/tutorial.page:
33
+ Documentation update.
34
+
35
+ Got most of the default plugins covered at least minimally. Split
36
+ out the rest of the manual into RDoc pages.
37
+ [41ef7a20e7cb]
38
+
1
39
  2012-08-24 Mahlon E. Smith <mahlon@martini.nu>
2
40
 
3
41
  * examples/strelka.conf.example:
4
42
  Add a documented example configuration file.
5
- [9d8ce0e99016] [tip]
43
+ [9d8ce0e99016]
6
44
 
7
45
  2012-08-23 Mahlon E. Smith <mahlon@martini.nu>
8
46
 
@@ -19,7 +57,7 @@
19
57
  * lib/strelka/app/restresources.rb:
20
58
  Don't try to auto-create restresource routes for no-param datasets,
21
59
  either.
22
- [10af8924212c] [github/master]
60
+ [10af8924212c]
23
61
 
24
62
  2012-08-13 Michael Granger <ged@FaerieMUD.org>
25
63
 
@@ -1003,7 +1041,7 @@
1003
1041
 
1004
1042
  * lib/strelka/app/errors.rb, spec/strelka/app/errors_spec.rb:
1005
1043
  Add documentation for the Errors plugin, improve test coverage.
1006
- [ff3ef6e5a7a1] [github/master@default]
1044
+ [ff3ef6e5a7a1]
1007
1045
 
1008
1046
  * Manifest.txt:
1009
1047
  Add session files to the manifest
data/Rakefile CHANGED
@@ -30,8 +30,8 @@ hoespec = Hoe.spec 'strelka' do
30
30
  self.dependency 'loggability', '~> 0.4'
31
31
  self.dependency 'mongrel2', '~> 0.30'
32
32
  self.dependency 'pluginfactory', '~> 1.0'
33
- self.dependency 'sysexits', '~> 1.0'
34
- self.dependency 'trollop', '~> 1.16'
33
+ self.dependency 'sysexits', '~> 1.1'
34
+ self.dependency 'trollop', '~> 2.0'
35
35
  self.dependency 'uuidtools', '~> 2.1'
36
36
 
37
37
  self.dependency 'hoe-deveiate', '~> 0.1', :developer
@@ -14,7 +14,7 @@ require 'strelka/mixins'
14
14
  #
15
15
  # == Configuration
16
16
  #
17
- # The configuration for this provider is read from the 'auth' section of the config, and
17
+ # The configuration for this provider is read from the 'basicauth' section of the config, and
18
18
  # may contain the following keys:
19
19
  #
20
20
  # [realm]:: the HTTP Basic realm. Defaults to the app's application ID
@@ -33,6 +33,11 @@ require 'strelka/mixins'
33
33
  # jblack: "1pAnQNSVtpL1z88QwXV4sG8NMP8="
34
34
  # kmurgen: "MZj9+VhZ8C9+aJhmwp+kWBL76Vs="
35
35
  #
36
+ # == Caveats
37
+ #
38
+ # This auth provider is intended as documentation and demonstration only; you should use a
39
+ # more cryptographically secure strategy for real-world applications.
40
+ #
36
41
  class Strelka::AuthProvider::Basic < Strelka::AuthProvider
37
42
  extend Configurability,
38
43
  Strelka::MethodUtilities
@@ -47,13 +52,6 @@ class Strelka::AuthProvider::Basic < Strelka::AuthProvider
47
52
  users: {},
48
53
  }
49
54
 
50
- # The amount of work to do while encrypting -- higher number == more work == less suceptable
51
- # to brute-force attacks
52
- ENCRYPT_ITERATIONS = 20_000
53
-
54
- # The Digest class to use when encrypting passwords
55
- DIGEST_CLASS = OpenSSL::Digest::SHA256
56
-
57
55
 
58
56
  ##
59
57
  # The Hash of users and their SHA1+Base64'ed passwords
@@ -82,22 +80,6 @@ class Strelka::AuthProvider::Basic < Strelka::AuthProvider
82
80
  ### I N S T A N C E M E T H O D S
83
81
  #################################################################
84
82
 
85
- ### Create a new Default AuthProvider.
86
- def initialize( * )
87
- super
88
-
89
- # Default the authentication realm to the application's ID
90
- unless self.class.realm
91
- self.log.warn "No realm configured -- using the app id"
92
- self.class.realm = self.app.conn.app_id
93
- end
94
-
95
- unless self.class.users
96
- self.log.warn "No users configured -- using an empty user list"
97
- self.class.users = {}
98
- end
99
- end
100
-
101
83
 
102
84
  ######
103
85
  public
@@ -120,12 +102,7 @@ class Strelka::AuthProvider::Basic < Strelka::AuthProvider
120
102
 
121
103
  # Split the credentials, check for valid user
122
104
  username, password = credentials.split( ':', 2 )
123
- digest = self.class.users[ username ] or
124
- self.log_failure "No such user %p." % [ username ]
125
-
126
- # Fail if the password's hash doesn't match
127
- self.log_failure "Password mismatch." unless
128
- digest == Digest::SHA1.base64digest( password )
105
+ self.check_password( username, password )
129
106
 
130
107
  # Success!
131
108
  self.log.info "Authentication for %p succeeded." % [ username ]
@@ -137,26 +114,27 @@ class Strelka::AuthProvider::Basic < Strelka::AuthProvider
137
114
  protected
138
115
  #########
139
116
 
117
+ ### Return +true+ if the given +password+ is valid for the specified +username+. Always
118
+ ### returns false for non-existant users.
119
+ def check_password( username, password )
120
+ digest = self.class.users[ username ] or
121
+ self.log_failure "No such user %p." % [ username ]
122
+
123
+ # Fail if the password's hash doesn't match
124
+ self.log_failure "Password mismatch." unless
125
+ digest == Digest::SHA1.base64digest( password )
126
+
127
+ return true
128
+ end
129
+
130
+
140
131
  ### Syntax sugar to allow returning 'false' while logging a reason for doing so.
141
132
  ### Log a message at 'info' level and return false.
142
133
  def log_failure( reason )
143
134
  self.log.warn "Auth failure: %s" % [ reason ]
144
- header = "Basic realm=%s" % [ self.class.realm ]
135
+ header = "Basic realm=%s" % [ self.class.realm || self.app.conn.app_id ]
145
136
  finish_with( HTTP::AUTH_REQUIRED, "Requires authentication.", www_authenticate: header )
146
137
  end
147
138
 
148
139
 
149
- ### (undocumented)
150
- def encrypt( pass, salt=nil )
151
- salt ||= OpenSSL::Random.random_bytes( 16 ) #store this with the generated value
152
- iter = ENCRYPT_ITERATIONS
153
- digest = DIGEST_CLASS.new
154
- len = digest.digest_length
155
-
156
- value = OpenSSL::PKCS5.pbkdf2_hmac( pass, salt, iter, len, digest )
157
-
158
- return [ value, salt ].join( ':' )
159
- end
160
-
161
-
162
140
  end # class Strelka::AuthProvider::Basic
@@ -64,10 +64,6 @@ describe Strelka::AuthProvider::Basic do
64
64
  # Examples
65
65
  #
66
66
 
67
- it "uses the app ID as the basic auth realm if none is explicitly configured" do
68
- described_class.realm.should == @app.conn.app_id
69
- end
70
-
71
67
  it "can be configured via the Configurability API" do
72
68
  described_class.configure( @config )
73
69
  described_class.realm.should == @config[:realm]
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.301
4
+ version: 0.0.1.pre.303
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-09-05 00:00:00.000000000 Z
39
+ date: 2012-09-18 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: configurability
@@ -173,7 +173,7 @@ dependencies:
173
173
  requirements:
174
174
  - - ~>
175
175
  - !ruby/object:Gem::Version
176
- version: '1.0'
176
+ version: '1.1'
177
177
  type: :runtime
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
@@ -181,7 +181,7 @@ dependencies:
181
181
  requirements:
182
182
  - - ~>
183
183
  - !ruby/object:Gem::Version
184
- version: '1.0'
184
+ version: '1.1'
185
185
  - !ruby/object:Gem::Dependency
186
186
  name: trollop
187
187
  requirement: !ruby/object:Gem::Requirement
@@ -189,7 +189,7 @@ dependencies:
189
189
  requirements:
190
190
  - - ~>
191
191
  - !ruby/object:Gem::Version
192
- version: '1.16'
192
+ version: '2.0'
193
193
  type: :runtime
194
194
  prerelease: false
195
195
  version_requirements: !ruby/object:Gem::Requirement
@@ -197,7 +197,7 @@ dependencies:
197
197
  requirements:
198
198
  - - ~>
199
199
  - !ruby/object:Gem::Version
200
- version: '1.16'
200
+ version: '2.0'
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: uuidtools
203
203
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file