devise_jwt_controllers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d4e4f13deb52fa238c98ecd24e6efc9265cfae80dfa7dbf4f0f95b81e3e7d5a1
4
+ data.tar.gz: 85f83f3ed86f86443d1a939630ebe6b92bf91db87ba75a243e39eb3551278c00
5
+ SHA512:
6
+ metadata.gz: 5912546a22f997b16c25370b33a2b6ddc4e5b88ff79293daa078997e92e34f7a578d0e9de2eff2e18971d031c818a4f0a257bc7375434acd53a54aec49359054
7
+ data.tar.gz: 3ebe528d1d84e60638233ef707bffd0fb66f941a7e13887aeac16022a5ec489b59a5f764ac21d68e3e4100436257186be5408abefb59ac846f4d446ee22b6505
data/.codeclimate.yml ADDED
@@ -0,0 +1,6 @@
1
+ plugins:
2
+ brakeman:
3
+ enabled: true
4
+ rubocop:
5
+ enabled: true
6
+ channel: rubocop-0-74
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /log/
10
+ .DS_Store
11
+ db/development.sqlite3
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,32 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+ Style/Documentation:
3
+ Enabled: false
4
+
5
+ Metrics/LineLength:
6
+ Max: 99
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - spec/**/*
11
+
12
+ Style/FrozenStringLiteralComment:
13
+ Enabled: false
14
+
15
+ # rubocop-rspec custom configurations
16
+
17
+ require: rubocop-rspec
18
+
19
+ Naming/VariableNumber:
20
+ EnforcedStyle: snake_case
21
+
22
+ RSpec/ExampleLength:
23
+ Exclude:
24
+
25
+ RSpec/AnyInstance:
26
+ Enabled: true
27
+
28
+ RSpec/MultipleExpectations:
29
+ Enabled: false
30
+
31
+ RSpec/NestedGroups:
32
+ Max: 3
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.5
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
1
+ ---
2
+ env:
3
+ global:
4
+ - CC_TEST_REPORTER_ID=436339ff4051385d74f34fb00bfc887a8079893f50ef723cb8e5126a12198df2
5
+ sudo: false
6
+ language: ruby
7
+ cache: bundler
8
+ rvm:
9
+ - 2.6.0
10
+ - 2.6.1
11
+ - 2.6.2
12
+ - 2.6.3
13
+ - 2.6.4
14
+ - 2.6.5
15
+ before_install: gem install bundler -v 2.0.2
16
+ before_script:
17
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
18
+ - chmod +x ./cc-test-reporter
19
+ - ./cc-test-reporter before-build
20
+ script:
21
+ - bundle exec rubocop && bundle exec rspec
22
+ after_script:
23
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Devise JWT Controllers Changelog
2
+
3
+ ## Notes
4
+
5
+ - Newer changes should be on top.
6
+ - Release dates are at GTM-3, Argentina time zone.
7
+
8
+ ## Format for changes
9
+
10
+ ### [Version name] ([YYYY-MM-DD])
11
+
12
+ [Change!] Summary for the version
13
+
14
+ #### Changes
15
+
16
+ [Change!] Add a list of changes
17
+
18
+ ## LOG
19
+
20
+ ### 0.1.0 ([2019-11-14])
21
+
22
+ Initial release
23
+
24
+ #### Changes
25
+
26
+ - Adds `devise_jwt_for` method in mappers, working like `devise_for` but for JWT.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ramiro.rojo@wolox.com.ar. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in devise_jwt_controllers.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,249 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ devise_jwt_controllers (0.1.0)
5
+ devise (~> 4.7.1)
6
+ devise-jwt (~> 0.6.0)
7
+ rails (>= 5.2.0, < 6.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (6.0.0)
13
+ actionpack (= 6.0.0)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (6.0.0)
17
+ actionpack (= 6.0.0)
18
+ activejob (= 6.0.0)
19
+ activerecord (= 6.0.0)
20
+ activestorage (= 6.0.0)
21
+ activesupport (= 6.0.0)
22
+ mail (>= 2.7.1)
23
+ actionmailer (6.0.0)
24
+ actionpack (= 6.0.0)
25
+ actionview (= 6.0.0)
26
+ activejob (= 6.0.0)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.0.0)
30
+ actionview (= 6.0.0)
31
+ activesupport (= 6.0.0)
32
+ rack (~> 2.0)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.0.0)
37
+ actionpack (= 6.0.0)
38
+ activerecord (= 6.0.0)
39
+ activestorage (= 6.0.0)
40
+ activesupport (= 6.0.0)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.0.0)
43
+ activesupport (= 6.0.0)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.0.0)
49
+ activesupport (= 6.0.0)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.0.0)
52
+ activesupport (= 6.0.0)
53
+ activerecord (6.0.0)
54
+ activemodel (= 6.0.0)
55
+ activesupport (= 6.0.0)
56
+ activestorage (6.0.0)
57
+ actionpack (= 6.0.0)
58
+ activejob (= 6.0.0)
59
+ activerecord (= 6.0.0)
60
+ marcel (~> 0.3.1)
61
+ activesupport (6.0.0)
62
+ concurrent-ruby (~> 1.0, >= 1.0.2)
63
+ i18n (>= 0.7, < 2)
64
+ minitest (~> 5.1)
65
+ tzinfo (~> 1.1)
66
+ zeitwerk (~> 2.1, >= 2.1.8)
67
+ ast (2.4.0)
68
+ bcrypt (3.1.13)
69
+ brakeman (4.7.0)
70
+ builder (3.2.3)
71
+ byebug (11.0.1)
72
+ concurrent-ruby (1.1.5)
73
+ crass (1.0.5)
74
+ database_cleaner (1.7.0)
75
+ devise (4.7.1)
76
+ bcrypt (~> 3.0)
77
+ orm_adapter (~> 0.1)
78
+ railties (>= 4.1.0)
79
+ responders
80
+ warden (~> 1.2.3)
81
+ devise-jwt (0.6.0)
82
+ devise (~> 4.0)
83
+ warden-jwt_auth (~> 0.4)
84
+ diff-lcs (1.3)
85
+ docile (1.3.2)
86
+ dry-auto_inject (0.6.1)
87
+ dry-container (>= 0.3.4)
88
+ dry-configurable (0.8.3)
89
+ concurrent-ruby (~> 1.0)
90
+ dry-core (~> 0.4, >= 0.4.7)
91
+ dry-container (0.7.2)
92
+ concurrent-ruby (~> 1.0)
93
+ dry-configurable (~> 0.1, >= 0.1.3)
94
+ dry-core (0.4.9)
95
+ concurrent-ruby (~> 1.0)
96
+ erubi (1.9.0)
97
+ factory_bot (5.1.1)
98
+ activesupport (>= 4.2.0)
99
+ factory_bot_rails (5.1.1)
100
+ factory_bot (~> 5.1.0)
101
+ railties (>= 4.2.0)
102
+ faker (2.6.0)
103
+ i18n (>= 1.6, < 1.8)
104
+ globalid (0.4.2)
105
+ activesupport (>= 4.2.0)
106
+ i18n (1.7.0)
107
+ concurrent-ruby (~> 1.0)
108
+ jaro_winkler (1.5.3)
109
+ json (2.2.0)
110
+ jwt (2.2.1)
111
+ loofah (2.3.1)
112
+ crass (~> 1.0.2)
113
+ nokogiri (>= 1.5.9)
114
+ mail (2.7.1)
115
+ mini_mime (>= 0.1.1)
116
+ marcel (0.3.3)
117
+ mimemagic (~> 0.3.2)
118
+ method_source (0.9.2)
119
+ mimemagic (0.3.3)
120
+ mini_mime (1.0.2)
121
+ mini_portile2 (2.4.0)
122
+ minitest (5.12.2)
123
+ nio4r (2.5.2)
124
+ nokogiri (1.10.4)
125
+ mini_portile2 (~> 2.4.0)
126
+ orm_adapter (0.5.0)
127
+ parallel (1.18.0)
128
+ parser (2.6.5.0)
129
+ ast (~> 2.4.0)
130
+ rack (2.0.7)
131
+ rack-test (1.1.0)
132
+ rack (>= 1.0, < 3)
133
+ rails (6.0.0)
134
+ actioncable (= 6.0.0)
135
+ actionmailbox (= 6.0.0)
136
+ actionmailer (= 6.0.0)
137
+ actionpack (= 6.0.0)
138
+ actiontext (= 6.0.0)
139
+ actionview (= 6.0.0)
140
+ activejob (= 6.0.0)
141
+ activemodel (= 6.0.0)
142
+ activerecord (= 6.0.0)
143
+ activestorage (= 6.0.0)
144
+ activesupport (= 6.0.0)
145
+ bundler (>= 1.3.0)
146
+ railties (= 6.0.0)
147
+ sprockets-rails (>= 2.0.0)
148
+ rails-dom-testing (2.0.3)
149
+ activesupport (>= 4.2.0)
150
+ nokogiri (>= 1.6)
151
+ rails-html-sanitizer (1.3.0)
152
+ loofah (~> 2.3)
153
+ railties (6.0.0)
154
+ actionpack (= 6.0.0)
155
+ activesupport (= 6.0.0)
156
+ method_source
157
+ rake (>= 0.8.7)
158
+ thor (>= 0.20.3, < 2.0)
159
+ rainbow (3.0.0)
160
+ rake (12.3.3)
161
+ responders (3.0.0)
162
+ actionpack (>= 5.0)
163
+ railties (>= 5.0)
164
+ rspec (3.9.0)
165
+ rspec-core (~> 3.9.0)
166
+ rspec-expectations (~> 3.9.0)
167
+ rspec-mocks (~> 3.9.0)
168
+ rspec-core (3.9.0)
169
+ rspec-support (~> 3.9.0)
170
+ rspec-expectations (3.9.0)
171
+ diff-lcs (>= 1.2.0, < 2.0)
172
+ rspec-support (~> 3.9.0)
173
+ rspec-mocks (3.9.0)
174
+ diff-lcs (>= 1.2.0, < 2.0)
175
+ rspec-support (~> 3.9.0)
176
+ rspec-rails (3.9.0)
177
+ actionpack (>= 3.0)
178
+ activesupport (>= 3.0)
179
+ railties (>= 3.0)
180
+ rspec-core (~> 3.9.0)
181
+ rspec-expectations (~> 3.9.0)
182
+ rspec-mocks (~> 3.9.0)
183
+ rspec-support (~> 3.9.0)
184
+ rspec-support (3.9.0)
185
+ rubocop (0.75.0)
186
+ jaro_winkler (~> 1.5.1)
187
+ parallel (~> 1.10)
188
+ parser (>= 2.6)
189
+ rainbow (>= 2.2.2, < 4.0)
190
+ ruby-progressbar (~> 1.7)
191
+ unicode-display_width (>= 1.4.0, < 1.7)
192
+ rubocop-rails (2.3.2)
193
+ rack (>= 1.1)
194
+ rubocop (>= 0.72.0)
195
+ rubocop-rspec (1.36.0)
196
+ rubocop (>= 0.68.1)
197
+ ruby-progressbar (1.10.1)
198
+ simplecov (0.17.1)
199
+ docile (~> 1.1)
200
+ json (>= 1.8, < 3)
201
+ simplecov-html (~> 0.10.0)
202
+ simplecov-html (0.10.2)
203
+ sprockets (4.0.0)
204
+ concurrent-ruby (~> 1.0)
205
+ rack (> 1, < 3)
206
+ sprockets-rails (3.2.1)
207
+ actionpack (>= 4.0)
208
+ activesupport (>= 4.0)
209
+ sprockets (>= 3.0.0)
210
+ sqlite3 (1.4.1)
211
+ thor (0.20.3)
212
+ thread_safe (0.3.6)
213
+ tzinfo (1.2.5)
214
+ thread_safe (~> 0.1)
215
+ unicode-display_width (1.6.0)
216
+ warden (1.2.8)
217
+ rack (>= 2.0.6)
218
+ warden-jwt_auth (0.4.0)
219
+ dry-auto_inject (~> 0.6)
220
+ dry-configurable (~> 0.8)
221
+ jwt (~> 2.1)
222
+ warden (~> 1.2)
223
+ websocket-driver (0.7.1)
224
+ websocket-extensions (>= 0.1.0)
225
+ websocket-extensions (0.1.4)
226
+ zeitwerk (2.2.0)
227
+
228
+ PLATFORMS
229
+ ruby
230
+
231
+ DEPENDENCIES
232
+ brakeman
233
+ bundler (~> 2.0)
234
+ byebug
235
+ database_cleaner (~> 1.7.0)
236
+ devise_jwt_controllers!
237
+ factory_bot_rails (~> 5.1.1)
238
+ faker (~> 2.6.0)
239
+ rake (~> 12.3.3)
240
+ rspec (~> 3.9)
241
+ rspec-rails (~> 3.9)
242
+ rubocop (= 0.75)
243
+ rubocop-rails (= 2.3.2)
244
+ rubocop-rspec (= 1.36.0)
245
+ simplecov (~> 0.17.0)
246
+ sqlite3 (~> 1.4.1)
247
+
248
+ BUNDLED WITH
249
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Wolox
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,58 @@
1
+ # DeviseJwtControllers
2
+
3
+ [![Build Status](https://travis-ci.org/Wolox/devise_jwt_controllers.svg?branch=development-1.x.x)](https://travis-ci.org/Wolox/devise_jwt_controllers) [![Maintainability](https://api.codeclimate.com/v1/badges/d37c76dac875775e487d/maintainability)](https://codeclimate.com/github/Wolox/devise_jwt_controllers/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/d37c76dac875775e487d/test_coverage)](https://codeclimate.com/github/Wolox/devise_jwt_controllers/test_coverage)
4
+
5
+ This gem add devise-jwt JSON-like controllers to your application.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'devise_jwt_controllers'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install devise_jwt_controllers
22
+
23
+ ## Usage
24
+
25
+ Setup [devise](https://github.com/plataformatec/devise) an [devise-jwt](https://github.com/waiting-for-dev/devise-jwt) as normal.
26
+
27
+ You then just replace your `devise_for` in `config/routes.rb` with `devise_jwt_for`.
28
+
29
+ `devise_jwt_for` accepts the same arguments as `devise_for`, and configurations.
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/devise_jwt_controllers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+
45
+ ## About
46
+ This project was developed by [Leon Calermo](leoncalermo) and [Ramiro Rojo](https://github.com/holywyvern).
47
+
48
+ Maintainers: [Leon Calermo](https://github.com/leoncalermo)
49
+
50
+ Contributors: [Ramiro Rojo](https://github.com/holywyvern)
51
+
52
+ This gem is eveloped at [Wolox]((http://www.wolox.com.ar)):
53
+
54
+ [![Wolox](https://raw.githubusercontent.com/Wolox/press-kit/master/logos/logo_banner.png)]((http://www.wolox.com.ar))
55
+
56
+ ## Code of Conduct
57
+
58
+ Everyone interacting in the DeviseJwtControllers project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/devise_jwt_controllers/blob/master/CODE_OF_CONDUCT.md).
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
@@ -0,0 +1,23 @@
1
+ module Devise
2
+ module JWT
3
+ class BaseController < ApplicationController
4
+ include ActionController::MimeResponds
5
+
6
+ def respond_with(resource, _opts = {})
7
+ if resource.valid?
8
+ render json: resource, status: :created
9
+ else
10
+ render json: resource.errors, status: :unprocessable_entity
11
+ end
12
+ end
13
+
14
+ def respond_to_on_destroy
15
+ head :no_content
16
+ end
17
+
18
+ def respond_to_removed_action
19
+ head :not_found
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ module Devise
2
+ module JWT
3
+ class ConfirmationsController < Devise::ConfirmationsController
4
+ respond_to :json
5
+
6
+ def new
7
+ respond_to_removed_action
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Devise
2
+ module JWT
3
+ class PasswordsController < Devise::PasswordsController
4
+ respond_to :json
5
+
6
+ def new
7
+ respond_to_removed_action
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ module Devise
2
+ module JWT
3
+ class RegistrationsController < Devise::RegistrationsController
4
+ respond_to :json
5
+
6
+ def new
7
+ respond_to_removed_action
8
+ end
9
+
10
+ def edit
11
+ respond_to_removed_action
12
+ end
13
+
14
+ def cancel
15
+ respond_to_removed_action
16
+ end
17
+
18
+ def destroy
19
+ respond_to_on_destroy
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ module Devise
2
+ module JWT
3
+ class SessionsController < Devise::SessionsController
4
+ respond_to :json
5
+
6
+ def new
7
+ respond_to_removed_action
8
+ end
9
+
10
+ def create
11
+ super do
12
+ token = "Bearer #{request.env['warden-jwt_auth.token']}"
13
+ response.set_header('Authorization', token)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module Devise
2
+ module JWT
3
+ class UnlocksController < Devise::UnlocksController
4
+ respond_to :json
5
+
6
+ def new
7
+ respond_to_removed_action
8
+ end
9
+ end
10
+ end
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'devise_jwt_controllers'
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,56 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'devise/jwt/controllers/version'
4
+
5
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
6
+ spec.name = 'devise_jwt_controllers'
7
+ spec.version = Devise::JWT::Controllers::VERSION
8
+ spec.authors = ['Ramiro Rojo']
9
+ spec.email = ['ramiro.rojo@wolox.com.ar']
10
+
11
+ spec.summary = 'A gem to generate documentation out of tests.'
12
+ spec.homepage = 'https://github.com/Wolox/devise_jwt_controllers'
13
+ spec.license = 'Apache-2.0'
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'https://github.com/Wolox/devise_jwt_controllers'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/Wolox/devise_jwt_controllers/CHANGELOG.md'
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.required_ruby_version = '>= 2.6.0'
31
+
32
+ spec.add_runtime_dependency 'rails', '>= 5.2.0', '< 6.1'
33
+
34
+ spec.add_runtime_dependency 'devise', '~> 4.7.1'
35
+ spec.add_runtime_dependency 'devise-jwt', '~> 0.6.0'
36
+
37
+ spec.add_development_dependency 'bundler', '~> 2.0'
38
+
39
+ spec.add_development_dependency 'byebug'
40
+
41
+ spec.add_development_dependency 'brakeman'
42
+
43
+ spec.add_development_dependency 'faker', '~> 2.6.0'
44
+
45
+ spec.add_development_dependency 'sqlite3', '~> 1.4.1'
46
+
47
+ spec.add_development_dependency 'database_cleaner', '~> 1.7.0'
48
+ spec.add_development_dependency 'factory_bot_rails', '~> 5.1.1'
49
+ spec.add_development_dependency 'rake', '~> 12.3.3'
50
+ spec.add_development_dependency 'rspec', '~> 3.9'
51
+ spec.add_development_dependency 'rspec-rails', '~> 3.9'
52
+ spec.add_development_dependency 'rubocop', '0.75'
53
+ spec.add_development_dependency 'rubocop-rails', '2.3.2'
54
+ spec.add_development_dependency 'rubocop-rspec', '1.36.0'
55
+ spec.add_development_dependency 'simplecov', '~> 0.17.0'
56
+ end
@@ -0,0 +1,8 @@
1
+ module Devise
2
+ module JWT
3
+ module Controllers
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Devise
2
+ module JWT
3
+ module Controllers
4
+ class Railtie < Rails::Railtie
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Devise
2
+ module JWT
3
+ module Controllers
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ module ActionDispatch
2
+ module Routing
3
+ class Mapper
4
+ def devise_jwt_for(*resources)
5
+ options = resources.extract_options!
6
+ options[:controllers] = default_devise_jwt_controllers.merge(options[:controllers] || {})
7
+ options[:defaults] = { format: :json }.merge(options[:defaults] || {})
8
+ Devise::JWT::WardenHelper.add_mappings(*resources)
9
+ devise_for(*resources, options)
10
+ end
11
+
12
+ private
13
+
14
+ def default_devise_jwt_controllers
15
+ {
16
+ confirmations: 'devise/jwt/confirmations',
17
+ passwords: 'devise/jwt/passwords',
18
+ registrations: 'devise/jwt/registrations',
19
+ sessions: 'devise/jwt/sessions',
20
+ unlocks: 'devise/jwt/unlocks'
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,44 @@
1
+ module Devise
2
+ module JWT
3
+ module WardenHelper
4
+ class << self
5
+ def add_mappings(*models)
6
+ Warden::JWTAuth.configure do |config|
7
+ config.mappings = {}
8
+ config.revocation_strategies ||= {}
9
+ models.each do |model|
10
+ map_model(model)
11
+ end
12
+ config.mappings = mappings
13
+ config.revocation_strategies = revocations
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def map_model(model)
20
+ class_value = model_class(model)
21
+ symbol = model_sym(model)
22
+ mappings.merge!(symbol => class_value)
23
+ revocations.merge!(symbol => model_class(model).jwt_revocation_strategy)
24
+ end
25
+
26
+ def mappings
27
+ @mappings ||= {}
28
+ end
29
+
30
+ def revocations
31
+ @revocations ||= {}
32
+ end
33
+
34
+ def model_class(model)
35
+ model.to_s.classify.constantize
36
+ end
37
+
38
+ def model_sym(model)
39
+ model.to_s.singularize.to_sym
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ Devise.setup do |config|
2
+ config.parent_controller = 'Devise::JWT::BaseController'
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'devise/jwt/controllers/version'
2
+
3
+ require 'devise/jwt/controllers/engine'
4
+ require 'devise/jwt/controllers/railtie'
5
+ require_relative 'devise/jwt/extensions/warden_helper'
6
+
7
+ require_relative 'devise/jwt/extensions/action_dispatch'
8
+ require_relative 'devise/jwt/overrides/devise'
metadata ADDED
@@ -0,0 +1,320 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise_jwt_controllers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ramiro Rojo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 5.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: devise
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 4.7.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 4.7.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: devise-jwt
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.6.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.6.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: byebug
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: brakeman
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: faker
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 2.6.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 2.6.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: sqlite3
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 1.4.1
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 1.4.1
131
+ - !ruby/object:Gem::Dependency
132
+ name: database_cleaner
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 1.7.0
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 1.7.0
145
+ - !ruby/object:Gem::Dependency
146
+ name: factory_bot_rails
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: 5.1.1
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 5.1.1
159
+ - !ruby/object:Gem::Dependency
160
+ name: rake
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: 12.3.3
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: 12.3.3
173
+ - !ruby/object:Gem::Dependency
174
+ name: rspec
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '3.9'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '3.9'
187
+ - !ruby/object:Gem::Dependency
188
+ name: rspec-rails
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: '3.9'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: '3.9'
201
+ - !ruby/object:Gem::Dependency
202
+ name: rubocop
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - '='
206
+ - !ruby/object:Gem::Version
207
+ version: '0.75'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - '='
213
+ - !ruby/object:Gem::Version
214
+ version: '0.75'
215
+ - !ruby/object:Gem::Dependency
216
+ name: rubocop-rails
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - '='
220
+ - !ruby/object:Gem::Version
221
+ version: 2.3.2
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - '='
227
+ - !ruby/object:Gem::Version
228
+ version: 2.3.2
229
+ - !ruby/object:Gem::Dependency
230
+ name: rubocop-rspec
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - '='
234
+ - !ruby/object:Gem::Version
235
+ version: 1.36.0
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - '='
241
+ - !ruby/object:Gem::Version
242
+ version: 1.36.0
243
+ - !ruby/object:Gem::Dependency
244
+ name: simplecov
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: 0.17.0
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: 0.17.0
257
+ description:
258
+ email:
259
+ - ramiro.rojo@wolox.com.ar
260
+ executables: []
261
+ extensions: []
262
+ extra_rdoc_files: []
263
+ files:
264
+ - ".codeclimate.yml"
265
+ - ".gitignore"
266
+ - ".rspec"
267
+ - ".rubocop.yml"
268
+ - ".ruby-version"
269
+ - ".travis.yml"
270
+ - CHANGELOG.md
271
+ - CODE_OF_CONDUCT.md
272
+ - Gemfile
273
+ - Gemfile.lock
274
+ - LICENSE.txt
275
+ - README.md
276
+ - Rakefile
277
+ - app/controllers/devise/j_w_t/base_controller.rb
278
+ - app/controllers/devise/j_w_t/confirmations_controller.rb
279
+ - app/controllers/devise/j_w_t/passwords_controller.rb
280
+ - app/controllers/devise/j_w_t/registrations_controller.rb
281
+ - app/controllers/devise/j_w_t/sessions_controller.rb
282
+ - app/controllers/devise/j_w_t/unlocks_controller.rb
283
+ - bin/console
284
+ - bin/setup
285
+ - config/database.yml
286
+ - devise_jwt_controllers.gemspec
287
+ - lib/devise/jwt/controllers/engine.rb
288
+ - lib/devise/jwt/controllers/railtie.rb
289
+ - lib/devise/jwt/controllers/version.rb
290
+ - lib/devise/jwt/extensions/action_dispatch.rb
291
+ - lib/devise/jwt/extensions/warden_helper.rb
292
+ - lib/devise/jwt/overrides/devise.rb
293
+ - lib/devise_jwt_controllers.rb
294
+ homepage: https://github.com/Wolox/devise_jwt_controllers
295
+ licenses:
296
+ - Apache-2.0
297
+ metadata:
298
+ homepage_uri: https://github.com/Wolox/devise_jwt_controllers
299
+ source_code_uri: https://github.com/Wolox/devise_jwt_controllers
300
+ changelog_uri: https://github.com/Wolox/devise_jwt_controllers/CHANGELOG.md
301
+ post_install_message:
302
+ rdoc_options: []
303
+ require_paths:
304
+ - lib
305
+ required_ruby_version: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - ">="
308
+ - !ruby/object:Gem::Version
309
+ version: 2.6.0
310
+ required_rubygems_version: !ruby/object:Gem::Requirement
311
+ requirements:
312
+ - - ">="
313
+ - !ruby/object:Gem::Version
314
+ version: '0'
315
+ requirements: []
316
+ rubygems_version: 3.0.3
317
+ signing_key:
318
+ specification_version: 4
319
+ summary: A gem to generate documentation out of tests.
320
+ test_files: []