rack-couchdb-oauth2 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem 'rack'
6
6
  gem 'couchrest'
7
- gem 'couchrest_model', :git => 'git://github.com/couchrest/couchrest_model.git'
7
+ gem 'couchrest_model', '>= 1.1.1'
8
8
  gem 'activesupport'
9
9
  gem 'rack-oauth2'
10
10
  gem 'bcrypt-ruby'
@@ -1,13 +1,3 @@
1
- GIT
2
- remote: git://github.com/couchrest/couchrest_model.git
3
- revision: dca47ac3b2b6fd5a4f3ee131083dde4a5cd2b8db
4
- specs:
5
- couchrest_model (1.1.0.rc1)
6
- activemodel (~> 3.0)
7
- couchrest (= 1.1.0.pre3)
8
- mime-types (~> 1.15)
9
- tzinfo (~> 0.3.22)
10
-
11
1
  GEM
12
2
  remote: http://rubygems.org/
13
3
  specs:
@@ -19,14 +9,19 @@ GEM
19
9
  attr_required (0.0.3)
20
10
  bcrypt-ruby (2.1.4)
21
11
  builder (2.1.2)
22
- couchrest (1.1.0.pre3)
12
+ couchrest (1.1.1)
23
13
  mime-types (~> 1.15)
24
14
  multi_json (~> 1.0.0)
25
15
  rest-client (~> 1.6.1)
16
+ couchrest_model (1.1.1)
17
+ activemodel (~> 3.0)
18
+ couchrest (= 1.1.1)
19
+ mime-types (~> 1.15)
20
+ tzinfo (~> 0.3.22)
26
21
  git (1.2.5)
27
22
  httpclient (2.2.1)
28
23
  i18n (0.5.0)
29
- jeweler (1.6.2)
24
+ jeweler (1.6.4)
30
25
  bundler (~> 1.0)
31
26
  git (>= 1.2.5)
32
27
  rake
@@ -34,7 +29,7 @@ GEM
34
29
  mime-types (1.16)
35
30
  multi_json (1.0.3)
36
31
  rack (1.3.0)
37
- rack-oauth2 (0.8.2)
32
+ rack-oauth2 (0.8.3)
38
33
  activesupport (>= 2.3)
39
34
  attr_required (>= 0.0.3)
40
35
  httpclient (>= 2.2.0.2)
@@ -47,7 +42,7 @@ GEM
47
42
  rcov (0.9.9)
48
43
  rest-client (1.6.3)
49
44
  mime-types (>= 1.16)
50
- tzinfo (0.3.28)
45
+ tzinfo (0.3.29)
51
46
 
52
47
  PLATFORMS
53
48
  ruby
@@ -57,7 +52,7 @@ DEPENDENCIES
57
52
  bcrypt-ruby
58
53
  bundler (~> 1.0.0)
59
54
  couchrest
60
- couchrest_model!
55
+ couchrest_model (>= 1.1.1)
61
56
  jeweler (~> 1.6.2)
62
57
  rack
63
58
  rack-oauth2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -6,6 +6,16 @@ class AccessToken < CouchRest::Model::Base
6
6
  belongs_to :refresh_token
7
7
  timestamps!
8
8
 
9
+ def self.find_by_env(env)
10
+ request = Rack::OAuth2::Server::Resource::Bearer::Request.new(env)
11
+ return nil unless request && request.oauth2?
12
+ request.setup!
13
+ token = self.find_by_token request.access_token
14
+ (token.nil? || token.expired?) ? nil : token
15
+ rescue
16
+ nil
17
+ end
18
+
9
19
  def to_bearer_token(with_refresh_token = false)
10
20
  bearer_token = Rack::OAuth2::AccessToken::Bearer.new(
11
21
  :access_token => self.token,
@@ -17,16 +17,7 @@ module Oauth2Token
17
17
 
18
18
  before_validation :setup, :on => :create
19
19
  validates :client, :expires_at, :account, :presence => true
20
- validates :token, :presence => true, :uniqueness => true
21
-
22
- def self.find_by_env(env)
23
- token = find_by_token(env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN])
24
- if token.nil? || token.expired?
25
- nil
26
- else
27
- token
28
- end
29
- end
20
+ validates :token, :presence => true, :uniqueness => true
30
21
 
31
22
  def self.valid
32
23
  view(:by_expires_at, :startkey => Time.now.utc)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-couchdb-oauth2}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Robin Lu"]
12
- s.date = %q{2011-06-27}
12
+ s.date = %q{2011-07-11}
13
13
  s.description = %q{Rack middleware for OAuth2 Provider Server Based on Couchdb}
14
14
  s.email = %q{iamawalrus@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
55
55
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
56
  s.add_runtime_dependency(%q<rack>, [">= 0"])
57
57
  s.add_runtime_dependency(%q<couchrest>, [">= 0"])
58
- s.add_runtime_dependency(%q<couchrest_model>, [">= 0"])
58
+ s.add_runtime_dependency(%q<couchrest_model>, [">= 1.1.1"])
59
59
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
60
60
  s.add_runtime_dependency(%q<rack-oauth2>, [">= 0"])
61
61
  s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 0"])
@@ -66,7 +66,7 @@ Gem::Specification.new do |s|
66
66
  else
67
67
  s.add_dependency(%q<rack>, [">= 0"])
68
68
  s.add_dependency(%q<couchrest>, [">= 0"])
69
- s.add_dependency(%q<couchrest_model>, [">= 0"])
69
+ s.add_dependency(%q<couchrest_model>, [">= 1.1.1"])
70
70
  s.add_dependency(%q<activesupport>, [">= 0"])
71
71
  s.add_dependency(%q<rack-oauth2>, [">= 0"])
72
72
  s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
@@ -78,7 +78,7 @@ Gem::Specification.new do |s|
78
78
  else
79
79
  s.add_dependency(%q<rack>, [">= 0"])
80
80
  s.add_dependency(%q<couchrest>, [">= 0"])
81
- s.add_dependency(%q<couchrest_model>, [">= 0"])
81
+ s.add_dependency(%q<couchrest_model>, [">= 1.1.1"])
82
82
  s.add_dependency(%q<activesupport>, [">= 0"])
83
83
  s.add_dependency(%q<rack-oauth2>, [">= 0"])
84
84
  s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
@@ -22,12 +22,9 @@ class TestToken < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  map '/db' do
25
- use Rack::OAuth2::Server::Resource::Bearer, 'test' do |req|
26
-
27
- end
28
25
  run proc {|env|
29
26
  token = AccessToken.find_by_env(env)
30
- raise 'no client' if token.nil?
27
+ raise 'no token' if token.nil?
31
28
  [200, {}, 'OK']
32
29
  }
33
30
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-couchdb-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robin Lu
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-27 00:00:00 +08:00
18
+ date: 2011-07-11 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -54,10 +54,12 @@ dependencies:
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- hash: 3
57
+ hash: 17
58
58
  segments:
59
- - 0
60
- version: "0"
59
+ - 1
60
+ - 1
61
+ - 1
62
+ version: 1.1.1
61
63
  name: couchrest_model
62
64
  version_requirements: *id003
63
65
  - !ruby/object:Gem::Dependency