tokenable-ruby 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +2 -2
- data/.github/workflows/{test.yml → tests.yml} +10 -4
- data/.gitignore +8 -0
- data/.rubocop.yml +55 -0
- data/Gemfile +18 -3
- data/README.md +42 -64
- data/lib/generators/templates/routes.rb.erb +2 -0
- data/lib/generators/templates/tokenable.rb.erb +12 -0
- data/lib/generators/templates/verifier_migration.rb.erb +5 -0
- data/lib/generators/tokenable/install_generator.rb +58 -0
- data/lib/generators/tokenable/verifier_generator.rb +40 -0
- data/lib/tokenable-ruby.rb +3 -0
- data/lib/tokenable/authable.rb +4 -2
- data/lib/tokenable/config.rb +3 -2
- data/lib/tokenable/controllers/tokens_controller.rb +6 -2
- data/lib/tokenable/engine.rb +1 -0
- data/lib/tokenable/strategies/devise.rb +3 -3
- data/lib/tokenable/strategies/secure_password.rb +3 -3
- data/lib/tokenable/strategies/sorcery.rb +31 -0
- data/lib/tokenable/version.rb +1 -1
- metadata +15 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a63844e9ccbdab546defaf4e6e9a3d8e1447a96dd1db93678181fc490c7210eb
|
4
|
+
data.tar.gz: e0f6a5cfcd3276d0809fe9c5293d632ff3a6bbf26c06bb698a6b24833987a460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18044255f88cadbe625ab99e2ea00d1c8bf92a6d6e512f00024a93121f010efcdf644b4bd4de3c63a6030d88feb97340cf124c49b73e99a8af7af618309fd93
|
7
|
+
data.tar.gz: d24acf6f7d796c6520efb10f97a7af9593a32d5d89428472454761665b7f3b75876d92e3f8a2907d833e94066d10742705b24a4fabdb2613b476a7196670542c
|
@@ -1,9 +1,9 @@
|
|
1
|
-
name:
|
1
|
+
name: Tests
|
2
2
|
|
3
3
|
on: push
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
6
|
+
rspec:
|
7
7
|
strategy:
|
8
8
|
fail-fast: false
|
9
9
|
matrix:
|
@@ -12,10 +12,16 @@ jobs:
|
|
12
12
|
runs-on: ${{ matrix.os }}
|
13
13
|
steps:
|
14
14
|
- uses: actions/checkout@v2
|
15
|
+
|
15
16
|
- name: Set up Ruby
|
16
17
|
uses: ruby/setup-ruby@v1
|
17
18
|
with:
|
18
19
|
ruby-version: ${{ matrix.ruby }}
|
19
|
-
|
20
|
-
|
20
|
+
bundler-cache: true
|
21
|
+
|
22
|
+
- run: cd spec/dummy && bundle install
|
23
|
+
- run: cd spec/dummy && bundle exec rails db:create db:migrate
|
24
|
+
env:
|
25
|
+
RAILS_ENV: test
|
26
|
+
|
21
27
|
- run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
6
|
+
NewCops: enable
|
2
7
|
TargetRubyVersion: 2.5
|
8
|
+
Exclude:
|
9
|
+
- "spec/dummy/**/*"
|
10
|
+
- "vendor/**/*"
|
11
|
+
- "tmp/**/*"
|
12
|
+
|
13
|
+
Naming/FileName:
|
14
|
+
Exclude:
|
15
|
+
- 'lib/tokenable-ruby.rb'
|
3
16
|
|
4
17
|
Style/Documentation:
|
5
18
|
Enabled: false
|
@@ -20,3 +33,45 @@ Style/TrailingCommaInHashLiteral:
|
|
20
33
|
|
21
34
|
Layout/LineLength:
|
22
35
|
Max: 150
|
36
|
+
Exclude:
|
37
|
+
- "spec/**/*"
|
38
|
+
|
39
|
+
Lint/EmptyBlock:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Metrics/AbcSize:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Metrics/MethodLength:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Metrics/BlockLength:
|
49
|
+
Exclude:
|
50
|
+
- "spec/**/*"
|
51
|
+
|
52
|
+
Style/ClassVars:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
RSpec/MultipleExpectations:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
RSpec/ImplicitBlockExpectation:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
RSpec/DescribedClass:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
RSpec/StubbedMock:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
RSpec/MessageSpies:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
RSpec/NamedSubject:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
RSpec/ExampleLength:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
RSpec/FilePath:
|
77
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -4,7 +4,22 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem '
|
7
|
+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
|
8
8
|
|
9
|
-
gem '
|
10
|
-
|
9
|
+
gem 'rake'
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'bcrypt'
|
13
|
+
gem 'codecov', require: false, git: 'https://github.com/codecov/codecov-ruby.git'
|
14
|
+
gem 'database_cleaner-active_record', '1.8.0'
|
15
|
+
gem 'generator_spec', '0.9.4'
|
16
|
+
gem 'rails'
|
17
|
+
gem 'rails-controller-testing', '1.0.5'
|
18
|
+
gem 'rspec-rails', '4.0.2'
|
19
|
+
gem 'rubocop', '1.8.1'
|
20
|
+
gem 'rubocop-rails', '2.9.1'
|
21
|
+
gem 'rubocop-rake', '0.5.1'
|
22
|
+
gem 'rubocop-rspec', '2.1.0'
|
23
|
+
gem 'simplecov', '~> 0.2'
|
24
|
+
gem 'sqlite3', '1.4.2'
|
25
|
+
end
|
data/README.md
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# Tokenable
|
2
2
|
|
3
|
-

|
4
|
+
[](https://codecov.io/gh/tokenable/tokenable-ruby)
|
5
|
+

|
6
|
+

|
4
7
|
|
5
|
-
Tokenable is a gem
|
8
|
+
Tokenable is a Rails gem that allows API-only applications a way to authenticate users. This can be helpful when building Single Page Applications, or Mobile Applications.
|
6
9
|
|
7
|
-
|
10
|
+
Simply send a login request to the authentication endpoint, and Tokenable will return a token. This token can then be used to access your API, and any authenticated endpoints.
|
8
11
|
|
9
12
|
## Installation
|
10
13
|
|
11
14
|
Add this line to your application's Gemfile:
|
12
15
|
|
13
16
|
```ruby
|
14
|
-
gem 'tokenable'
|
17
|
+
gem 'tokenable-ruby', git: 'https://github.com/tokenable/tokenable-ruby.git', branch: 'main'
|
15
18
|
```
|
16
19
|
|
17
20
|
And then execute:
|
@@ -22,103 +25,78 @@ bundle install
|
|
22
25
|
|
23
26
|
## Usage
|
24
27
|
|
25
|
-
|
28
|
+
Once you have the gem installed, lets get it setup:
|
26
29
|
|
27
|
-
```
|
28
|
-
|
30
|
+
```bash
|
31
|
+
rails generate tokenable:install User --strategy=devise
|
29
32
|
```
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
class User < ApplicationRecord
|
35
|
-
include Tokenable::Strategies::SecurePassword
|
34
|
+
We make it easier for you, by adding out of the box support for some auth libraries. You can pick from the following options for `--strategy`, or leave it empty for a [custom strategy](https://github.com/tokenable/tokenable-ruby/wiki/Create-your-own-statergy):
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
- [devise](https://github.com/heartcombo/devise)
|
37
|
+
- [sorcery](https://github.com/Sorcery/sorcery)
|
38
|
+
- [secure_password](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html)
|
40
39
|
|
41
|
-
|
40
|
+
This will add a route, the configuration file at `config/initializers/tokenable.rb`, and add the required includes to your User model. There are no migrations to run in the default configuration.
|
42
41
|
|
43
|
-
|
44
|
-
- `Tokenable::Strategies::Devise`
|
42
|
+
### Controllers
|
45
43
|
|
46
|
-
|
44
|
+
To limit access to your controllers/endpoints, you will need to include Tokenable.
|
47
45
|
|
48
46
|
```ruby
|
49
|
-
|
50
|
-
|
51
|
-
return nil unless user.present?
|
47
|
+
class SomeController < ApplicationController
|
48
|
+
include Tokenable::Authable
|
52
49
|
|
53
|
-
|
54
|
-
user
|
50
|
+
before_action :require_tokenable_user!
|
55
51
|
end
|
56
52
|
```
|
57
53
|
|
54
|
+
After you have done this, the following methods are available:
|
55
|
+
|
56
|
+
- `current_user`
|
57
|
+
- `user_signed_in?`
|
58
|
+
|
58
59
|
### Invalidate Tokens
|
59
60
|
|
60
|
-
|
61
|
+
Sometime you want to be able to force a user (or users) to login again. You can do this by adding the Verifier. To install this, run:
|
61
62
|
|
62
|
-
```
|
63
|
-
|
64
|
-
include Tokenable::Verifier
|
65
|
-
end
|
63
|
+
```
|
64
|
+
rails generate tokenable:verifier User
|
66
65
|
```
|
67
66
|
|
68
|
-
And
|
67
|
+
And then run your migrations:
|
69
68
|
|
70
|
-
```
|
71
|
-
rails
|
69
|
+
```
|
70
|
+
rails db:migrate
|
72
71
|
```
|
73
72
|
|
74
73
|
You can now invalidate all tokens by calling `user.invalidate_tokens!`.
|
75
74
|
|
76
75
|
### Token Expiry
|
77
76
|
|
78
|
-
By default, tokens
|
77
|
+
By default, tokens expire after 7 days. If you want to change this, you can set a config option.
|
79
78
|
|
80
79
|
```ruby
|
80
|
+
# Expire in 7 days (default)
|
81
81
|
Tokenable::Config.lifespan = 7.days
|
82
|
-
```
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
Tokenable works out of the box, with no config required, however you can tweak the settings, by creating `config/initializers/tokenable.rb` file.
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
# The secret used to create these tokens. This is then used to verify the
|
90
|
-
# token is valid. Note: Tokens are not encrypted, and container the user_id.
|
91
|
-
# Default: Rails.application.secret_key_base
|
92
|
-
Tokenable::Config.secret = 'a-256-bit-string'
|
83
|
+
# Tokens will never expire
|
84
|
+
Tokenable::Config.lifespan = nil
|
93
85
|
```
|
94
86
|
|
95
|
-
### Example
|
87
|
+
### Example Use Cases
|
96
88
|
|
97
|
-
Once you have this setup, you
|
89
|
+
Once you have this setup, you will then be able to integrate your Rails API with a mobile app, single page application, or any other type of system. Here are some example use cases:
|
98
90
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
password: "coolpassword123",
|
103
|
-
});
|
104
|
-
|
105
|
-
const token = data.data.token;
|
106
|
-
const user_id = data.data.user_id;
|
107
|
-
```
|
108
|
-
|
109
|
-
You then use this token in all future API requests:
|
110
|
-
|
111
|
-
```js
|
112
|
-
const { data } = await axios.get(`https://example.com/api/user/${user_id}`, {
|
113
|
-
headers: { Authorization: `Bearer ${token}` },
|
114
|
-
});
|
115
|
-
```
|
91
|
+
- [Using Tokenable with Nuxt.js Auth](https://github.com/tokenable/tokenable-ruby/wiki/Integration-with-Nuxt.js-Auth)
|
92
|
+
- [Using Tokenable with Axios](https://github.com/tokenable/tokenable-ruby/wiki/Integration-with-Axios)
|
93
|
+
- [Using Tokenable with Curl](https://github.com/tokenable/tokenable-ruby/wiki/Curl-Example)
|
116
94
|
|
117
95
|
## Development
|
118
96
|
|
119
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
97
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
120
98
|
|
121
|
-
|
99
|
+
Then, run `bundle exec rspec` to run the tests.
|
122
100
|
|
123
101
|
## Contributing
|
124
102
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# How long should the token be valid for?
|
2
|
+
# After this time, it will return Tokenable::Unauthorized
|
3
|
+
# You can set this to nil for tokens to never expire
|
4
|
+
Tokenable::Config.lifespan = 7.days
|
5
|
+
|
6
|
+
# The class in which your User resides.
|
7
|
+
Tokenable::Config.user_class = <%= name %>
|
8
|
+
|
9
|
+
# The secret used to create these tokens. This is then used to verify the
|
10
|
+
# token is valid. Note: Tokens are not encrypted, and container the user_id.
|
11
|
+
# You can change this to any 256-bit string
|
12
|
+
Tokenable::Config.secret = Rails.application.secret_key_base
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/active_record'
|
4
|
+
|
5
|
+
module Tokenable
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < Rails::Generators::NamedBase
|
8
|
+
source_root File.expand_path('../templates', __dir__)
|
9
|
+
class_option :strategy, type: :string
|
10
|
+
|
11
|
+
def install_config
|
12
|
+
template 'tokenable.rb.erb', 'config/initializers/tokenable.rb'
|
13
|
+
template 'routes.rb.erb', 'config/routes.rb' unless routes_file_exists?
|
14
|
+
route "mount Tokenable::Engine => '/api/auth'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_strategy
|
18
|
+
unless options.strategy
|
19
|
+
say_status :skip, 'strategy (none provided)', :yellow
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
if options.strategy.in?(list_of_strategies)
|
24
|
+
invoke 'active_record:model', [name], migration: false unless model_exists?
|
25
|
+
|
26
|
+
strategy_class = options.strategy.classify
|
27
|
+
model_path = "app/models/#{file_name}.rb"
|
28
|
+
already_injected = File.open(File.join(destination_root, model_path)).grep(/Tokenable::Strategies/).any?
|
29
|
+
|
30
|
+
if already_injected
|
31
|
+
say_status :skip, 'a strategy is already in this model', :yellow
|
32
|
+
else
|
33
|
+
inject_into_file model_path, " include Tokenable::Strategies::#{strategy_class}\n", after: " < ApplicationRecord\n"
|
34
|
+
end
|
35
|
+
else
|
36
|
+
say_status :failure, "stargery not found (#{options.strategy}). Available: #{list_of_strategies.join(", ")}", :red
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def model_exists?
|
43
|
+
File.exist?(File.join(destination_root, "app/models/#{file_name}.rb"))
|
44
|
+
end
|
45
|
+
|
46
|
+
def routes_file_exists?
|
47
|
+
File.exist?(File.join(destination_root, 'config/routes.rb'))
|
48
|
+
end
|
49
|
+
|
50
|
+
def list_of_strategies
|
51
|
+
Dir.entries(File.expand_path('../../tokenable/strategies', __dir__))
|
52
|
+
.reject { |f| File.directory?(f) }
|
53
|
+
.map { |f| File.basename(f, File.extname(f)) }
|
54
|
+
.compact
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/active_record'
|
4
|
+
|
5
|
+
module Tokenable
|
6
|
+
module Generators
|
7
|
+
class VerifierGenerator < ActiveRecord::Generators::Base
|
8
|
+
source_root File.expand_path('../templates', __dir__)
|
9
|
+
|
10
|
+
def generate_model
|
11
|
+
invoke 'active_record:model', [name], migration: false unless model_exists? && behavior == :invoke
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_to_model
|
15
|
+
model_path = "app/models/#{file_name}.rb"
|
16
|
+
already_injected = File.open(File.join(destination_root, model_path)).grep(/Tokenable::Verifier/).any?
|
17
|
+
|
18
|
+
if already_injected
|
19
|
+
say_status :skip, 'verifier is already in this model', :yellow
|
20
|
+
else
|
21
|
+
inject_into_file "app/models/#{file_name}.rb", " include Tokenable::Verifier\n", after: " < ApplicationRecord\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_migration
|
26
|
+
migration_template 'verifier_migration.rb.erb', "db/migrate/add_tokenable_verifier_to_#{table_name}.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def model_exists?
|
32
|
+
File.exist?(File.join(destination_root, "app/models/#{file_name}.rb"))
|
33
|
+
end
|
34
|
+
|
35
|
+
def migration_version
|
36
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails::VERSION::MAJOR >= 5
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/tokenable/authable.rb
CHANGED
@@ -14,7 +14,7 @@ module Tokenable
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def current_user
|
17
|
-
@current_user ||= user_class.
|
17
|
+
@current_user ||= user_class.find_by(id: jwt_user_id)
|
18
18
|
rescue Tokenable::Unauthorized
|
19
19
|
nil
|
20
20
|
end
|
@@ -42,7 +42,7 @@ module Tokenable
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def token_from_header
|
45
|
-
request.authorization.to_s.split
|
45
|
+
request.authorization.to_s.split.last
|
46
46
|
end
|
47
47
|
|
48
48
|
def token_from_user(user)
|
@@ -56,6 +56,8 @@ module Tokenable
|
|
56
56
|
|
57
57
|
jwt_data[:data][:verifier] = user.current_verifier if verifier_enabled?
|
58
58
|
|
59
|
+
raise Tokenable::Unauthorized, 'No secret key was provided' unless jwt_secret
|
60
|
+
|
59
61
|
JWT.encode(jwt_data, jwt_secret, 'HS256')
|
60
62
|
end
|
61
63
|
|
data/lib/tokenable/config.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
module Tokenable
|
4
4
|
class Config
|
5
5
|
# How long should the token last before it expires?
|
6
|
-
# E.G: Tokenable::Config.lifespan =
|
7
|
-
|
6
|
+
# E.G: Tokenable::Config.lifespan = 14.days
|
7
|
+
# You could set this to nil to disable expiring keys
|
8
|
+
mattr_writer :lifespan, default: -> { 7.days }
|
8
9
|
|
9
10
|
# The secret used by JWT to encode the Token.
|
10
11
|
# We default to Rails secret_key_base
|
@@ -4,9 +4,13 @@ module Tokenable
|
|
4
4
|
class TokensController < ::ActionController::API
|
5
5
|
include Authable
|
6
6
|
|
7
|
+
rescue_from 'Tokenable::Unauthorized' do
|
8
|
+
render json: { error: 'Login failed, please try again.' }, status: 401
|
9
|
+
end
|
10
|
+
|
7
11
|
def create
|
8
|
-
user =
|
9
|
-
raise Tokenable::Unauthorized unless user
|
12
|
+
user = Tokenable::Config.user_class.from_tokenable_params(params)
|
13
|
+
raise Tokenable::Unauthorized, 'No user returned by strategy' unless user
|
10
14
|
|
11
15
|
response = {
|
12
16
|
data: {
|
data/lib/tokenable/engine.rb
CHANGED
@@ -9,7 +9,7 @@ module Tokenable
|
|
9
9
|
def from_tokenable_params(params)
|
10
10
|
email, password = parse_auth_params(params)
|
11
11
|
|
12
|
-
user =
|
12
|
+
user = Tokenable::Config.user_class.find_by(email: email)
|
13
13
|
return nil unless user
|
14
14
|
|
15
15
|
return nil unless user.valid_password?(password)
|
@@ -21,8 +21,8 @@ module Tokenable
|
|
21
21
|
|
22
22
|
def parse_auth_params(params)
|
23
23
|
[
|
24
|
-
params
|
25
|
-
params
|
24
|
+
params[:email],
|
25
|
+
params[:password],
|
26
26
|
]
|
27
27
|
end
|
28
28
|
end
|
@@ -9,7 +9,7 @@ module Tokenable
|
|
9
9
|
def from_tokenable_params(params)
|
10
10
|
email, password = parse_auth_params(params)
|
11
11
|
|
12
|
-
user =
|
12
|
+
user = Tokenable::Config.user_class.find_by(email: email)
|
13
13
|
return nil unless user
|
14
14
|
|
15
15
|
return nil unless user.authenticate(password)
|
@@ -21,8 +21,8 @@ module Tokenable
|
|
21
21
|
|
22
22
|
def parse_auth_params(params)
|
23
23
|
[
|
24
|
-
params
|
25
|
-
params
|
24
|
+
params[:email],
|
25
|
+
params[:password],
|
26
26
|
]
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tokenable
|
4
|
+
module Strategies
|
5
|
+
module Sorcery
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
class_methods do
|
9
|
+
def from_tokenable_params(params)
|
10
|
+
email, password = parse_auth_params(params)
|
11
|
+
|
12
|
+
user = Tokenable::Config.user_class.find_by(email: email)
|
13
|
+
return nil unless user
|
14
|
+
|
15
|
+
return nil unless user.valid_password?(password)
|
16
|
+
|
17
|
+
user
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def parse_auth_params(params)
|
23
|
+
[
|
24
|
+
params[:email],
|
25
|
+
params[:password],
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/tokenable/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tokenable-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Qualie
|
8
8
|
- Scott Robertson
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-01-
|
12
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jwt
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '6.2'
|
54
|
-
description:
|
54
|
+
description:
|
55
55
|
email:
|
56
56
|
- marc@marcqualie.com
|
57
57
|
- scott@scottrobertson.me
|
@@ -61,7 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".github/workflows/publish.yml"
|
63
63
|
- ".github/workflows/rubocop.yml"
|
64
|
-
- ".github/workflows/
|
64
|
+
- ".github/workflows/tests.yml"
|
65
65
|
- ".gitignore"
|
66
66
|
- ".rspec"
|
67
67
|
- ".rubocop.yml"
|
@@ -73,6 +73,12 @@ files:
|
|
73
73
|
- bin/console
|
74
74
|
- bin/setup
|
75
75
|
- config/routes.rb
|
76
|
+
- lib/generators/templates/routes.rb.erb
|
77
|
+
- lib/generators/templates/tokenable.rb.erb
|
78
|
+
- lib/generators/templates/verifier_migration.rb.erb
|
79
|
+
- lib/generators/tokenable/install_generator.rb
|
80
|
+
- lib/generators/tokenable/verifier_generator.rb
|
81
|
+
- lib/tokenable-ruby.rb
|
76
82
|
- lib/tokenable.rb
|
77
83
|
- lib/tokenable/authable.rb
|
78
84
|
- lib/tokenable/config.rb
|
@@ -81,6 +87,7 @@ files:
|
|
81
87
|
- lib/tokenable/railtie.rb
|
82
88
|
- lib/tokenable/strategies/devise.rb
|
83
89
|
- lib/tokenable/strategies/secure_password.rb
|
90
|
+
- lib/tokenable/strategies/sorcery.rb
|
84
91
|
- lib/tokenable/verifier.rb
|
85
92
|
- lib/tokenable/version.rb
|
86
93
|
- tokenable-ruby.gemspec
|
@@ -91,7 +98,7 @@ metadata:
|
|
91
98
|
homepage_uri: https://github.com/tokenable/tokenable-ruby
|
92
99
|
source_code_uri: https://github.com/tokenable/tokenable-ruby
|
93
100
|
changelog_uri: https://github.com/tokenable/tokenable-ruby/releases
|
94
|
-
post_install_message:
|
101
|
+
post_install_message:
|
95
102
|
rdoc_options: []
|
96
103
|
require_paths:
|
97
104
|
- lib
|
@@ -106,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
113
|
- !ruby/object:Gem::Version
|
107
114
|
version: '0'
|
108
115
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
110
|
-
signing_key:
|
116
|
+
rubygems_version: 3.0.3
|
117
|
+
signing_key:
|
111
118
|
specification_version: 4
|
112
119
|
summary: JWT authentication for Rails API's
|
113
120
|
test_files: []
|