Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: robin/rack-couchdb-oauth2
base: eedf0a7407
...
head fork: robin/rack-couchdb-oauth2
compare: 69c68b37cc
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 04, 2012
@nilclass nilclass ActiveSupport doesn't bring SecureRandom anymore. Ruby 1.9 does. 0be23d3
Commits on Mar 05, 2012
@robin Merge pull request #1 from nilclass/master
handle deprecation of ActiveSupport::SecureRandom
69c68b3
View
4 lib/couchdb_oauth2/model/client.rb
@@ -14,7 +14,7 @@ class Client < CouchRest::Model::Base
def setup
if self.secret.nil?
- self.secret = ActiveSupport::SecureRandom.base64(64)
+ self.secret = SecureRandom.base64(64)
end
end
@@ -27,4 +27,4 @@ def self.find_by_env(env)
client = Client.find(request.client_id)
client if client && client.secret == request.client_secret
end
-end
+end
View
4 lib/couchdb_oauth2/model/oauth2_token.rb
@@ -47,11 +47,11 @@ def expired?
private
def self.generate(bytes = 64)
- ActiveSupport::SecureRandom.base64(bytes)
+ SecureRandom.base64(bytes)
end
def setup
self.token = Oauth2Token.generate
self.expires_at ||= self.default_lifetime.from_now
end
-end
+end
View
16 lib/rack-couchdb-oauth2.rb
@@ -3,6 +3,22 @@
require 'couchrest_model'
require 'active_support'
+if defined? ActiveSupport::SecureRandom and not defined? SecureRandom
+ # pre 3.2 activesupport version + ruby 1.8
+ SecureRandom = ActiveSupport::SecureRandom
+elsif not defined? SecureRandom
+ if RUBY_VERSION > '1.9'
+ # ruby 1.9 brings securerandom
+ require 'securerandom'
+ else
+ begin
+ require 'securerandom'
+ rescue LoadError
+ raise LoadError, "SecureRandom not found! Use ruby 1.9, downgrade activesupport below 3.2 or install webget-securerandom gem"
+ end
+ end
+end
+
module Rack
module CouchdbOAuth2
autoload :Configuration, 'couchdb_oauth2/configuration'

No commit comments for this range

Something went wrong with that request. Please try again.