warden-oauth2-strategies 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/warden/oauth2/failure_app.rb +13 -9
- data/lib/warden/oauth2/version.rb +1 -1
- data/spec/warden/oauth2/failure_app_spec.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5f58493bf08099b52076a588bec5a9b085a87dc
|
4
|
+
data.tar.gz: c035adbefd44c2d638f4083837bdf177556d4daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82c79f570379db6077afae398c31ac2fae751e6e1dabdd38c44a653340d48432eb98125dde64905ce2cd515cd47c4f7f67add125a569595e46acc650f965bca2
|
7
|
+
data.tar.gz: 9fa9d1e8aaa201fa5a1644d985f4456e26aab48c9ed625a71b3cd2b0ff2c565340421ff0fc32f6e1bb61912034681bedc668cf01dd2145e07f11f3ebeb50ddba
|
@@ -9,18 +9,22 @@ module Warden
|
|
9
9
|
def call(env)
|
10
10
|
warden = env['warden']
|
11
11
|
strategy = warden.winning_strategy
|
12
|
-
error_description = strategy.respond_to?(:error_description) ? strategy.error_description : ''
|
13
12
|
|
14
|
-
body = {}
|
15
|
-
body[:error] = strategy.message
|
16
|
-
body[:error_description] = error_description
|
17
|
-
body = JSON.dump(body)
|
18
|
-
status = strategy.error_status
|
19
13
|
headers = {'Content-Type' => 'application/json'}
|
14
|
+
body = {}
|
15
|
+
if strategy
|
16
|
+
error_description = strategy.respond_to?(:error_description) ? strategy.error_description : ''
|
17
|
+
body[:error] = strategy.message
|
18
|
+
body[:error_description] = error_description
|
19
|
+
status = strategy.error_status
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
headers['X-Accepted-OAuth-Scopes'] = (strategy.scope || :public).to_s
|
22
|
+
else
|
23
|
+
status = 400
|
24
|
+
body[:error] = "invalid_grant"
|
25
|
+
body[:error_description] = "grant_type is not specified or invalid"
|
26
|
+
end
|
27
|
+
[status, headers, [JSON.dump(body)]]
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -2,8 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Warden::OAuth2::FailureApp do
|
4
4
|
let(:app) { subject }
|
5
|
-
let(:warden) { double(:winning_strategy => @strategy
|
5
|
+
let(:warden) { double(:winning_strategy => @strategy) }
|
6
6
|
|
7
|
+
it 'defaults to invalid_grant if strategy is not found' do
|
8
|
+
@strategy = nil
|
9
|
+
get '/unauthenticated', {}, 'warden' => warden
|
10
|
+
last_response.status.should == 400
|
11
|
+
last_response.body.should == '{"error":"invalid_grant","error_description":"grant_type is not specified or invalid"}'
|
12
|
+
end
|
7
13
|
it 'uses empty string is strategy does not provide a description' do
|
8
14
|
@strategy = double(error_status: 500,:message => 'custom', scope: 'bla')
|
9
15
|
get '/unauthenticated', {}, 'warden' => warden
|