warden-oauth2-strategies 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/warden/oauth2/failure_app.rb +7 -2
- data/lib/warden/oauth2/version.rb +1 -1
- data/spec/warden/oauth2/failure_app_spec.rb +11 -6
- data/warden-oauth2.gemspec +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f69d35d74b8c3c2634402bbcef1763f247ed8766
|
4
|
+
data.tar.gz: 9f6f94e8081c71a097f8a7faba877bb2200e395d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 684cddb78f24c07f0369cb774ad52a9052d8af3260384417ade64cf4d93f359a03c3b1393c21dacc28c40eb9a3c900199719446aa7711662af21ef678dc031e0
|
7
|
+
data.tar.gz: 77d117334f06d35b5d5819e6f784ddfa3c814fee60ef69de004f2b293364d1c278df06176699f8a89dd91de226fe07f5f97f332c5ef46a88c3b01eac47f8957d
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'json'
|
1
2
|
module Warden
|
2
3
|
module OAuth2
|
3
4
|
class FailureApp
|
@@ -8,9 +9,13 @@ module Warden
|
|
8
9
|
def call(env)
|
9
10
|
warden = env['warden']
|
10
11
|
strategy = warden.winning_strategy
|
12
|
+
error_description = strategy.respond_to?(:error_description) ? strategy.error_description : ''
|
11
13
|
|
12
|
-
body =
|
13
|
-
|
14
|
+
body = {}
|
15
|
+
body[:error] = strategy.message
|
16
|
+
body[:error_description] = error_description
|
17
|
+
body = JSON.dump(body)
|
18
|
+
status = strategy.error_status
|
14
19
|
headers = {'Content-Type' => 'application/json'}
|
15
20
|
|
16
21
|
headers['X-Accepted-OAuth-Scopes'] = (strategy.scope || :public).to_s
|
@@ -1,13 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Warden::OAuth2::FailureApp do
|
4
|
-
let(:app){ subject }
|
5
|
-
let(:warden){ double(:winning_strategy => @strategy || strategy) }
|
6
|
-
let(:strategy){ double(:message => 'invalid_request') }
|
4
|
+
let(:app) { subject }
|
5
|
+
let(:warden) { double(:winning_strategy => @strategy || strategy) }
|
7
6
|
|
7
|
+
it 'uses empty string is strategy does not provide a description' do
|
8
|
+
@strategy = double(error_status: 500,:message => 'custom', scope: 'bla')
|
9
|
+
get '/unauthenticated', {}, 'warden' => warden
|
10
|
+
last_response.body.should == '{"error":"custom","error_description":""}'
|
11
|
+
end
|
8
12
|
context 'with all info' do
|
9
13
|
before do
|
10
|
-
@strategy = double(:error_status => 502, :message => 'custom', :
|
14
|
+
@strategy = double(:error_status => 502, :message => 'custom', error_description: 'description',
|
15
|
+
:scope => 'random')
|
11
16
|
get '/unauthenticated', {}, 'warden' => warden
|
12
17
|
end
|
13
18
|
|
@@ -15,8 +20,8 @@ describe Warden::OAuth2::FailureApp do
|
|
15
20
|
last_response.status.should == 502
|
16
21
|
end
|
17
22
|
|
18
|
-
it 'should set the message from the message' do
|
19
|
-
last_response.body.should == '{"error":"custom"}'
|
23
|
+
it 'should set the message and error description from the message' do
|
24
|
+
last_response.body.should == '{"error":"custom","error_description":"description"}'
|
20
25
|
end
|
21
26
|
|
22
27
|
it 'should set the content type' do
|
data/warden-oauth2.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-oauth2-strategies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AirService
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: warden
|
@@ -102,7 +102,8 @@ files:
|
|
102
102
|
- spec/warden/oauth2/strategies/token_spec.rb
|
103
103
|
- warden-oauth2.gemspec
|
104
104
|
homepage: https://github.com/airservice/warden-oauth2
|
105
|
-
licenses:
|
105
|
+
licenses:
|
106
|
+
- MIT
|
106
107
|
metadata: {}
|
107
108
|
post_install_message:
|
108
109
|
rdoc_options: []
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.1.11
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: OAuth 2.0 strategies for Warden
|