simple_admin_auth 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +27 -1
- data/config.ru +23 -0
- data/lib/simple_admin_auth/rack.rb +17 -0
- data/lib/simple_admin_auth/version.rb +1 -1
- metadata +15 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 98c29dd68bd81a74dea530e3ea8ca8ba68269af6
|
4
|
+
data.tar.gz: 4cd9263c01366f771ef4f5d393907d5822a4425f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea4985da24de96b94f27ec7574c8ab4b0afbf17559ec5efae1ec7916ba299c83ee7ba580cf30e548db108223c095172ea1794a6ec3925db595a7c5a1ed88884a
|
7
|
+
data.tar.gz: ee994b9bc4c4e9ce25c0c8553771478d108bac033dc51164af2dc81563fae59d9e7cc5101caad9978df288561e682ef8d447f0ac2a9f1e30e29411c36c31a9dc
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Add simple admin authentication to any Rails application, using Google Apps for
|
|
4
4
|
|
5
5
|
Authentication is done purely on the Google Apps domain - no user model is used.
|
6
6
|
|
7
|
-
## Usage
|
7
|
+
## Usage with Rails 3.x
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
@@ -24,6 +24,32 @@ Protect any routes that require authentication:
|
|
24
24
|
|
25
25
|
An user may be logged out by linking to `/auth/admin/logout`, or by clearing `session[:admin_user]`.
|
26
26
|
|
27
|
+
## Usage with Sinatra/Rack-based apps
|
28
|
+
|
29
|
+
require 'rack/builder'
|
30
|
+
require 'simple_admin_auth'
|
31
|
+
require 'simple_admin_auth/rack'
|
32
|
+
|
33
|
+
app = Rack::Builder.new do
|
34
|
+
use Rack::Session::Cookie, secret: 'change_me'
|
35
|
+
|
36
|
+
use SimpleAdminAuth::Builder do
|
37
|
+
provider :google_apps, :domain => 'yourdomain.com', :name => 'admin'
|
38
|
+
end
|
39
|
+
|
40
|
+
map "/your_protected_area" do
|
41
|
+
use SimpleAdminAuth::Rack
|
42
|
+
run YourProtectedArea.new
|
43
|
+
end
|
44
|
+
|
45
|
+
map "/" do
|
46
|
+
use SimpleAdminAuth::Application
|
47
|
+
run YourMainSite.new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
run app
|
52
|
+
|
27
53
|
|
28
54
|
## Contributing
|
29
55
|
|
data/config.ru
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rack/builder'
|
2
|
+
require 'simple_admin_auth'
|
3
|
+
require 'simple_admin_auth/rack'
|
4
|
+
|
5
|
+
app = Rack::Builder.new do
|
6
|
+
use Rack::Session::Cookie, secret: 'your_secret_here'
|
7
|
+
|
8
|
+
use SimpleAdminAuth::Builder do
|
9
|
+
provider :google_apps, :domain => 'embarkmobile.com', :name => 'admin'
|
10
|
+
end
|
11
|
+
|
12
|
+
map "/admin" do
|
13
|
+
use SimpleAdminAuth::Rack
|
14
|
+
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['Welcome, you have been authenticated!']] }
|
15
|
+
end
|
16
|
+
|
17
|
+
map "/" do
|
18
|
+
use SimpleAdminAuth::Application
|
19
|
+
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['Main site']] }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
run app
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SimpleAdminAuth
|
2
|
+
class Rack
|
3
|
+
def initialize(app, options={})
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
if env['rack.session'][:admin_user]
|
9
|
+
@app.call(env)
|
10
|
+
else
|
11
|
+
redirect_to = env['SCRIPT_NAME'] + env['PATH_INFO']
|
12
|
+
env['rack.session'][:admin_login_return_url] = redirect_to
|
13
|
+
[302, {"Content-Type"=>"text/plain", "Location" => '/auth/admin/login'}, ["Redirecting..."]]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_admin_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ralf Kistner
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: omniauth
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: omniauth-google-apps
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: sinatra
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Add simple admin authentication to any Rails application, using Google
|
@@ -72,37 +65,37 @@ files:
|
|
72
65
|
- LICENSE.txt
|
73
66
|
- README.md
|
74
67
|
- Rakefile
|
68
|
+
- config.ru
|
75
69
|
- lib/simple_admin_auth.rb
|
76
70
|
- lib/simple_admin_auth/application.rb
|
77
71
|
- lib/simple_admin_auth/authenticated.rb
|
78
72
|
- lib/simple_admin_auth/builder.rb
|
79
73
|
- lib/simple_admin_auth/login_redirect.rb
|
74
|
+
- lib/simple_admin_auth/rack.rb
|
80
75
|
- lib/simple_admin_auth/version.rb
|
81
76
|
- simple_admin_auth.gemspec
|
82
77
|
- static/css/bootstrap.min.css
|
83
78
|
homepage: ''
|
84
79
|
licenses: []
|
80
|
+
metadata: {}
|
85
81
|
post_install_message:
|
86
82
|
rdoc_options: []
|
87
83
|
require_paths:
|
88
84
|
- lib
|
89
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
86
|
requirements:
|
92
|
-
- -
|
87
|
+
- - '>='
|
93
88
|
- !ruby/object:Gem::Version
|
94
89
|
version: '0'
|
95
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
91
|
requirements:
|
98
|
-
- -
|
92
|
+
- - '>='
|
99
93
|
- !ruby/object:Gem::Version
|
100
94
|
version: '0'
|
101
95
|
requirements: []
|
102
96
|
rubyforge_project:
|
103
|
-
rubygems_version:
|
97
|
+
rubygems_version: 2.0.3
|
104
98
|
signing_key:
|
105
|
-
specification_version:
|
99
|
+
specification_version: 4
|
106
100
|
summary: Simple admin authentication using Google Apps
|
107
101
|
test_files: []
|
108
|
-
has_rdoc:
|