challah 1.5.0 → 1.6.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/CHANGELOG.md +8 -0
- data/README.md +3 -3
- data/VERSION +1 -1
- data/lib/challah/techniques/token_technique.rb +2 -0
- data/lib/generators/challah_generator.rb +23 -0
- data/{db/migrate/20120127150433_create_users.rb → lib/generators/templates/migration.rb} +19 -4
- data/lib/tasks/setup.rake +7 -3
- metadata +9 -9
- data/db/migrate/20121116210759_create_authorizations.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c5d55264692dddf543d5c67c2590a56ca95ba7e
|
4
|
+
data.tar.gz: f1c1b7db86c25987bc4ec369a9928a6ff6a2043a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d518430ab8db7e27eb0bfd6ef23681b7d49af39eb20baf77c88b1ae6d403db85e4a972e0b852e9408800e9dba5323a345d9fff85c3930d5025a87c730d53ae
|
7
|
+
data.tar.gz: 272d606557225f242aa605c09e4ac76a62d5e19e8672b0861abe71a2eee10c97c55a48958b7468f25d0876f6370ed864ad99379561238860188357816e2c7091
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## Challah 1.6.0
|
2
|
+
|
3
|
+
* For token technique, don't bother checking the database for an empty token query param
|
4
|
+
* Add migration generator to account for Rails 5 migration inheritance syntax (`ActiveRecord::Migration[5.1]`)
|
5
|
+
* Minor testing updates
|
6
|
+
* Dependency updates, including renaming FactoryGirl to FactoryBot
|
7
|
+
* Readme typo [PR #32](https://github.com/jdtornow/challah/pull/34) @stevenschobert
|
8
|
+
|
1
9
|
## Challah 1.5.0
|
2
10
|
|
3
11
|
* Extract status enum to separate concern [PR #32](https://github.com/jdtornow/challah/pull/32) @philtr
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Challah doesn't provide any fancy controllers or views that clutter your app or
|
|
10
10
|
|
11
11
|
* Ruby 2.2.2+
|
12
12
|
* Bundler
|
13
|
-
* Rails
|
13
|
+
* Rails 5.0+ (4.2 still supported, but not recommended)
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -35,7 +35,7 @@ This will copy over the necessary migrations to your app and migrate the databas
|
|
35
35
|
If you would prefer to handle these steps manually, you can do so by using these rake tasks instead:
|
36
36
|
|
37
37
|
```bash
|
38
|
-
rails challah
|
38
|
+
rails g challah
|
39
39
|
rails challah:unpack:user
|
40
40
|
rails db:migrate
|
41
41
|
```
|
@@ -253,7 +253,7 @@ By default, the `first_name`, `last_name`, and `email` fields are required on th
|
|
253
253
|
|
254
254
|
```ruby
|
255
255
|
# in config/initializers/challah.rb
|
256
|
-
Challah[:skip_user_validations] = true
|
256
|
+
Challah.options[:skip_user_validations] = true
|
257
257
|
```
|
258
258
|
|
259
259
|
## Authorization Model
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.6.0
|
@@ -18,6 +18,8 @@ module Challah
|
|
18
18
|
# This is turned off by default and must be manually enabled for security reasons.
|
19
19
|
return nil unless Challah.options[:token_enabled]
|
20
20
|
|
21
|
+
return nil unless token.present?
|
22
|
+
|
21
23
|
if user = user_model.where(api_key: token).first
|
22
24
|
if user.valid_session?
|
23
25
|
return user
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rails/generators/active_record"
|
2
|
+
|
3
|
+
class ChallahGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
include ActiveRecord::Generators::Migration
|
6
|
+
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
|
9
|
+
def copy_migration
|
10
|
+
migration_template "migration.rb", "db/migrate/challah_create_users.rb", migration_version: migration_version
|
11
|
+
end
|
12
|
+
|
13
|
+
def rails5?
|
14
|
+
Rails.version.start_with? "5"
|
15
|
+
end
|
16
|
+
|
17
|
+
def migration_version
|
18
|
+
if rails5?
|
19
|
+
"[#{ Rails::VERSION::MAJOR }.#{ Rails::VERSION::MINOR }]"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
class
|
2
|
-
|
1
|
+
class ChallahCreateUsers < ActiveRecord::Migration<%= migration_version %>
|
3
2
|
def change
|
4
|
-
|
3
|
+
create_table :users do |t|
|
5
4
|
t.string :first_name
|
6
5
|
t.string :last_name
|
7
6
|
t.string :email
|
@@ -24,6 +23,22 @@ class CreateUsers < ActiveRecord::Migration
|
|
24
23
|
add_index :users, :last_name
|
25
24
|
add_index :users, :email
|
26
25
|
add_index :users, :api_key
|
27
|
-
end
|
28
26
|
|
27
|
+
create_table :authorizations do |t|
|
28
|
+
t.integer :user_id
|
29
|
+
t.string :provider, limit: 50
|
30
|
+
t.string :uid
|
31
|
+
t.string :token, limit: 500
|
32
|
+
t.datetime :expires_at
|
33
|
+
t.datetime :last_session_at
|
34
|
+
t.string :last_session_ip
|
35
|
+
t.integer :session_count, default: 0
|
36
|
+
t.timestamps null: true
|
37
|
+
end
|
38
|
+
|
39
|
+
add_index :authorizations, :user_id
|
40
|
+
add_index :authorizations, [ :user_id, :provider ]
|
41
|
+
add_index :authorizations, :uid
|
42
|
+
add_index :authorizations, :token
|
43
|
+
end
|
29
44
|
end
|
data/lib/tasks/setup.rake
CHANGED
@@ -3,6 +3,10 @@ namespace :challah do
|
|
3
3
|
task :setup => [ "challah:setup:migrations", "challah:unpack:user", "db:migrate", "challah:banner" ]
|
4
4
|
|
5
5
|
task :banner do
|
6
|
+
is_rails5 = Rails.version.start_with? "5"
|
7
|
+
|
8
|
+
cmd = is_rails5 ? "rails" : "rake"
|
9
|
+
|
6
10
|
banner = <<-str
|
7
11
|
|
8
12
|
==========================================================================
|
@@ -15,7 +19,7 @@ namespace :challah do
|
|
15
19
|
|
16
20
|
If you want to create a new user now, just run:
|
17
21
|
|
18
|
-
|
22
|
+
#{ cmd } challah:users:create
|
19
23
|
|
20
24
|
==========================================================================
|
21
25
|
|
@@ -26,8 +30,8 @@ namespace :challah do
|
|
26
30
|
|
27
31
|
namespace :setup do
|
28
32
|
task :migrations do
|
29
|
-
puts "
|
30
|
-
|
33
|
+
puts "Setting up migrations..."
|
34
|
+
sh "rails generate challah"
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: challah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Tornow
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|
@@ -80,28 +80,28 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '3.
|
83
|
+
version: '3.7'
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '3.
|
90
|
+
version: '3.7'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
92
|
+
name: factory_bot_rails
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '4.
|
97
|
+
version: '4.8'
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '4.
|
104
|
+
version: '4.8'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: sqlite3
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,8 +134,6 @@ files:
|
|
134
134
|
- app/views/sessions/access_denied.html.erb
|
135
135
|
- app/views/sessions/new.html.erb
|
136
136
|
- config/locales/en.yml
|
137
|
-
- db/migrate/20120127150433_create_users.rb
|
138
|
-
- db/migrate/20121116210759_create_authorizations.rb
|
139
137
|
- lib/challah.rb
|
140
138
|
- lib/challah/audit.rb
|
141
139
|
- lib/challah/authenticators.rb
|
@@ -171,6 +169,8 @@ files:
|
|
171
169
|
- lib/challah/validators/email_validator.rb
|
172
170
|
- lib/challah/validators/password_validator.rb
|
173
171
|
- lib/challah/version.rb
|
172
|
+
- lib/generators/challah_generator.rb
|
173
|
+
- lib/generators/templates/migration.rb
|
174
174
|
- lib/tasks/crud.rake
|
175
175
|
- lib/tasks/setup.rake
|
176
176
|
- lib/tasks/unpack.rake
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class CreateAuthorizations < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def change
|
4
|
-
create_table :authorizations do |t|
|
5
|
-
t.integer :user_id
|
6
|
-
t.string :provider, limit: 50
|
7
|
-
t.string :uid
|
8
|
-
t.string :token, limit: 500
|
9
|
-
t.datetime :expires_at
|
10
|
-
t.datetime :last_session_at
|
11
|
-
t.string :last_session_ip
|
12
|
-
t.integer :session_count, default: 0
|
13
|
-
t.timestamps null: true
|
14
|
-
end
|
15
|
-
|
16
|
-
add_index :authorizations, :user_id
|
17
|
-
add_index :authorizations, [ :user_id, :provider ]
|
18
|
-
add_index :authorizations, :uid
|
19
|
-
add_index :authorizations, :token
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|