Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 174 lines (116 sloc) 4.774 kb
c0ccb58 @blt04 Update README
blt04 authored
1 Authlogic Crowd
2 ===============
3
4 Authlogic Crowd is an extension of the Authlogic library to add Atlassian Crowd
5 support. We have only tested this plugin with Authlogic 2.x and Rails 2.x.
6
7
8 ## Installation
9
10 Add the gem to your Gemfile:
11
12 gem 'authlogic_crowd'
13
14 and run `bundle`.
15
16
17 ## Configuration
18
19 In your model class, add Crowd configuration:
20
21 class User < ActiveRecord::Base
22 acts_as_authentic do |c|
23 c.crowd_service_url = "http://mycrowdapp:8095/crowd"
24 c.crowd_app_name = "testapp"
25 c.crowd_app_password = "testpass"
26 end
27 end
28
29
30 ## Usage
31
32 When a user logs in via your existing login form, the user's credentials will
33 be authenticated with Crowd. authlogic_crowd will also authenticate users with
34 an existing Crowd token_key cookie.
35
36 authlogic_crowd acts as an *additional* authentication plugin. Other
37 authentication plugins will be tried in the order in which they were
38 registered. Thus, if your model contains password fields used by the
39 built-in `Password` authentication module, Authlogic will attempt to
40 authenticate via local passwords first. If this fails, it will move on to
41 authenticate via Crowd. If you want to skip internal password checking, you
42 should set internal password fields to `nil`.
43
44
45 ### Re-authenticate Every x Seconds
46
47 By default, authlogic_crowd authenticates the Crowd token key cookie on every
48 request. You can tell the module to cache authentication and only
49 re-authenticate periodically using *crowd_auth_every*:
50
51 class UserSession < Authlogic::Session::Base
52 crowd_auth_every 10.minutes
53 end
54
55
56 ### Auto Registration
57
537b234 @blt04 Simplify synchronizer calls
blt04 authored
58 When a Crowd user logs in with no corresponding local user, a new local user
59 will be added by default. You can disable auto-registration with the
60 `auto_register` setting in your Authlogic session:
c0ccb58 @blt04 Update README
blt04 authored
61
62 class UserSession < Authlogic::Session::Base
63 auto_register false
64 end
65
66
67 ### Auto Add Crowd Records
68
69 When a new local user is added, authlogic_crowd can add a corresponding user to
537b234 @blt04 Simplify synchronizer calls
blt04 authored
70 Crowd. This is disabled by default. To enable, use the `add_crowd_records`
71 setting:
c0ccb58 @blt04 Update README
blt04 authored
72
73 class User < ActiveRecord::Base
74 acts_as_authentic do |c|
75 c.add_crowd_records = true
76 end
77 end
78
79
537b234 @blt04 Simplify synchronizer calls
blt04 authored
80 ### Auto Update Crowd Records
81
82 When a local user is updated, authlogic_crowd will update the corresponding
83 Crowd user. This is enabled by default. To disable, use the
84 `update_crowd_records` setting:
85
86 class User < ActiveRecord::Base
87 acts_as_authentic do |c|
88 c.update_crowd_records = false
89 end
90 end
91
92
c0ccb58 @blt04 Update README
blt04 authored
93 ### Disable Crowd
94
95 If you need to disable Crowd (in testing for example), use the `crowd_enabled`
96 setting:
97
98 class User < ActiveRecord::Base
99 acts_as_authentic do |c|
100 c.crowd_enabled = false
101 end
102 end
103
104
105 ## Callbacks
106
107 authlogic_crowd adds several callbacks that can be used to customize the
108 plugin. Callbacks execute in the following order:
109
110 before_create_from_crowd
111 before_sync_from_crowd
112 sync_from_crowd
113 after_sync_from_crowd
114 after_create_from_crowd
115
116 before_create_crowd_record
117 before_sync_to_crowd
118 sync_to_crowd
119 after_sync_to_crowd
120 after_create_crowd_record
121
537b234 @blt04 Simplify synchronizer calls
blt04 authored
122
c0ccb58 @blt04 Update README
blt04 authored
123 ### before_sync_from_crowd, sync_from_crowd, after_sync_from_crowd
124
125 Called whenever a local record should be synchronized from Crowd. Each time a
126 user logs in to your application via Crowd (with login credentials or the
127 token_key cookie), the local user record is synchronized with the Crowd record.
128
129 For example:
130
131 class User < ActiveRecord::Base
132 acts_as_authentic do |c|
133 c.sync_from_crowd :update_from_crowd_record
134 end
135
136 def update_from_crowd_record
137 self.email = self.crowd_record.email
138 self.name = self.crowd_record.first_name + ' ' + self.crowd_record.last_name
139 end
140 end
141
537b234 @blt04 Simplify synchronizer calls
blt04 authored
142
c0ccb58 @blt04 Update README
blt04 authored
143 ### before_sync_to_crowd, sync_to_crowd, after_sync_to_crowd
144
145 Called whenever Crowd should be synchornized from a local record.
146
537b234 @blt04 Simplify synchronizer calls
blt04 authored
147 For example:
148
149 class User < ActiveRecord::Base
150 acts_as_authentic do |c|
151 c.sync_to_crowd :update_crowd_record
152 end
153
154 def update_crowd_record
155 self.crowd_record = self.email
156 self.crowd_record.display_name = self.name
157 self.crowd_record.first_name = self.first_name
158 self.crowd_record.last_name = self.last_name
159 end
160 end
161
162
c0ccb58 @blt04 Update README
blt04 authored
163 ### before_create_from_crowd, after_create_from_crowd
164
165 Called when creating a new local record from a crowd record. When
166 auto-registration is enabled new local users will be created automatically
167 when existing Crowd users log in to your application.
168
537b234 @blt04 Simplify synchronizer calls
blt04 authored
169
c0ccb58 @blt04 Update README
blt04 authored
170 ### before_create_crowd_record, after_create_crowd_record
171
172 Called when creating a new crowd record from a new local record. These
173 callbacks are only executed if the `add_crowd_records` setting is enabled.
Something went wrong with that request. Please try again.