checkpoint 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Readme.markdown +12 -2
- data/checkpoint.gemspec +1 -1
- data/lib/checkpoint/railtie.rb +15 -7
- data/lib/checkpoint/version.rb +1 -1
- metadata +4 -7
- data/.Gemfile.swp +0 -0
- data/.Readme.markdown.swp +0 -0
- data/.checkpoint.gemspec.swp +0 -0
data/.gitignore
CHANGED
data/Readme.markdown
CHANGED
@@ -18,7 +18,7 @@ To enable a user to access/use a resource you must specify an authorisation rule
|
|
18
18
|
So if for instance you wanted to grant access (to all users) to your posts index action you could do the following:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
#grant access your posts controller 'index' action to all users
|
21
|
+
#grant access to your posts controller 'index' action to all users
|
22
22
|
authorise "PostsController::index"
|
23
23
|
|
24
24
|
#or authorize "PostsController::index"
|
@@ -51,7 +51,7 @@ authorise /\APostsController::.*\Z/
|
|
51
51
|
If you want to be able to grant access to your view action to only users who have signed in, you can do this by passing a block that returns true if the user is logged in.
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
#grant access your posts controller 'view' action to all users who have signed in
|
54
|
+
#grant access to your posts controller 'view' action to all users who have signed in
|
55
55
|
authorise "PostsController::view" do
|
56
56
|
!current_user.nil?
|
57
57
|
end
|
@@ -85,6 +85,16 @@ end
|
|
85
85
|
authorise "Devise::*"
|
86
86
|
|
87
87
|
```
|
88
|
+
### How do I enable an API Key?
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
#grant access to all controllers in the Api namespace for requests which have the API key as a param
|
92
|
+
authorize "Api::*" do
|
93
|
+
params[:api_key] == API_KEY
|
94
|
+
end
|
95
|
+
|
96
|
+
```
|
97
|
+
|
88
98
|
|
89
99
|
## License
|
90
100
|
|
data/checkpoint.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Checkpoint::VERSION
|
8
8
|
s.authors = ["Leanbid LTD"]
|
9
9
|
s.email = ["it@leanbid.com"]
|
10
|
-
s.homepage = "https://github.com/
|
10
|
+
s.homepage = "https://github.com/digitalfrost/checkpoint"
|
11
11
|
s.summary = "Simple rails authorisation"
|
12
12
|
#s.description = %q{TODO: Write a gem description}
|
13
13
|
s.license = "MIT"
|
data/lib/checkpoint/railtie.rb
CHANGED
@@ -60,17 +60,25 @@ class Checkpoint::Railtie < ::Rails::Railtie
|
|
60
60
|
end
|
61
61
|
false
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
|
64
|
+
def access_denied
|
65
|
+
logger.info "\n\n-----------------------------------------------"
|
66
|
+
logger.info " (401) Access Denied!"
|
67
|
+
logger.info " * see the above request for more info"
|
68
|
+
logger.info "-----------------------------------------------\n\n"
|
69
|
+
render :text => "Access Denied", :status => 401
|
70
|
+
end
|
71
|
+
|
72
|
+
def check_authorized
|
65
73
|
if !authorised?
|
66
|
-
|
67
|
-
logger.info " (401) Access Denied!"
|
68
|
-
logger.info " * see the above request for more info"
|
69
|
-
logger.info "-----------------------------------------------\n\n"
|
70
|
-
render :text => "Access Denied", :status => 401
|
74
|
+
access_denied
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
78
|
+
before_filter do |controller|
|
79
|
+
check_authorized
|
80
|
+
end
|
81
|
+
|
74
82
|
end
|
75
83
|
end
|
76
84
|
end
|
data/lib/checkpoint/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -18,9 +18,6 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .Gemfile.swp
|
22
|
-
- .Readme.markdown.swp
|
23
|
-
- .checkpoint.gemspec.swp
|
24
21
|
- .gitignore
|
25
22
|
- Gemfile
|
26
23
|
- Rakefile
|
@@ -29,7 +26,7 @@ files:
|
|
29
26
|
- lib/checkpoint.rb
|
30
27
|
- lib/checkpoint/railtie.rb
|
31
28
|
- lib/checkpoint/version.rb
|
32
|
-
homepage: https://github.com/
|
29
|
+
homepage: https://github.com/digitalfrost/checkpoint
|
33
30
|
licenses:
|
34
31
|
- MIT
|
35
32
|
post_install_message:
|
@@ -50,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
47
|
version: '0'
|
51
48
|
requirements: []
|
52
49
|
rubyforge_project: checkpoint
|
53
|
-
rubygems_version: 1.8.
|
50
|
+
rubygems_version: 1.8.24
|
54
51
|
signing_key:
|
55
52
|
specification_version: 3
|
56
53
|
summary: Simple rails authorisation
|
data/.Gemfile.swp
DELETED
Binary file
|
data/.Readme.markdown.swp
DELETED
Binary file
|
data/.checkpoint.gemspec.swp
DELETED
Binary file
|