rails_jwt_auth 0.4.0 → 0.5.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590d1c824e7a0171f9e8c084046dc0351181487d
|
4
|
+
data.tar.gz: ef843896d84008e223cefa7fa805ef646bdd4926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80f81e20135779d4d172fce4d06d0f92cb21aee8a5b45a81a93e1d6d2fdba20dd6c37de4747315d8df5b6b13e08b44b78d7bc6d2f75c869af6708e0186d9da79
|
7
|
+
data.tar.gz: 69a6d187020c8acb0984adbedbaed96aa45d622bea1ad63d9b657cd04dc769c6a8770fd2b0eb0b7509331e536cda01de58fa1072a05e270d49c2f1cf963e1968
|
data/README.md
CHANGED
@@ -350,7 +350,7 @@ resource :registration, controller: 'registrations', only: [:create, :update, :d
|
|
350
350
|
|
351
351
|
## Testing (rspec)
|
352
352
|
|
353
|
-
Require the RailsJwtAuth::Spec::Helpers helper module in `
|
353
|
+
Require the RailsJwtAuth::Spec::Helpers helper module in `rails_helper.rb`.
|
354
354
|
|
355
355
|
```ruby
|
356
356
|
require 'rails_jwt_auth/spec/helpers'
|
@@ -358,22 +358,23 @@ Require the RailsJwtAuth::Spec::Helpers helper module in `spec_helper.rb`.
|
|
358
358
|
RSpec.configure do |config|
|
359
359
|
...
|
360
360
|
config.include RailsJwtAuth::Spec::Helpers, :type => :controller
|
361
|
-
...
|
362
361
|
end
|
363
362
|
```
|
364
363
|
|
365
|
-
And then
|
364
|
+
And then we can just call sign_in(user) to sign in as a user, or sign_out for examples that have no user signed in. Here's two quick examples:
|
366
365
|
|
367
366
|
```ruby
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
367
|
+
describe ExampleController
|
368
|
+
it "blocks unauthenticated access" do
|
369
|
+
sign_out
|
370
|
+
expect { get :index }.to raise_error(RailsJwtAuth::Errors::NotAuthorized)
|
371
|
+
end
|
372
372
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
373
|
+
it "allows authenticated access" do
|
374
|
+
sign_in
|
375
|
+
get :index
|
376
|
+
expect(response).to be_success
|
377
|
+
end
|
377
378
|
end
|
378
379
|
```
|
379
380
|
|
@@ -16,8 +16,12 @@ module RailsJwtAuth
|
|
16
16
|
warden.authenticate!
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
19
|
+
def self.included(base)
|
20
|
+
return unless Rails.env.test? && base.name == 'ApplicationController'
|
21
|
+
|
22
|
+
base.send(:rescue_from, RailsJwtAuth::Spec::NotAuthorized) do
|
23
|
+
render json: {}, status: 401
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module RailsJwtAuth
|
2
2
|
module Spec
|
3
3
|
module Helpers
|
4
|
-
require 'rails_jwt_auth/
|
4
|
+
require 'rails_jwt_auth/spec/not_authorized'
|
5
5
|
require 'rails_jwt_auth/jwt/manager'
|
6
6
|
|
7
7
|
def sign_out
|
8
8
|
request.env['warden'] = RailsJwtAuth::Strategies::Jwt.new request.env
|
9
|
-
allow(request.env['warden']).to receive(:authenticate!).and_raise(RailsJwtAuth::
|
9
|
+
allow(request.env['warden']).to receive(:authenticate!).and_raise(RailsJwtAuth::Spec::NotAuthorized)
|
10
10
|
end
|
11
11
|
|
12
12
|
def sign_in(user)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_jwt_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rjurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -95,10 +95,10 @@ files:
|
|
95
95
|
- lib/generators/templates/initializer.rb
|
96
96
|
- lib/rails_jwt_auth.rb
|
97
97
|
- lib/rails_jwt_auth/engine.rb
|
98
|
-
- lib/rails_jwt_auth/errors/not_authorized.rb
|
99
98
|
- lib/rails_jwt_auth/jwt/manager.rb
|
100
99
|
- lib/rails_jwt_auth/jwt/request.rb
|
101
100
|
- lib/rails_jwt_auth/spec/helpers.rb
|
101
|
+
- lib/rails_jwt_auth/spec/not_authorized.rb
|
102
102
|
- lib/rails_jwt_auth/strategies/jwt.rb
|
103
103
|
- lib/rails_jwt_auth/version.rb
|
104
104
|
- lib/tasks/rails_token_jwt_tasks.rake
|