warden-jwt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +6 -0
  7. data/Guardfile +16 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +41 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +7 -0
  13. data/lib/warden/jwt/config.rb +117 -0
  14. data/lib/warden/jwt/strategy.rb +73 -0
  15. data/lib/warden/jwt/version.rb +5 -0
  16. data/lib/warden/jwt.rb +9 -0
  17. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_audience_check/and_invalid_audience/fails_authentication.yml +55 -0
  18. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_audience_check/and_valid_audience/authenticates_successfully.yml +55 -0
  19. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_invalid_password/fails_authentication.yml +52 -0
  20. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_invalid_username/fails_authentication.yml +52 -0
  21. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_issuer_check/and_invalid_issuer/raises_invalid_issuer_exception.yml +55 -0
  22. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_issuer_check/and_valid_issuer/authenticates_successfully.yml +55 -0
  23. data/spec/fixtures/vcr_cassettes/Warden_JWT_Strategy/_authenticate_/with_valid_parameters/authenticates_successfully.yml +55 -0
  24. data/spec/helpers/request_helper.rb +9 -0
  25. data/spec/spec_helper.rb +18 -0
  26. data/spec/support/vcr.rb +7 -0
  27. data/spec/warden/jwt/config_spec.rb +183 -0
  28. data/spec/warden/jwt/strategy_spec.rb +143 -0
  29. data/spec/warden/jwt_spec.rb +7 -0
  30. data/warden-jwt.gemspec +38 -0
  31. metadata +297 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5850a3c4cdf867ca5cd9b6c0b1f0b264642611db
4
+ data.tar.gz: 7e846e427951539fd0e7cd848c29348459e69231
5
+ SHA512:
6
+ metadata.gz: dc8bd5c392d7c5c88b033a488605a10e46f01889e8641ac010585cc9212dce7014e743ab11c97c3465eecba05c8c62826b9ffebdfd12365879b3ac4fec95ff96
7
+ data.tar.gz: 2aaf35c8428bbc5b3cdbc5132f5bf4133dfb8214c030f31d57c43861247d7923220b8ab92af04309ffd6b9adf57616b3337f5d8356b2e48261c0e5635eddb9b9
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.ruby-version
11
+ /*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ - 2.2.2
5
+ before_install: gem install bundler -v 1.10.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in warden-jwt.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/Guardfile ADDED
@@ -0,0 +1,16 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rob Sharp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Warden::Jwt
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/warden/jwt`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'warden-jwt'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install warden-jwt
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dgvz/warden-jwt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "warden/jwt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,117 @@
1
+ module Warden
2
+ module JWT
3
+ # This class encapsulates the configuration of the strategy. A strategy can
4
+ # be configured through Warden::Manager by defining a scope's default. Thus,
5
+ # it is possible to use the same strategy with different configurations by
6
+ # using multiple scopes.
7
+ #
8
+ # To configure a scope, use #scope_defaults inside the Warden::Manager
9
+ # config block. The first arg is the name of the scope (the default is
10
+ # :default, so use that to configure the default scope), the second arg is
11
+ # an options hash which should contain:
12
+ #
13
+ # - :strategies : An array of strategies to use for this scope. Since this
14
+ # strategy is called :jwt, include it in the array.
15
+ #
16
+ # - :config : A hash containing the configs that are used for JWT.
17
+ # Valid parameters include :issuer, :audience, :secret,
18
+ # :verify_issuer, :verify_audience,
19
+ # :username_param, and :password_param.
20
+ #
21
+ # If :issuer, :audience or :secret are not specified, they
22
+ # will be fetched from -
23
+ # ENV['IDENTITY_URL'],
24
+ # ENV['IDENTITY_CLIENT_ID'] and
25
+ # ENV['IDENTITY_SECRET'], respectively.
26
+ #
27
+ # If :username_param or :password_param are not specified,
28
+ # they will be fetched from -
29
+ # params['username'],
30
+ # params['password'], respectively.
31
+ #
32
+ # Examples
33
+ #
34
+ # use Warden::Manager do |config|
35
+ # config.failure_app = BadAuthentication
36
+ #
37
+ # # The following line doesn't specify any custom configurations, thus
38
+ # # the default scope will be using the implict client_id,
39
+ # # client_secret, and redirect_uri.
40
+ # config.default_strategies :jwt
41
+ #
42
+ # # This configures an additional scope that uses the jwt strategy
43
+ # # with custom configuration.
44
+ # config.scope_defaults :admin, :config => { :issuer => 'foobar',
45
+ # :audience => 'barfoo',
46
+ # :secret => 'foobarfoo' }
47
+ # end
48
+ class Config
49
+ BadConfig = Class.new(StandardError)
50
+
51
+ include ::Warden::Mixins::Common
52
+
53
+ attr_reader :env, :warden_scope
54
+
55
+ def initialize(env, warden_scope)
56
+ @env = env
57
+ @warden_scope = warden_scope
58
+ end
59
+
60
+ def issuer
61
+ custom_config[:issuer] ||
62
+ ENV['IDENTITY_URL'] ||
63
+ fail(BadConfig, 'Missing issuer configuration.')
64
+ end
65
+
66
+ def audience
67
+ custom_config[:audience] ||
68
+ ENV['IDENTITY_CLIENT_ID'] ||
69
+ fail(BadConfig, 'Missing audience configuration.')
70
+ end
71
+
72
+ def secret
73
+ custom_config[:secret] ||
74
+ ENV['IDENTITY_SECRET'] ||
75
+ fail(BadConfig, 'Missing secret configuration.')
76
+ end
77
+
78
+ def username_param
79
+ custom_config[:username_param] ||
80
+ "username"
81
+ end
82
+
83
+ def password_param
84
+ custom_config[:password_param] ||
85
+ "password"
86
+ end
87
+
88
+ def verify_issuer
89
+ custom_config.fetch(:verify_issuer, true)
90
+ end
91
+
92
+ def verify_audience
93
+ custom_config.fetch(:verify_audience, true)
94
+ end
95
+
96
+ def to_hash
97
+ { :issuer => issuer,
98
+ :audience => audience,
99
+ :secret => secret,
100
+ :username_param => username_param,
101
+ :password_param => password_param,
102
+ :verify_issuer => verify_issuer,
103
+ :verify_audience => verify_audience }
104
+ end
105
+
106
+ private
107
+
108
+ def custom_config
109
+ @custom_config ||=
110
+ env['warden'].
111
+ config[:scope_defaults].
112
+ fetch(warden_scope, {}).
113
+ fetch(:config, {})
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,73 @@
1
+ require 'addressable/uri'
2
+ require 'ostruct'
3
+ require 'jwt'
4
+ require 'warden'
5
+ require 'rest_client'
6
+
7
+ module Warden
8
+ module JWT
9
+ class Strategy < ::Warden::Strategies::Base
10
+
11
+ def valid?
12
+ !!params[config[:username_param]] && !!params[config[:password_param]]
13
+ end
14
+
15
+ def authenticate!
16
+ token = fetch_token do |json|
17
+ decode_token_from_json(json)
18
+ end
19
+
20
+ if token
21
+ success!(token)
22
+ else
23
+ fail!("Could not log in")
24
+ end
25
+ end
26
+
27
+ def config
28
+ @config ||= ::Warden::JWT::Config.new(env, scope).to_hash
29
+ end
30
+
31
+ def fetch_token
32
+ token_url = Addressable::URI.parse(config[:issuer])
33
+ token_url.path = "/oauth/token"
34
+
35
+ response = ::RestClient.post(
36
+ token_url.to_s,
37
+ {
38
+ :grant_type => :password,
39
+ :username => params[config[:username_param]],
40
+ :password => params[config[:password_param]]
41
+ }
42
+ )
43
+
44
+ yield(response) if block_given?
45
+ rescue RestClient::Unauthorized
46
+ false
47
+ end
48
+
49
+ def decode_token_from_json(response)
50
+ json_token = JSON.parse(response)["access_token"]
51
+
52
+ token = ::JWT.decode(
53
+ json_token,
54
+ config[:secret],
55
+ true,
56
+ {
57
+ 'iss' => config[:issuer],
58
+ :verify_iss => config[:verify_issuer],
59
+ 'aud' => config[:audience],
60
+ :verify_aud => config[:verify_audience]
61
+ }
62
+ ).first
63
+
64
+ OpenStruct.new(token)
65
+ rescue ::JWT::InvalidAudError
66
+ # this simply means our app isn't authorised for this user, no biggie
67
+ false
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ Warden::Strategies.add(:jwt, Warden::JWT::Strategy)
@@ -0,0 +1,5 @@
1
+ module Warden
2
+ module JWT
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
data/lib/warden/jwt.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "warden/jwt/version"
2
+ require "warden/jwt/strategy"
3
+ require "warden/jwt/config"
4
+
5
+ module Warden
6
+ module JWT
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:4000/oauth/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: grant_type=password&username=you%40example.com&password=mypassword
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '66'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ Cache-Control:
32
+ - no-store
33
+ Pragma:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"3c60b875859fa36cd6b1977b4c6acb78"
39
+ Set-Cookie:
40
+ - _oauth-provider-doorkeeper_session=M0ZXTUpyalJOYlpmSUkyN004ZnNVQkpjR0t1empoanoyR0dQelZ0RmFxSVN2cURzRkpjUlg4SGhSMDNjUjAwSytybFltTE9leWVNUCtSUGdld1JZRFE9PS0tQWM1VVl3S2MzUFRVanJUWlpVWGxQZz09--f369dfa7942343e6491a579db5c7992869f23762;
41
+ path=/; HttpOnly
42
+ X-Request-Id:
43
+ - e35ad3de-9af1-4b1a-a146-5a4e39912cab
44
+ X-Runtime:
45
+ - '0.155582'
46
+ Connection:
47
+ - close
48
+ Server:
49
+ - thin
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOiIyMDE1LTA3LTI4VDA0OjIyOjIxLjkyMyswMDowMCIsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDAwMCIsImF1ZCI6WyIxZjI0YmY1NDJiNjkyNWZmM2IxODAzMmY5MzExYzEyMmMyMTA2OGNlMGEwOTAzM2IyMDcxMTJmODI2ZGIzZDdmIl0sInVpZCI6OSwidW4iOiJ0ZXN0IiwiZW1haWwiOiJ5b3VAZXhhbXBsZS5jb20iLCJmbiI6IlRlc3QiLCJsbiI6IlRlc3QiLCJuIjoiVGVzdCIsInIiOiJkZWZhdWx0IiwibSI6W3sicCI6ImRlZmF1bHQiLCJvaWQiOiIxZjI0YmY1NDJiNjkyNWZmM2IxODAzMmY5MzExYzEyMmMyMTA2OGNlMGEwOTAzM2IyMDcxMTJmODI2ZGIzZDdmIiwibyI6IkRpZ2lmaW5kIn1dfQ.WdlVPv6anMKAQCXdaZURAPNsiyQERXdKlYCGBZXK4nc","token_type":"bearer","expires_in":7200,"refresh_token":"1e4ce31b01256ac78ca74931a7839f38391de00dd06450425073bfb402e79616","scope":"public","created_at":1438057341}'
53
+ http_version:
54
+ recorded_at: Tue, 28 Jul 2015 04:22:21 GMT
55
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:4000/oauth/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: grant_type=password&username=you%40example.com&password=mypassword
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '66'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ Cache-Control:
32
+ - no-store
33
+ Pragma:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"c53edd4b96a43d2353d0302ad7744c1d"
39
+ Set-Cookie:
40
+ - _oauth-provider-doorkeeper_session=UTJ4VFJHdVprOUw2cksxL2RpdjJjNFZGRGMzUlREblZ6aDRXbGZSZ0dmaG5zUmtDa1ZmRis3VmY0VERuNDN5M0VTdnE1OUlxR3FmMkpRYnhaaTUyMmc9PS0tamxKMlJnSUdDUUMwZi9CWjVwQXc1QT09--b48bbe38811c831800a1cdf6213731a1c61a78c2;
41
+ path=/; HttpOnly
42
+ X-Request-Id:
43
+ - e1e10e09-ff17-420b-b813-6c966003f1e2
44
+ X-Runtime:
45
+ - '0.379049'
46
+ Connection:
47
+ - close
48
+ Server:
49
+ - thin
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOiIyMDE1LTA3LTI4VDA0OjIxOjQ5Ljk4NiswMDowMCIsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDAwMCIsImF1ZCI6WyIxZjI0YmY1NDJiNjkyNWZmM2IxODAzMmY5MzExYzEyMmMyMTA2OGNlMGEwOTAzM2IyMDcxMTJmODI2ZGIzZDdmIl0sInVpZCI6OSwidW4iOiJ0ZXN0IiwiZW1haWwiOiJ5b3VAZXhhbXBsZS5jb20iLCJmbiI6IlRlc3QiLCJsbiI6IlRlc3QiLCJuIjoiVGVzdCIsInIiOiJkZWZhdWx0IiwibSI6W3sicCI6ImRlZmF1bHQiLCJvaWQiOiIxZjI0YmY1NDJiNjkyNWZmM2IxODAzMmY5MzExYzEyMmMyMTA2OGNlMGEwOTAzM2IyMDcxMTJmODI2ZGIzZDdmIiwibyI6IkRpZ2lmaW5kIn1dfQ.MQZkDOMGV41gcC10iAO9hothwV_iUZ04YFqT3d21Pf0","token_type":"bearer","expires_in":7200,"refresh_token":"20ba636c067b058b191d8cbea885a24b4e39f7b1f57f2a9a78bb112afe0b8907","scope":"public","created_at":1438057310}'
53
+ http_version:
54
+ recorded_at: Tue, 28 Jul 2015 04:21:50 GMT
55
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:4000/oauth/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: grant_type=password&username=you%40example.com&password=pass
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '60'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ Content-Type:
32
+ - application/xml; charset=utf-8
33
+ Cache-Control:
34
+ - no-cache
35
+ X-Request-Id:
36
+ - 4a1facd0-cfb6-4a1d-a266-d9b0d4aa2e92
37
+ X-Runtime:
38
+ - '0.103057'
39
+ Connection:
40
+ - close
41
+ Server:
42
+ - thin
43
+ body:
44
+ encoding: UTF-8
45
+ string: |
46
+ <?xml version="1.0" encoding="UTF-8"?>
47
+ <errors>
48
+ <error>Invalid login or password.</error>
49
+ </errors>
50
+ http_version:
51
+ recorded_at: Tue, 28 Jul 2015 03:41:37 GMT
52
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:4000/oauth/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: grant_type=password&username=me%40example.com&password=pass
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '59'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ Content-Type:
32
+ - application/xml; charset=utf-8
33
+ Cache-Control:
34
+ - no-cache
35
+ X-Request-Id:
36
+ - 4b529d0f-94e0-44d4-ab68-353884115d94
37
+ X-Runtime:
38
+ - '0.107683'
39
+ Connection:
40
+ - close
41
+ Server:
42
+ - thin
43
+ body:
44
+ encoding: UTF-8
45
+ string: |
46
+ <?xml version="1.0" encoding="UTF-8"?>
47
+ <errors>
48
+ <error>Invalid login or password.</error>
49
+ </errors>
50
+ http_version:
51
+ recorded_at: Tue, 28 Jul 2015 03:41:37 GMT
52
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:2000/oauth/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: grant_type=password&username=you%40example.com&password=mypassword
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '66'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ Cache-Control:
32
+ - no-store
33
+ Pragma:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"459619d6b3a0bb2a58497340ec503734"
39
+ Set-Cookie:
40
+ - _oauth-provider-doorkeeper_session=bExsY09pWTZrL2ViVnB2OSt4QThnMFE4ZWRXOXpmWGl2cVNPUjQ5T1hHeW9DQUJOUlQxM0tNSXIyeGsyWXZ2NUUrOFZITjVTSVNoS215S3E5QlYvM3c9PS0tcmhuUzVZSFNlNE1TMWNpaFpoeHFrdz09--6461c4d8dbfdf6d24bf5ff91f1f7115061ae99f0;
41
+ path=/; HttpOnly
42
+ X-Request-Id:
43
+ - 83b151f1-c2c8-4a9f-bd31-6ad384251491
44
+ X-Runtime:
45
+ - '1.018228'
46
+ Connection:
47
+ - close
48
+ Server:
49
+ - thin
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOiIyMDE1LTA3LTI4VDA1OjAyOjA2LjIzNCswMDowMCIsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDAwMCIsImF1ZCI6WyIxZjI0YmY1NDJiNjkyNWZmM2IxODAzMmY5MzExYzEyMmMyMTA2OGNlMGEwOTAzM2IyMDcxMTJmODI2ZGIzZDdmIl0sInVpZCI6OSwidW4iOiJ0ZXN0IiwiZW1haWwiOiJ5b3VAZXhhbXBsZS5jb20iLCJmbiI6IlRlc3QiLCJsbiI6IlRlc3QiLCJuIjoiVGVzdCIsInIiOiJkZWZhdWx0IiwibSI6W3sicCI6ImRlZmF1bHQiLCJvaWQiOiIxZjI0YmY1NDJiNjkyNWZmM2IxODAzMmY5MzExYzEyMmMyMTA2OGNlMGEwOTAzM2IyMDcxMTJmODI2ZGIzZDdmIiwibyI6IkRpZ2lmaW5kIn1dfQ.DDdBYX5eSUw_cKwlVvbo2eMNvxvzifVcmXEcqW3N0A4","token_type":"bearer","expires_in":7200,"refresh_token":"3df5374721178cc40799e2b3bb69f394998b8e8d6345f6b00309d077bb5bf9fe","scope":"public","created_at":1438059726}'
53
+ http_version:
54
+ recorded_at: Tue, 28 Jul 2015 05:02:06 GMT
55
+ recorded_with: VCR 2.9.3