devise_oauth2_providable 0.3.7 → 0.3.8

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/README.md CHANGED
@@ -38,7 +38,8 @@ class User
38
38
  # if supporting Resource Owner Password Credentials Grant Type
39
39
  devise :oauth2_providable,
40
40
  :oauth2_password_grantable,
41
- :oauth2_refresh_token_grantable
41
+ :oauth2_refresh_token_grantable,
42
+ :oauth2_authorization_code_grantable
42
43
  end
43
44
  ```
44
45
 
@@ -35,12 +35,13 @@ class Oauth2::AuthorizationsController < ApplicationController
35
35
  if params[:approve].present?
36
36
  case req.response_type
37
37
  when :code
38
- authorization_code = current_user.authorization_codes.create(:client_id => @client, :redirect_uri => @redirect_uri)
38
+ authorization_code = current_user.authorization_codes.create(:client => @client, :redirect_uri => @redirect_uri)
39
39
  res.code = authorization_code.token
40
40
  when :token
41
- access_token = current_user.access_tokens.create(:client_id => @client).token
41
+ access_token = current_user.access_tokens.create(:client => @client).token
42
42
  bearer_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => access_token)
43
43
  res.access_token = bearer_token
44
+ res.uid = current_user.id
44
45
  end
45
46
  res.approve!
46
47
  else
data/app/models/client.rb CHANGED
@@ -4,9 +4,12 @@ class Client < ActiveRecord::Base
4
4
 
5
5
  before_validation :init_identifier, :on => :create, :unless => :identifier?
6
6
  before_validation :init_secret, :on => :create, :unless => :secret?
7
- validates :name, :website, :redirect_uri, :secret, :presence => true
7
+ validates :website, :redirect_uri, :secret, :presence => true
8
+ validates :name, :presence => true, :uniqueness => true
8
9
  validates :identifier, :presence => true, :uniqueness => true
9
10
 
11
+ attr_accessible :name, :website, :redirect_uri
12
+
10
13
  private
11
14
 
12
15
  def init_identifier
data/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  Rails.application.routes.draw do
2
2
  scope '/oauth2', :as => 'oauth2' do
3
3
  resources :authorizations, :controller => 'oauth2/authorizations', :only => :create
4
- resource :token, :controller => 'oauth2/tokens', :only => :create
5
4
  match 'authorize' => 'oauth2/authorizations#new'
5
+ resource :token, :controller => 'oauth2/tokens', :only => :create
6
6
  end
7
7
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_runtime_dependency(%q<rails>, [">= 3.0.7"])
18
18
  s.add_runtime_dependency(%q<devise>, [">= 1.3.3"])
19
- s.add_runtime_dependency(%q<rack-oauth2>, ["~> 0.8.2"])
19
+ s.add_runtime_dependency(%q<rack-oauth2>, ["~> 0.11.0"])
20
20
  s.add_development_dependency(%q<rspec>, ['>= 2.5.0'])
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Oauth2Providable
3
- VERSION = "0.3.7"
3
+ VERSION = "0.3.8"
4
4
  end
5
5
  end
@@ -15,7 +15,7 @@ module Devise
15
15
  module Oauth2Providable
16
16
  class << self
17
17
  def random_id
18
- ActiveSupport::SecureRandom.hex
18
+ SecureRandom.hex
19
19
  end
20
20
  end
21
21
  end
@@ -4,10 +4,16 @@ describe Client do
4
4
  describe 'basic client instance' do
5
5
  subject { Client.create! :name => 'test', :redirect_uri => 'http://localhost:3000', :website => 'http://localhost' }
6
6
  it { should validate_presence_of :name }
7
+ it { should validate_uniqueness_of :name }
8
+ it { should allow_mass_assignment_of :name }
7
9
  it { should validate_presence_of :website }
10
+ it { should allow_mass_assignment_of :website }
8
11
  it { should validate_presence_of :redirect_uri }
12
+ it { should allow_mass_assignment_of :redirect_uri }
9
13
  it { should validate_uniqueness_of :identifier }
10
- it { should have_many :refresh_tokens }
11
14
  it { should have_db_index(:identifier).unique(true) }
15
+ it { should_not allow_mass_assignment_of :identifier }
16
+ it { should_not allow_mass_assignment_of :secret }
17
+ it { should have_many :refresh_tokens }
12
18
  end
13
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_oauth2_providable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 7
10
- version: 0.3.7
9
+ - 8
10
+ version: 0.3.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Sonnek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-21 00:00:00 Z
18
+ date: 2011-10-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -57,12 +57,12 @@ dependencies:
57
57
  requirements:
58
58
  - - ~>
59
59
  - !ruby/object:Gem::Version
60
- hash: 59
60
+ hash: 51
61
61
  segments:
62
62
  - 0
63
- - 8
64
- - 2
65
- version: 0.8.2
63
+ - 11
64
+ - 0
65
+ version: 0.11.0
66
66
  type: :runtime
67
67
  version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency