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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e885487f2c3e237d8a7cffa9020ea86671d015e
4
- data.tar.gz: 9b6d3b51466a0861cf876fa606d407fd9fd2da18
3
+ metadata.gz: f69d35d74b8c3c2634402bbcef1763f247ed8766
4
+ data.tar.gz: 9f6f94e8081c71a097f8a7faba877bb2200e395d
5
5
  SHA512:
6
- metadata.gz: f3fd02b16da09b9454a707f3d8843e969d907239f824caa136892c80734e63ac37b20befd927c4b5b6985fa87ca0dfcaca25228bd5c8672c8d57c3bbe743b69d
7
- data.tar.gz: 4a1ddb4c062dec57fbb06ea3e3a7d8da582baba7063d267bef97d2e404f0fa35b07d1ff07955d73a612bc21065e9fb55d46503c0c95d92ee8a5a8475eaa538f5
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 = '{"error":"' + strategy.message.to_s + '"}'
13
- status = strategy.error_status rescue 401
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,5 +1,5 @@
1
1
  module Warden
2
2
  module OAuth2
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -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', :scope => 'random')
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
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "warden-oauth2-strategies"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Warden::OAuth2::VERSION
17
+ gem.licenses = ['MIT']
17
18
 
18
19
  gem.add_dependency 'warden'
19
20
  gem.add_development_dependency 'rake'
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.2
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-18 00:00:00.000000000 Z
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.2.1
124
+ rubygems_version: 2.1.11
124
125
  signing_key:
125
126
  specification_version: 4
126
127
  summary: OAuth 2.0 strategies for Warden