simple-auth 0.2.5 → 0.3.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.
- data/LICENSE +2 -0
- data/README.md +99 -1
- data/VERSION +1 -1
- data/simple-auth.gemspec +1 -1
- metadata +4 -4
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,103 @@
|
|
1
1
|
simple-auth
|
2
2
|
===========
|
3
3
|
|
4
|
-
|
4
|
+
simple-auth is a simple authentication library for applications that run under the same domain.
|
5
|
+
|
6
|
+
simple-auth can be used with any authentication provider, like - Authlogic, Devise, Restful Authentication,
|
7
|
+
and any others that use cookie based authentication.
|
8
|
+
|
9
|
+
simple-auth can be used to redirect a browser application to the authentication provider for login and session management.
|
10
|
+
|
11
|
+
simple-auth can also be used to recieve persistent tokens from the authenticator application,
|
12
|
+
which in turn can be used to make requests on behalf of a user even when they are logged off.
|
13
|
+
|
14
|
+
Sample Configuration
|
15
|
+
====================
|
16
|
+
|
17
|
+
simple-auth authenticator host and paths can be configured for multiple environments as shown below.
|
18
|
+
|
19
|
+
SimpleAuth.configure do
|
20
|
+
host do
|
21
|
+
development 'test.domain.local'
|
22
|
+
test 'test.domain.local'
|
23
|
+
production 'test.domain.local'
|
24
|
+
end
|
25
|
+
|
26
|
+
paths do
|
27
|
+
login 'login'
|
28
|
+
logout 'logout'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
In the example configuration above, simple-auth configures "test.domain.local" as the host of the authenticator application.
|
33
|
+
|
34
|
+
The #host method is the helper to set the authenticator host for multiple environments.
|
35
|
+
|
36
|
+
host do
|
37
|
+
development 'development.domain.local'
|
38
|
+
test 'test.domain.local'
|
39
|
+
end
|
40
|
+
|
41
|
+
The #paths method is the helper to set the relative paths for endpoints in the authenticator application.
|
42
|
+
|
43
|
+
paths do
|
44
|
+
login 'login'
|
45
|
+
logout 'logout'
|
46
|
+
end
|
47
|
+
|
48
|
+
This example sets the login and logout paths in the authenticator application.
|
49
|
+
These endpoints can now be accessed in the consumer application just as rails routes.
|
50
|
+
|
51
|
+
login_path, login_url
|
52
|
+
logout_path, logout_url
|
53
|
+
|
54
|
+
As a bonus, you can also use the configuration to setup non authentication related paths.
|
55
|
+
|
56
|
+
paths do
|
57
|
+
logo 'images/logo.png'
|
58
|
+
end
|
59
|
+
|
60
|
+
logo_path, logo_url
|
61
|
+
|
62
|
+
This is a contrived example, but you get the point ...
|
63
|
+
|
64
|
+
Usage
|
65
|
+
=====
|
66
|
+
|
67
|
+
In the consumer application, set up your Gemfile to use the simple-auth gem.
|
68
|
+
|
69
|
+
gem 'simple-auth', :require => 'simple_auth'
|
70
|
+
|
71
|
+
Run 'bundle install', and you should have the following helpers available in your controllers and views.
|
72
|
+
|
73
|
+
* #api - A RestClient::Resource instance pointing to the host endopoint.
|
74
|
+
* #login - The #login method uses the cookie in the browser request to authenticate the user, and follow redirection from the authenticator application.
|
75
|
+
|
76
|
+
Controller Usage
|
77
|
+
================
|
78
|
+
|
79
|
+
To use the simple-auth gem to redirect to an endpoint in the authenticator application enforced by a before filter, you can use a before filter in the consumer application.
|
80
|
+
|
81
|
+
before_filter :require_login
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def require_login
|
86
|
+
login unless current_user
|
87
|
+
end
|
88
|
+
|
89
|
+
You could choose not to save the session returned in the consumer application, however, all you requests will be authenticated and so will effect performance.
|
90
|
+
|
91
|
+
Pre-Requisite
|
92
|
+
=============
|
93
|
+
|
94
|
+
The authenticator application should define a route for a method #show in the user sessions controller. This method can return the desired session information and enforce authorization rules.
|
95
|
+
|
96
|
+
class UserSessionsController
|
97
|
+
def show
|
98
|
+
render :json => { :session => 'secret' }
|
99
|
+
end
|
100
|
+
end
|
5
101
|
|
6
102
|
Note on Patches/Pull Requests
|
7
103
|
=============================
|
@@ -17,6 +113,8 @@ Note on Patches/Pull Requests
|
|
17
113
|
Copyright
|
18
114
|
=========
|
19
115
|
|
116
|
+
Copyright (c) 2010 Umang Chouhan
|
117
|
+
Copyright (c) 2010 Ehren Murdick
|
20
118
|
Copyright (c) 2010 OptimisCorp.
|
21
119
|
|
22
120
|
See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/simple-auth.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Umang Chouhan
|