brycesch-devise_oauth2_providable 1.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89087ce6dfc7e93ca6f2dd4188c32ddb3b088c75
4
- data.tar.gz: 21f7d31bfc441e0eb30ad55fec67f7c952a3448c
3
+ metadata.gz: 09dbe4d5fdfe303bf1b13d2e683ccd6abd30419c
4
+ data.tar.gz: 74ff05e0eb6663d40484e121e573e90b9ddda358
5
5
  SHA512:
6
- metadata.gz: 970b338d028b599b04666f7818febca2b0e7ed1feefc7bf165f2a2bf6eb6fe43d0607b1a095cec6fe3c2c2ca4aea27a6e5a0bb5957ca1a4a5d52c9ab26c0eb12
7
- data.tar.gz: c2975a80ad4c94df699f70957dc7d5172a5e88623a739a43b91dec70af7941ca577b83f04d038121bf5b0962c044b4850b5f6c5009a3ac425c72d1983d64662a
6
+ metadata.gz: e6cf5f68adf86cd7bbd8c986738554c31bc729fe6f4cff39f535cabcd9cc3b16d487503ceda1ec6ec443ee2b33b8679bf2e1f9ae5a3105fd49e3767912dd9d89
7
+ data.tar.gz: c97a6bacf12d426766462f4cbe1ac479615bb597404ed3fd3b4a02e78aa975fbff25b83df3772b02fce63e6e8066c8266b4d23993aca05cef087a8a5d85da37e
@@ -10,12 +10,14 @@ class Devise::Oauth2Providable::TokensController < ApplicationController
10
10
  def create
11
11
  @refresh_token = oauth2_current_refresh_token || oauth2_current_client.refresh_tokens.create!(:user => current_user)
12
12
  @access_token = @refresh_token.access_tokens.create!(:client => oauth2_current_client, :user => current_user)
13
+ yield if block_given?
13
14
  render :json => @access_token.token_response
14
15
  end
15
16
 
16
17
  def destroy
17
18
  raise Rack::OAuth2::Server::Authorize::BadRequest unless current_user && oauth2_current_client
18
19
  oauth2_current_client.expire_tokens_for_user(current_user)
20
+ yield if block_given?
19
21
  head :no_content
20
22
  end
21
23
 
@@ -0,0 +1,6 @@
1
+ en:
2
+ devise:
3
+ failure:
4
+ invalid_client: "Invalid client credentials."
5
+ invalid_refresh_token: "Invalid refresh token."
6
+ invalid_auth_code: "Invalid authorization code."
@@ -11,7 +11,7 @@ module Devise
11
11
  if code = client.authorization_codes.find_by_token(params[:code])
12
12
  success! code.user
13
13
  else
14
- oauth_error! :invalid_grant, 'invalid authorization code request'
14
+ oauth_error! :invalid_grant, I18n.t('devise.failure.invalid_auth_code')
15
15
  end
16
16
  end
17
17
  end
@@ -27,14 +27,13 @@ module Devise
27
27
  env[Devise::Oauth2Providable::CLIENT_ENV_REF] = client
28
28
  authenticate_grant_type(client)
29
29
  else
30
- oauth_error! :invalid_client, 'invalid client credentials'
30
+ oauth_error! :invalid_client
31
31
  end
32
32
  end
33
33
 
34
- # return custom error response in accordance with the oauth spec
35
- # see http://tools.ietf.org/html/draft-ietf-oauth-v2-16#section-4.3
36
34
  def oauth_error!(error_code = :invalid_request, description = nil)
37
35
  body = {:error => error_code}
36
+ description = I18n.t("devise.failure.#{error_code}") unless description
38
37
  body[:error_description] = description if description
39
38
  custom! [400, {'Content-Type' => 'application/json'}, [body.to_json]]
40
39
  throw :warden
@@ -12,7 +12,7 @@ module Devise
12
12
  if validate(resource) { resource.valid_password?(params[:password]) }
13
13
  success! resource
14
14
  else
15
- oauth_error! :invalid_grant, 'invalid password authentication request'
15
+ oauth_error! :invalid_grant, I18n.t("devise.failure.#{resource.unauthenticated_message}")
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module Devise
12
12
  env[Devise::Oauth2Providable::REFRESH_TOKEN_ENV_REF] = refresh_token
13
13
  success! refresh_token.user
14
14
  else
15
- oauth_error! :invalid_grant, 'invalid refresh token'
15
+ oauth_error! :invalid_grant, I18n.t("devise.failure.invalid_refresh_token")
16
16
  end
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Oauth2Providable
3
- VERSION = "1.1.7"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -30,10 +30,10 @@ end
30
30
  Devise.add_module(:oauth2_providable,
31
31
  :strategy => true,
32
32
  :model => 'devise/oauth2_providable/models/oauth2_providable')
33
- Devise.add_module(:oauth2_password_grantable,
33
+ Devise.add_module(:oauth2_password_grantable,
34
34
  :strategy => true,
35
35
  :model => 'devise/oauth2_providable/models/oauth2_password_grantable')
36
- Devise.add_module(:oauth2_refresh_token_grantable,
36
+ Devise.add_module(:oauth2_refresh_token_grantable,
37
37
  :strategy => true,
38
38
  :model => 'devise/oauth2_providable/models/oauth2_refresh_token_grantable')
39
39
  Devise.add_module(:oauth2_authorization_code_grantable,
@@ -1,7 +1,6 @@
1
1
  class ProtectedController < ApplicationController
2
2
  before_filter :authenticate_user!
3
3
  def index
4
- # binding.pry
5
4
  render :nothing => true, :status => :ok
6
5
  end
7
6
  end
@@ -54,7 +54,7 @@ describe Devise::Strategies::Oauth2AuthorizationCodeGrantTypeStrategy do
54
54
  it 'returns json' do
55
55
  expected = {
56
56
  :error => 'invalid_grant',
57
- :error_description => 'invalid authorization code request'
57
+ :error_description => 'Invalid authorization code.'
58
58
  }
59
59
  response.body.should match_json(expected)
60
60
  end
@@ -78,7 +78,7 @@ describe Devise::Strategies::Oauth2AuthorizationCodeGrantTypeStrategy do
78
78
  it 'returns json' do
79
79
  expected = {
80
80
  :error => 'invalid_grant',
81
- :error_description => 'invalid authorization code request'
81
+ :error_description => 'Invalid authorization code.'
82
82
  }
83
83
  response.body.should match_json(expected)
84
84
  end
@@ -102,7 +102,7 @@ describe Devise::Strategies::Oauth2AuthorizationCodeGrantTypeStrategy do
102
102
  it 'returns json' do
103
103
  expected = {
104
104
  :error => 'invalid_client',
105
- :error_description => 'invalid client credentials'
105
+ :error_description => 'Invalid client credentials.'
106
106
  }
107
107
  response.body.should match_json(expected)
108
108
  end
@@ -126,7 +126,7 @@ describe Devise::Strategies::Oauth2AuthorizationCodeGrantTypeStrategy do
126
126
  it 'returns json' do
127
127
  expected = {
128
128
  :error => 'invalid_client',
129
- :error_description => 'invalid client credentials'
129
+ :error_description => 'Invalid client credentials.'
130
130
  }
131
131
  response.body.should match_json(expected)
132
132
  end
@@ -65,7 +65,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
65
65
  it { response.content_type.should == 'application/json' }
66
66
  it 'returns json' do
67
67
  expected = {
68
- :error_description => "invalid client credentials",
68
+ :error_description => "Invalid client credentials.",
69
69
  :error => "invalid_client"
70
70
  }
71
71
  response.body.should match_json(expected)
@@ -87,7 +87,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
87
87
  it { response.content_type.should == 'application/json' }
88
88
  it 'returns json' do
89
89
  expected = {
90
- :error_description => "invalid client credentials",
90
+ :error_description => "Invalid client credentials.",
91
91
  :error => "invalid_client"
92
92
  }
93
93
  response.body.should match_json(expected)
@@ -112,7 +112,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
112
112
  it { response.content_type.should == 'application/json' }
113
113
  it 'returns json' do
114
114
  expected = {
115
- :error_description => "invalid password authentication request",
115
+ :error_description => "Invalid email or password.",
116
116
  :error => "invalid_grant"
117
117
  }
118
118
  response.body.should match_json(expected)
@@ -137,7 +137,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
137
137
  it { response.content_type.should == 'application/json' }
138
138
  it 'returns json' do
139
139
  expected = {
140
- :error_description => "invalid client credentials",
140
+ :error_description => "Invalid client credentials.",
141
141
  :error => "invalid_client"
142
142
  }
143
143
  response.body.should match_json(expected)
@@ -162,7 +162,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
162
162
  it { response.content_type.should == 'application/json' }
163
163
  it 'returns json' do
164
164
  expected = {
165
- :error_description => "invalid client credentials",
165
+ :error_description => "Invalid client credentials.",
166
166
  :error => "invalid_client"
167
167
  }
168
168
  response.body.should match_json(expected)
@@ -53,7 +53,7 @@ describe Devise::Strategies::Oauth2RefreshTokenGrantTypeStrategy do
53
53
  it 'returns json' do
54
54
  expected = {
55
55
  :error => 'invalid_grant',
56
- :error_description => 'invalid refresh token'
56
+ :error_description => 'Invalid refresh token.'
57
57
  }
58
58
  response.body.should match_json(expected)
59
59
  end
@@ -79,7 +79,7 @@ describe Devise::Strategies::Oauth2RefreshTokenGrantTypeStrategy do
79
79
  refresh_token = @refresh_token
80
80
  expected = {
81
81
  :error => 'invalid_grant',
82
- :error_description => 'invalid refresh token'
82
+ :error_description => 'Invalid refresh token.'
83
83
  }
84
84
  response.body.should match_json(expected)
85
85
  end
@@ -103,7 +103,7 @@ describe Devise::Strategies::Oauth2RefreshTokenGrantTypeStrategy do
103
103
  it 'returns json' do
104
104
  expected = {
105
105
  :error => 'invalid_client',
106
- :error_description => 'invalid client credentials'
106
+ :error_description => 'Invalid client credentials.'
107
107
  }
108
108
  response.body.should match_json(expected)
109
109
  end
@@ -127,7 +127,7 @@ describe Devise::Strategies::Oauth2RefreshTokenGrantTypeStrategy do
127
127
  it 'returns json' do
128
128
  expected = {
129
129
  :error => 'invalid_client',
130
- :error_description => 'invalid client credentials'
130
+ :error_description => 'Invalid client credentials.'
131
131
  }
132
132
  response.body.should match_json(expected)
133
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brycesch-devise_oauth2_providable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -175,6 +175,7 @@ files:
175
175
  - app/views/devise/oauth2_providable/authorizations/_form.html.erb
176
176
  - app/views/devise/oauth2_providable/authorizations/error.html.erb
177
177
  - app/views/devise/oauth2_providable/authorizations/new.html.erb
178
+ - config/locales/en.yml
178
179
  - config/routes.rb
179
180
  - db/migrate/20111014160714_create_devise_oauth2_providable_schema.rb
180
181
  - devise_oauth2_providable.gemspec