challah 1.2.11 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -15
- data/VERSION +1 -1
- data/app/controllers/sessions_controller.rb +7 -1
- data/db/migrate/20120127150433_create_users.rb +3 -5
- data/db/migrate/20121116210759_create_authorizations.rb +2 -0
- data/lib/challah/controller.rb +11 -5
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3d6fd80f0638cb01d51f3160c92792a9d12924c
|
4
|
+
data.tar.gz: 0641b3c92b52c2f8c3e9b1cf47c11c7fa55b6e7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98dbd14406c791f07ee32a0f053100949cc90ad4dfa33d59a8c2c3e9094bc984c1348ea2e40d7039dec8ee935e0886ca54eb3b110e46146f1c69fc12a3aab9ce
|
7
|
+
data.tar.gz: 719ddddb95e07ce9036b22d04f28132e35a2465f23caaa32f695f4cc6f163c4f43d315b96c680716371e0f8f3575cd1b8db2ab8195e77e1b73c375563393a205
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Challah
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/jdtornow/challah.svg?branch=master)](https://travis-ci.org/jdtornow/challah) [![Code Climate](https://codeclimate.com/github/jdtornow/challah.
|
3
|
+
[![Build Status](https://travis-ci.org/jdtornow/challah.svg?branch=master)](https://travis-ci.org/jdtornow/challah) [![Code Climate](https://codeclimate.com/github/jdtornow/challah/badges/gpa.svg)](https://codeclimate.com/github/jdtornow/challah) [![Dependency Status](https://gemnasium.com/jdtornow/challah.svg)](https://gemnasium.com/jdtornow/challah) [![Gem Version](https://badge.fury.io/rb/challah.svg)](https://badge.fury.io/rb/challah)
|
4
4
|
|
5
5
|
Challah (pronounced HAH-lah) is a simple Rails authentication gem that provides users a way to authenticate with your app. Most of the functionality within the gem lives within a Rails engine and tries to stay out of the way of your app.
|
6
6
|
|
@@ -8,16 +8,16 @@ Challah doesn’t provide any fancy controllers or views that clutter your app o
|
|
8
8
|
|
9
9
|
## Requirements
|
10
10
|
|
11
|
-
* Ruby 1.
|
11
|
+
* Ruby 2.1.2+
|
12
12
|
* Bundler
|
13
|
-
* Rails 4.
|
13
|
+
* Rails 4.2+
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
17
17
|
In your `Gemfile`
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
gem
|
20
|
+
gem "challah"
|
21
21
|
```
|
22
22
|
|
23
23
|
## Set up
|
@@ -71,11 +71,11 @@ For example, restrict the second list item to only users that have logged in:
|
|
71
71
|
</ul>
|
72
72
|
```
|
73
73
|
|
74
|
-
Controllers can also be restricted using `
|
74
|
+
Controllers can also be restricted using `before_action`:
|
75
75
|
|
76
76
|
```ruby
|
77
77
|
class WidgetsController < ApplicationController
|
78
|
-
|
78
|
+
before_action :signin_required
|
79
79
|
|
80
80
|
# ...
|
81
81
|
end
|
@@ -91,7 +91,7 @@ class WidgetsController < ApplicationController
|
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
94
|
-
All normal Rails `
|
94
|
+
All normal Rails `before_action` options apply, so you can always limit this restriction to a specific action:
|
95
95
|
|
96
96
|
|
97
97
|
```ruby
|
@@ -116,8 +116,6 @@ If you’d prefer to set up your own “sign in” and “sign out” actions, y
|
|
116
116
|
|
117
117
|
Challah.options[:skip_routes] = true
|
118
118
|
|
119
|
-
Note: These routes have changed from previous versions of Challah. `signin_path` and `signout_path` are now the preferred routes, instead of the legacy `login_path` and `logout_path`. However, the legacy routes still remain for backward compatibility.
|
120
|
-
|
121
119
|
## Sign In Form
|
122
120
|
|
123
121
|
By default, the sign in form is tucked away within the Challah gem. If you’d like to customize the markup or functionality of the sign in form, you can unpack it into your app by running:
|
@@ -132,12 +130,6 @@ If necessary, the sessions controller which handles creating new sessions and si
|
|
132
130
|
|
133
131
|
Documentation is available at: [http://rubydoc.info/gems/challah](http://rubydoc.info/gems/challah)
|
134
132
|
|
135
|
-
## Example App
|
136
|
-
|
137
|
-
A fully-functional example app, complete with some basic tests, is available at [http://challah-example.herokuapp.com/](http://challah-example.herokuapp.com/).
|
138
|
-
|
139
|
-
The source code to the example is available at [https://github.com/jdtornow/challah-example](https://github.com/jdtornow/challah-example).
|
140
|
-
|
141
133
|
### Issues
|
142
134
|
|
143
135
|
If you have any issues or find bugs running Challah, please [report them on Github](https://github.com/jdtornow/challah/issues). While most functions should be stable, Challah is still in its infancy and certain issues may be present.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
@@ -1,6 +1,12 @@
|
|
1
1
|
if defined?(ApplicationController)
|
2
2
|
class SessionsController < ApplicationController
|
3
|
-
|
3
|
+
if respond_to?(:before_action)
|
4
|
+
# Rails >= 4.0
|
5
|
+
before_action :destroy_session, except: :create
|
6
|
+
else
|
7
|
+
# Rails <= 3.2
|
8
|
+
before_filter :destroy_session, except: :create
|
9
|
+
end
|
4
10
|
|
5
11
|
unloadable
|
6
12
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class CreateUsers < ActiveRecord::Migration
|
2
|
-
|
2
|
+
|
3
|
+
def change
|
3
4
|
create_table :users do |t|
|
4
5
|
t.string :first_name
|
5
6
|
t.string :last_name
|
@@ -27,7 +28,4 @@ class CreateUsers < ActiveRecord::Migration
|
|
27
28
|
add_index :users, :role_id
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
-
drop_table :users
|
32
|
-
end
|
33
|
-
end
|
31
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class CreateAuthorizations < ActiveRecord::Migration
|
2
|
+
|
2
3
|
def change
|
3
4
|
create_table :authorizations do |t|
|
4
5
|
t.integer :user_id
|
@@ -17,4 +18,5 @@ class CreateAuthorizations < ActiveRecord::Migration
|
|
17
18
|
add_index :authorizations, :uid
|
18
19
|
add_index :authorizations, :token
|
19
20
|
end
|
21
|
+
|
20
22
|
end
|
data/lib/challah/controller.rb
CHANGED
@@ -11,7 +11,7 @@ module Challah
|
|
11
11
|
module ClassMethods
|
12
12
|
# Restrict the current controller to only users that have authenticated. All actions
|
13
13
|
# in the controller will be restricted unless otherwise stated. All normal options
|
14
|
-
# for a
|
14
|
+
# for a before_action are observed.
|
15
15
|
#
|
16
16
|
# @example
|
17
17
|
# class YourController < ApplicationController
|
@@ -29,8 +29,14 @@ module Challah
|
|
29
29
|
#
|
30
30
|
# @see Controller::InstanceMethods#signin_required signin_required
|
31
31
|
def restrict_to_authenticated(options = {})
|
32
|
-
|
33
|
-
|
32
|
+
block = proc { |controller| controller.send(:signin_required) }
|
33
|
+
|
34
|
+
if respond_to?(:before_action)
|
35
|
+
# Rails >= 4.0
|
36
|
+
before_action(options, &block)
|
37
|
+
else
|
38
|
+
# Rails <= 3.2
|
39
|
+
before_filter(options, &block)
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
@@ -90,14 +96,14 @@ module Challah
|
|
90
96
|
#
|
91
97
|
# @example
|
92
98
|
# class YourController < ApplicationController
|
93
|
-
#
|
99
|
+
# before_action :login_required
|
94
100
|
#
|
95
101
|
# # ...
|
96
102
|
# end
|
97
103
|
#
|
98
104
|
# @example Specifing certain actions.
|
99
105
|
# class YourOtherController < ApplicationController
|
100
|
-
#
|
106
|
+
# before_action :login_required, :only => [ :create, :update, :destroy ]
|
101
107
|
#
|
102
108
|
# # ...
|
103
109
|
# 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.3.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:
|
13
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|
@@ -36,16 +36,16 @@ dependencies:
|
|
36
36
|
name: rails
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 4.0.0
|
42
42
|
type: :runtime
|
43
43
|
prerelease: false
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 4.0.0
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,28 +80,28 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '3.
|
83
|
+
version: '3.4'
|
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.4'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: factory_girl_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.6'
|
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.6'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: sqlite3
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,7 +173,7 @@ files:
|
|
173
173
|
- lib/tasks/crud.rake
|
174
174
|
- lib/tasks/setup.rake
|
175
175
|
- lib/tasks/unpack.rake
|
176
|
-
homepage:
|
176
|
+
homepage: https://github.com/jdtornow/challah
|
177
177
|
licenses:
|
178
178
|
- MIT
|
179
179
|
metadata: {}
|
@@ -193,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
195
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.4.5.1
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
|
-
summary: Rails
|
199
|
+
summary: Rails authentication and sessions
|
200
200
|
test_files: []
|