pasaporte 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/History.txt +2 -0
  2. data/Manifest.txt +41 -0
  3. data/README.txt +72 -0
  4. data/Rakefile +111 -0
  5. data/TODO.txt +2 -0
  6. data/bin/pasaporte-fcgi.rb +17 -0
  7. data/lib/pasaporte/.DS_Store +0 -0
  8. data/lib/pasaporte/assets/.DS_Store +0 -0
  9. data/lib/pasaporte/assets/bgbar.png +0 -0
  10. data/lib/pasaporte/assets/lock.png +0 -0
  11. data/lib/pasaporte/assets/mainbg_green.gif +0 -0
  12. data/lib/pasaporte/assets/mainbg_red.gif +0 -0
  13. data/lib/pasaporte/assets/openid.png +0 -0
  14. data/lib/pasaporte/assets/pasaporte.css +192 -0
  15. data/lib/pasaporte/assets/pasaporte.js +10 -0
  16. data/lib/pasaporte/assets/user.png +0 -0
  17. data/lib/pasaporte/auth/cascade.rb +16 -0
  18. data/lib/pasaporte/auth/remote_web_workplace.rb +61 -0
  19. data/lib/pasaporte/auth/yaml_digest_table.rb +23 -0
  20. data/lib/pasaporte/auth/yaml_table.rb +43 -0
  21. data/lib/pasaporte/faster_openid.rb +39 -0
  22. data/lib/pasaporte/iso_countries.yml +247 -0
  23. data/lib/pasaporte/julik_state.rb +42 -0
  24. data/lib/pasaporte/markaby_ext.rb +8 -0
  25. data/lib/pasaporte/pasaporte_store.rb +60 -0
  26. data/lib/pasaporte/timezones.yml +797 -0
  27. data/lib/pasaporte.rb +1214 -0
  28. data/test/fixtures/pasaporte_approvals.yml +12 -0
  29. data/test/fixtures/pasaporte_profiles.yml +45 -0
  30. data/test/fixtures/pasaporte_throttles.yml +4 -0
  31. data/test/helper.rb +66 -0
  32. data/test/mosquito.rb +596 -0
  33. data/test/test_approval.rb +33 -0
  34. data/test/test_auth_backends.rb +59 -0
  35. data/test/test_openid.rb +363 -0
  36. data/test/test_pasaporte.rb +326 -0
  37. data/test/test_profile.rb +165 -0
  38. data/test/test_settings.rb +27 -0
  39. data/test/test_throttle.rb +70 -0
  40. data/test/testable_openid_fetcher.rb +82 -0
  41. metadata +151 -0
@@ -0,0 +1,247 @@
1
+ # This has been autogenerated from http://www.iso.org/iso/iso3166_en_code_lists.txt on Fri Sep 14 06:29:24 +0200 2007. See Rakefile for details.
2
+ # This file is bonafide UTF-8 for YAML but do not edit it manually!
3
+ ---
4
+ bs: Bahamas
5
+ hk: Hong Kong
6
+ kh: Cambodia
7
+ bt: Bhutan
8
+ ki: Kiribati
9
+ ne: Niger
10
+ qa: Qatar
11
+ ru: Russian Federation
12
+ us: United States
13
+ hm: Heard Island and Mcdonald Islands
14
+ nf: Norfolk Island
15
+ bv: Bouvet Island
16
+ er: Eritrea
17
+ hn: Honduras
18
+ ng: Nigeria
19
+ rw: Rwanda
20
+ bw: Botswana
21
+ es: Spain
22
+ et: Ethiopia
23
+ ni: Nicaragua
24
+ ad: Andorra
25
+ by: Belarus
26
+ km: Comoros
27
+ ae: United Arab Emirates
28
+ tc: Turks and Caicos Islands
29
+ bz: Belize
30
+ hr: Croatia
31
+ kn: Saint Kitts and Nevis
32
+ af: Afghanistan
33
+ nl: Netherlands
34
+ td: Chad
35
+ uy: Uruguay
36
+ ag: Antigua and Barbuda
37
+ ht: Haiti
38
+ kp: Korea, Democratic People's Republic of
39
+ uz: Uzbekistan
40
+ ga: Gabon
41
+ hu: Hungary
42
+ tf: French Southern Territories
43
+ gb: United Kingdom
44
+ ai: Anguilla
45
+ de: Germany
46
+ kr: Korea, Republic of
47
+ tg: Togo
48
+ "no": Norway
49
+ th: Thailand
50
+ gd: Grenada
51
+ np: Nepal
52
+ za: South Africa
53
+ wf: Wallis and Futuna
54
+ ge: Georgia
55
+ tj: Tajikistan
56
+ al: Albania
57
+ gf: French Guiana
58
+ nr: Nauru
59
+ tk: Tokelau
60
+ am: Armenia
61
+ kw: Kuwait
62
+ tl: Timor-leste
63
+ an: Netherlands Antilles
64
+ dj: Djibouti
65
+ tm: Turkmenistan
66
+ gg: Guernsey
67
+ ao: Angola
68
+ dk: Denmark
69
+ je: Jersey
70
+ ma: Morocco
71
+ ky: Cayman Islands
72
+ nu: Niue
73
+ tn: Tunisia
74
+ gh: Ghana
75
+ kz: Kazakhstan
76
+ to: Tonga
77
+ aq: Antarctica
78
+ dm: Dominica
79
+ gi: Gibraltar
80
+ mc: Monaco
81
+ ar: Argentina
82
+ md: Moldova, Republic of
83
+ as: American Samoa
84
+ do: Dominican Republic
85
+ tr: Turkey
86
+ pa: Panama
87
+ at: Austria
88
+ gl: Greenland
89
+ me: Montenegro
90
+ nz: New Zealand
91
+ au: Australia
92
+ gm: Gambia
93
+ gn: Guinea
94
+ mg: Madagascar
95
+ zm: Zambia
96
+ tt: Trinidad and Tobago
97
+ aw: Aruba
98
+ mh: Marshall Islands
99
+ ax: "\xC3\x85land Islands"
100
+ gp: Guadeloupe
101
+ pe: Peru
102
+ sa: Saudi Arabia
103
+ tv: Tuvalu
104
+ ws: Samoa
105
+ ca: Canada
106
+ gq: Equatorial Guinea
107
+ jm: Jamaica
108
+ pf: French Polynesia
109
+ sb: Solomon Islands
110
+ tw: Taiwan, Province of China
111
+ az: Azerbaijan
112
+ gr: Greece
113
+ mk: Macedonia, the Former Yugoslav Republic of
114
+ pg: Papua New Guinea
115
+ sc: Seychelles
116
+ gs: South Georgia and the South Sandwich Islands
117
+ jo: Jordan
118
+ ml: Mali
119
+ ph: Philippines
120
+ sd: Sudan
121
+ cc: Cocos (keeling) Islands
122
+ gt: Guatemala
123
+ jp: Japan
124
+ se: Sweden
125
+ va: Holy See (vatican City State)
126
+ cd: Congo, the Democratic Republic of the
127
+ gu: Guam
128
+ mm: Myanmar
129
+ tz: Tanzania, United Republic of
130
+ dz: Algeria
131
+ mn: Mongolia
132
+ pk: Pakistan
133
+ sg: Singapore
134
+ vc: Saint Vincent and the Grenadines
135
+ cf: Central African Republic
136
+ gw: Guinea-bissau
137
+ mo: Macao
138
+ pl: Poland
139
+ sh: Saint Helena
140
+ ve: Venezuela
141
+ cg: Congo
142
+ mp: Northern Mariana Islands
143
+ pm: Saint Pierre and Miquelon
144
+ si: Slovenia
145
+ zw: Zimbabwe
146
+ ch: Switzerland
147
+ gy: Guyana
148
+ mq: Martinique
149
+ pn: Pitcairn
150
+ sj: Svalbard and Jan Mayen
151
+ vg: Virgin Islands, British
152
+ ci: Cote D'ivoire
153
+ mr: Mauritania
154
+ sk: Slovakia
155
+ ms: Montserrat
156
+ sl: Sierra Leone
157
+ ye: Yemen
158
+ vi: Virgin Islands, U.S.
159
+ ck: Cook Islands
160
+ id: Indonesia
161
+ mt: Malta
162
+ sm: San Marino
163
+ cl: Chile
164
+ ie: Ireland
165
+ la: Lao People's Democratic Republic
166
+ mu: Mauritius
167
+ sn: Senegal
168
+ cm: Cameroon
169
+ fi: Finland
170
+ lb: Lebanon
171
+ mv: Maldives
172
+ pr: Puerto Rico
173
+ so: Somalia
174
+ cn: China
175
+ fj: Fiji
176
+ lc: Saint Lucia
177
+ mw: Malawi
178
+ ps: Palestinian Territory, Occupied
179
+ co: Colombia
180
+ fk: Falkland Islands (malvinas)
181
+ mx: Mexico
182
+ pt: Portugal
183
+ vn: Viet Nam
184
+ my: Malaysia
185
+ sr: Suriname
186
+ fm: Micronesia, Federated States of
187
+ mz: Mozambique
188
+ cr: Costa Rica
189
+ pw: Palau
190
+ fo: Faroe Islands
191
+ st: Sao Tome and Principe
192
+ il: Israel
193
+ li: Liechtenstein
194
+ py: Paraguay
195
+ cu: Cuba
196
+ im: Isle of Man
197
+ sv: El Salvador
198
+ ba: Bosnia and Herzegovina
199
+ cv: Cape Verde
200
+ fr: France
201
+ in: India
202
+ lk: Sri Lanka
203
+ vu: Vanuatu
204
+ io: British Indian Ocean Territory
205
+ bb: Barbados
206
+ ua: Ukraine
207
+ re: Reunion
208
+ sy: Syrian Arab Republic
209
+ cx: Christmas Island
210
+ iq: Iraq
211
+ sz: Swaziland
212
+ bd: Bangladesh
213
+ cy: Cyprus
214
+ ir: Iran, Islamic Republic of
215
+ yt: Mayotte
216
+ be: Belgium
217
+ cz: Czech Republic
218
+ bf: Burkina Faso
219
+ ec: Ecuador
220
+ is: Iceland
221
+ om: Oman
222
+ bg: Bulgaria
223
+ it: Italy
224
+ bh: Bahrain
225
+ ug: Uganda
226
+ bi: Burundi
227
+ ee: Estonia
228
+ lr: Liberia
229
+ bj: Benin
230
+ ls: Lesotho
231
+ eg: Egypt
232
+ lt: Lithuania
233
+ eh: Western Sahara
234
+ lu: Luxembourg
235
+ bm: Bermuda
236
+ lv: Latvia
237
+ ro: Romania
238
+ bn: Brunei Darussalam
239
+ um: United States Minor Outlying Islands
240
+ bo: Bolivia
241
+ ke: Kenya
242
+ na: Namibia
243
+ ly: Libyan Arab Jamahiriya
244
+ br: Brazil
245
+ kg: Kyrgyzstan
246
+ nc: New Caledonia
247
+ rs: Serbia
@@ -0,0 +1,42 @@
1
+ # Camping session module is a wretched piece of junk, so we just replace it
2
+ module JulikState
3
+ require 'activerecord'
4
+ class State < ActiveRecord::Base; set_table_name 'julik_states'; serialize :blob; end
5
+
6
+ def self.create_schema
7
+ return if State.table_exists?
8
+ ActiveRecord::Schema.define do
9
+ create_table :julik_states do | s |
10
+ s.column :blob, :text
11
+ s.column :sid, :string, :limit => 32
12
+ s.column :app, :string, :null => false, :limit => 50
13
+ s.column :modified_at, :datetime
14
+ s.column :created_at, :datetime
15
+ end
16
+ add_index :julik_states, [:sid, :app], :unique => true
17
+ State.reset_column_information
18
+ end
19
+ end
20
+ RC = [*'A'..'Z'] + [*'0'..'9'] + [*'a'..'z']
21
+ def _sid; (0...32).inject("") { |ret,_| ret << RC[rand(RC.length)] }; end
22
+ def _appn; self.class.to_s.split(/::/).shift; end
23
+
24
+ def force_session_save!
25
+ @cookies.jsid ||= _sid
26
+ res = @js_rec.update_attributes :blob => @state, :sid => @cookies.jsid
27
+ raise "Cannot save session" unless res
28
+ end
29
+
30
+ def service(*a)
31
+
32
+ fresh = Camping::H[{}]
33
+ @js_rec = State.find_by_sid_and_app(@cookies.jsid, _appn) || State.new(:app => _appn, :blob => fresh,
34
+ :sid => (@cookies.jsid ||= _sid))
35
+
36
+ @state = @js_rec.blob.dup
37
+ @msg = @state.delete(:msg)
38
+ returning(super(*a)) do
39
+ force_session_save! if (@state != @js_rec.blob)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ %w( action_pack action_controller action_view ).each { |e| require e }
2
+ # We use some Rails magic to make forms easier
3
+ class Markaby::Builder
4
+ include ::ActionView::Helpers::FormHelper
5
+ include ::ActionView::Helpers::FormOptionsHelper
6
+ include ::ActionView::Helpers::TextHelper
7
+ include ::ActionView::Helpers::DateHelper
8
+ end
@@ -0,0 +1,60 @@
1
+ require 'openid/store/interface'
2
+ class PasaporteStore < ::OpenID::Store::Interface
3
+ include ::Pasaporte::Models
4
+ attr_accessor :pasaporte_domain
5
+
6
+ def store_association(server_url, assoc)
7
+ raise "Cannot save association without my own domain being set" unless @pasaporte_domain
8
+ remove_association(server_url, assoc.handle)
9
+ Association.create(:server_url => server_url,
10
+ :handle => assoc.handle,
11
+ :secret => assoc.secret,
12
+ :issued => assoc.issued,
13
+ :lifetime => assoc.lifetime,
14
+ :assoc_type => assoc.assoc_type,
15
+ :pasaporte_domain => pasaporte_domain)
16
+ end
17
+
18
+ def get_association(server_url, handle=nil)
19
+ raise "Cannot load association without my own domain being set" unless @pasaporte_domain
20
+ assocs = if handle.blank?
21
+ Association.find_all_by_server_url_and_pasaporte_domain(server_url, pasaporte_domain)
22
+ else
23
+ Association.find_all_by_server_url_and_handle_and_pasaporte_domain(server_url, handle, pasaporte_domain)
24
+ end
25
+
26
+ assocs.reverse.each do |assoc|
27
+ a = assoc.from_record
28
+ if a.expires_in == 0
29
+ assoc.destroy
30
+ else
31
+ return a
32
+ end
33
+ end if assocs.any?
34
+
35
+ return nil
36
+ end
37
+
38
+ def remove_association(server_url, handle)
39
+ raise "Cannot remove association without my own domain being set" unless pasaporte_domain
40
+ Association.delete_all(['server_url = ? AND handle = ? AND pasaporte_domain = ?', server_url, handle, pasaporte_domain]) > 0
41
+ end
42
+
43
+ def use_nonce(server_url, timestamp, salt)
44
+ raise "Cannot look for nonce without my own domain being set" unless pasaporte_domain
45
+ return false if Nonce.find_by_server_url_timestamp_salt_and_pasaporte_domain(server_url, timestamp, salt, pasaporte_domain)
46
+ return false if (timestamp - Time.now.to_i).abs > OpenID::Nonce.skew
47
+ Nonce.create(:server_url => server_url, :timestamp => timestamp, :salt => salt)
48
+ return true
49
+ end
50
+
51
+ def cleanup_nonces
52
+ now = Time.now.to_i
53
+ Nonce.delete_all(["timestamp > ? OR timestamp < ?", now + OpenID::Nonce.skew, now - OpenID::Nonce.skew])
54
+ end
55
+
56
+ def cleanup_associations
57
+ now = Time.now.to_i
58
+ Association.delete_all(['issued + lifetime > ?',now])
59
+ end
60
+ end