authengine 0.0.2

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.
Files changed (155) hide show
  1. data/.gitignore +10 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/README.md +86 -0
  5. data/Rakefile +31 -0
  6. data/app/assets/images/message_block/back.gif +0 -0
  7. data/app/assets/images/message_block/back_m.gif +0 -0
  8. data/app/assets/images/message_block/confirmation.gif +0 -0
  9. data/app/assets/images/message_block/confirmation_m.gif +0 -0
  10. data/app/assets/images/message_block/error.gif +0 -0
  11. data/app/assets/images/message_block/error_m.gif +0 -0
  12. data/app/assets/images/message_block/info.gif +0 -0
  13. data/app/assets/images/message_block/info_m.gif +0 -0
  14. data/app/assets/images/message_block/notice.gif +0 -0
  15. data/app/assets/images/message_block/notice_m.gif +0 -0
  16. data/app/assets/images/message_block/warn.gif +0 -0
  17. data/app/assets/images/message_block/warn_m.gif +0 -0
  18. data/app/assets/stylesheets/authengine.css +3 -0
  19. data/app/assets/stylesheets/message_block.css +45 -0
  20. data/app/controllers/authengine/accounts_controller.rb +56 -0
  21. data/app/controllers/authengine/action_roles_controller.rb +22 -0
  22. data/app/controllers/authengine/actions_controller.rb +17 -0
  23. data/app/controllers/authengine/roles_controller.rb +35 -0
  24. data/app/controllers/authengine/sessions_controller.rb +75 -0
  25. data/app/controllers/authengine/user_roles_controller.rb +55 -0
  26. data/app/controllers/authengine/useractions_controller.rb +17 -0
  27. data/app/controllers/authengine/users_controller.rb +137 -0
  28. data/app/helpers/application_helper.rb +2 -0
  29. data/app/helpers/authengine/users_helper.rb +11 -0
  30. data/app/helpers/roles_helper.rb +2 -0
  31. data/app/mailers/authengine/user_mailer.rb +53 -0
  32. data/app/models/action.rb +54 -0
  33. data/app/models/action_role.rb +29 -0
  34. data/app/models/authenticated_system.rb +179 -0
  35. data/app/models/authorized_system.rb +41 -0
  36. data/app/models/controller.rb +124 -0
  37. data/app/models/role.rb +71 -0
  38. data/app/models/session.rb +3 -0
  39. data/app/models/session_role.rb +17 -0
  40. data/app/models/user.rb +191 -0
  41. data/app/models/user_observer.rb +14 -0
  42. data/app/models/user_role.rb +4 -0
  43. data/app/models/useraction.rb +56 -0
  44. data/app/views/authengine/accounts/edit.html.erb +19 -0
  45. data/app/views/authengine/actions/create.html.erb +2 -0
  46. data/app/views/authengine/actions/destroy.html.erb +2 -0
  47. data/app/views/authengine/actions/edit.html.erb +80 -0
  48. data/app/views/authengine/actions/index.html.haml +26 -0
  49. data/app/views/authengine/actions/new.html.erb +2 -0
  50. data/app/views/authengine/actions/show.html.erb +8 -0
  51. data/app/views/authengine/actions/update.html.erb +11 -0
  52. data/app/views/authengine/admin/_show.html.haml +5 -0
  53. data/app/views/authengine/layouts/authengine.html.haml +9 -0
  54. data/app/views/authengine/roles/index.html.haml +12 -0
  55. data/app/views/authengine/roles/new.html.haml +15 -0
  56. data/app/views/authengine/roles/show.html.erb +8 -0
  57. data/app/views/authengine/sessions/new.html.haml +18 -0
  58. data/app/views/authengine/user_mailer/activation.html.erb +5 -0
  59. data/app/views/authengine/user_mailer/forgot_password.html.erb +3 -0
  60. data/app/views/authengine/user_mailer/message_to_admin.html.erb +2 -0
  61. data/app/views/authengine/user_mailer/reset_password.html.erb +1 -0
  62. data/app/views/authengine/user_mailer/signup_notification.html.erb +5 -0
  63. data/app/views/authengine/user_roles/edit.html.haml +10 -0
  64. data/app/views/authengine/user_roles/index.html.haml +14 -0
  65. data/app/views/authengine/user_roles/new.html.haml +8 -0
  66. data/app/views/authengine/useractions/_useraction.html.erb +6 -0
  67. data/app/views/authengine/useractions/index.html.erb +13 -0
  68. data/app/views/authengine/useractions/show.html.haml +14 -0
  69. data/app/views/authengine/useractions/update.html.erb +2 -0
  70. data/app/views/authengine/users/_no_privacy_policy.html.haml +1 -0
  71. data/app/views/authengine/users/_privacy_policy_example.html.haml +36 -0
  72. data/app/views/authengine/users/_user.html.haml +19 -0
  73. data/app/views/authengine/users/edit.html.haml +24 -0
  74. data/app/views/authengine/users/index.html.haml +10 -0
  75. data/app/views/authengine/users/new.html.haml +31 -0
  76. data/app/views/authengine/users/show.html.haml +19 -0
  77. data/app/views/authengine/users/signup.html.haml +52 -0
  78. data/authengine.gemspec +44 -0
  79. data/config/application.rb +1 -0
  80. data/config/routes.rb +43 -0
  81. data/db/migrate/20110320171029_create_authengine_tables.rb +90 -0
  82. data/db/migrate/20110924165900_add_parent_id_to_roles_table.rb +5 -0
  83. data/db/migrate/20110925202800_add_type_field_to_user_roles_table.rb +5 -0
  84. data/db/migrate/20111003074700_add_indexes_to_several_tables.rb +7 -0
  85. data/db/seeds.rb +7 -0
  86. data/lib/application_helper.rb +19 -0
  87. data/lib/authengine.rb +5 -0
  88. data/lib/authengine/engine.rb +44 -0
  89. data/lib/authengine/testing_support/factories/user_factory.rb +13 -0
  90. data/lib/authengine/version.rb +3 -0
  91. data/lib/rails/generators/authengine/authengine_generator.rb +160 -0
  92. data/lib/rails/generators/authengine/templates/initializer.rb +3 -0
  93. data/lib/rails/generators/authengine/templates/migration.rb +16 -0
  94. data/lib/rails/generators/authengine/templates/pre_populate_database.rb +20 -0
  95. data/lib/rails/generators/authengine/templates/schema.rb +69 -0
  96. data/lib/tasks/bootstrap.rake +29 -0
  97. data/spec/authengine_spec.rb +7 -0
  98. data/spec/dummy/.rspec +1 -0
  99. data/spec/dummy/Gemfile +3 -0
  100. data/spec/dummy/Rakefile +8 -0
  101. data/spec/dummy/app/assets/javascripts/jasmine_examples/Player.js +22 -0
  102. data/spec/dummy/app/assets/javascripts/jasmine_examples/Song.js +7 -0
  103. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  104. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  105. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  106. data/spec/dummy/config.ru +4 -0
  107. data/spec/dummy/config/application.rb +50 -0
  108. data/spec/dummy/config/boot.rb +10 -0
  109. data/spec/dummy/config/database.yml +22 -0
  110. data/spec/dummy/config/environment.rb +5 -0
  111. data/spec/dummy/config/environments/development.rb +26 -0
  112. data/spec/dummy/config/environments/production.rb +49 -0
  113. data/spec/dummy/config/environments/test.rb +35 -0
  114. data/spec/dummy/config/initializers/application.rb +1 -0
  115. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  116. data/spec/dummy/config/initializers/inflections.rb +10 -0
  117. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  118. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  119. data/spec/dummy/config/initializers/session_store.rb +8 -0
  120. data/spec/dummy/config/locales/en.yml +5 -0
  121. data/spec/dummy/config/routes.rb +3 -0
  122. data/spec/dummy/db/development.sqlite3 +0 -0
  123. data/spec/dummy/db/schema.rb +87 -0
  124. data/spec/dummy/lib/constants.rb +5 -0
  125. data/spec/dummy/log/development.log +117 -0
  126. data/spec/dummy/log/production.log +0 -0
  127. data/spec/dummy/log/server.log +0 -0
  128. data/spec/dummy/public/404.html +26 -0
  129. data/spec/dummy/public/422.html +26 -0
  130. data/spec/dummy/public/500.html +26 -0
  131. data/spec/dummy/public/favicon.ico +0 -0
  132. data/spec/dummy/public/javascripts/application.js +2 -0
  133. data/spec/dummy/public/javascripts/controls.js +965 -0
  134. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  135. data/spec/dummy/public/javascripts/effects.js +1123 -0
  136. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  137. data/spec/dummy/public/javascripts/rails.js +191 -0
  138. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  139. data/spec/dummy/script/rails +6 -0
  140. data/spec/dummy/spec/javascripts/helpers/.gitkeep +0 -0
  141. data/spec/dummy/spec/javascripts/helpers/SpecHelper.js +9 -0
  142. data/spec/dummy/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
  143. data/spec/dummy/spec/javascripts/support/jasmine.yml +76 -0
  144. data/spec/generators/authengine_generator_spec.rb +11 -0
  145. data/spec/integration/navigation_spec.rb +9 -0
  146. data/spec/javascripts/spec.css +3 -0
  147. data/spec/javascripts/spec.js.coffee +2 -0
  148. data/spec/models/action_role_spec.rb +59 -0
  149. data/spec/models/authenticated_system_spec.rb +109 -0
  150. data/spec/models/role_spec.rb +38 -0
  151. data/spec/models/user_factory_spec.rb +7 -0
  152. data/spec/models/user_spec.rb +16 -0
  153. data/spec/requests/sessions_spec.rb +11 -0
  154. data/spec/spec_helper.rb +57 -0
  155. metadata +405 -0
@@ -0,0 +1,19 @@
1
+ %tr{:class => "#{cycle('odd', 'even')}"}
2
+ %td= user.firstName
3
+ %td= user.lastName
4
+ %td= user.roles.map(&:name).join(', ')
5
+ %td= user.enabled ? 'yes' : 'no'
6
+ %td
7
+ - unless user == current_user
8
+ - if user.enabled
9
+ = link_to('disable', disable_authengine_user_path(user.id), :method => :put)
10
+ - else
11
+ = link_to('enable', enable_authengine_user_path(user.id), :method => :put)
12
+ %td= link_to "show", authengine_user_path(user)
13
+ %td
14
+ - unless user == current_user
15
+ = link_to "delete", [:authengine, user], :data => {:confirm => "are you sure you want to delete #{user.first_last_name} ?"}, :method => :delete
16
+ %td
17
+ - unless user == current_user
18
+ = link_to 'edit roles', authengine_user_user_roles_path(user)
19
+ %td= link_to 'edit profile', edit_authengine_user_path(user)
@@ -0,0 +1,24 @@
1
+ %h2>Edit Profile
2
+ - if @user.errors.any?
3
+ %ul
4
+ - @user.errors.full_messages.each do |msg|
5
+ %li=msg
6
+
7
+ = form_for @user, :url => requested_user_or_self, :html => { :method => :put } do |f|
8
+ %p
9
+ First Name:
10
+ %br/
11
+ = f.text_field :firstName, :size => 60
12
+ %p
13
+ Last Name:
14
+ %br/
15
+ = f.text_field :lastName, :size => 60
16
+ %p
17
+ Email:
18
+ %br/
19
+ = f.text_field :email, :size => 60
20
+
21
+ - submit_or_return_to authengine_users_path
22
+
23
+ %script{:type=>'text/javascript'}
24
+ document.getElementById('user_email').focus()
@@ -0,0 +1,10 @@
1
+ %h1 Database Users
2
+ %table
3
+ %tr
4
+ %th First Name
5
+ %th Last Name
6
+ %th Role(s)
7
+ %th{:colspan=>"2"}Enabled?
8
+ %th{:colspan=>"4"}Manage
9
+ = render :partial => 'user', :collection => @users
10
+ %p= link_to "New User", new_authengine_user_path
@@ -0,0 +1,31 @@
1
+ = message_block :on => [:user]
2
+
3
+ %h1 Create a new user account:
4
+
5
+ =form_for [:authengine, @user] do |f|
6
+ %table
7
+ %tr
8
+ %td
9
+ %label{:for=>"firstName"} First Name
10
+ %td= f.text_field :firstName
11
+
12
+ %tr
13
+ %td
14
+ %label{:for=>"lastName"} Last Name
15
+ %td= f.text_field :lastName
16
+
17
+ %tr
18
+ %td
19
+ %label{:for=>"email"} Email
20
+ %td= f.text_field :email
21
+
22
+ %tr
23
+ %td
24
+ %label{:for => "role_id"} Database access role
25
+ %td
26
+ = f.fields_for :user_roles do |role_form|
27
+ = role_form.collection_select(:role_id, @roles, :id, :name)
28
+
29
+ - submit_or_return_to(authengine_users_path)
30
+ %script{:type=>'text/javascript'}
31
+ document.getElementById('user_firstName').focus()
@@ -0,0 +1,19 @@
1
+ %h2
2
+ %table
3
+ %tr
4
+ %td User:
5
+ %td= @user.firstName+" "+@user.lastName
6
+ %tr
7
+ %td Login name:
8
+ %td= @user.login
9
+ %tr
10
+ %td email:
11
+ %td= @user.email
12
+ %tr
13
+ %td Joined on:
14
+ %td= @user.created_at.to_s(:long)
15
+ %tr
16
+ %td Role(s):
17
+ %td= @user.roles.map(&:name).join(", ")
18
+ %br/
19
+ = link_to "Back", :back
@@ -0,0 +1,52 @@
1
+ :javascript
2
+ function check_policy(){
3
+ cb_count = 0
4
+ for(var i = 1; i<10; i++){
5
+ cb = document.getElementById("user_cb_cb"+i)
6
+ if(cb.checked){cb_count++}
7
+ }
8
+ if (cb_count == 9){return true}
9
+ else{alert("Please check all the checkboxes to signify your agreement to comply with the #{ORGANIZATION_NAME} Privacy Policy"); return false}
10
+ }
11
+
12
+ function check_user_info(){
13
+ if(document.getElementById('user_login').value.length < 5){alert('Please enter a login name longer than 5 letters')}
14
+ else if(document.getElementById('user_email').value.length < 9 ){alert('Please enter a legitimate email address')}
15
+ else if(document.getElementById('user_password').value.length < 6){alert('Please select a password longer than 6 characters')}
16
+ else if(document.getElementById('user_password_confirmation').value != document.getElementById('user_password').value){alert('The two password fields don\'t match')}
17
+ else{
18
+ $(".user_info").css("display", "none")
19
+ $("#privacy_policy").css("display", "block")
20
+ }
21
+ }
22
+
23
+ = message_block :on => :user
24
+ = form_for :user, :url => {:action=>:activate, :activation_code=>session[:activation_code], :method=>:post}, :html=>{:onsubmit=>"return check_policy()"} do |f|
25
+ .user_info
26
+ %h1
27
+ Welcome #{@user.firstName} #{@user.lastName} to the #{APPLICATION_NAME || "database"}
28
+ %table
29
+ %tr
30
+ %td
31
+ %label{:for => "login" } Select a login name:
32
+ %td= f.text_field :login
33
+ %tr
34
+ %td
35
+ %label{:for => "email" } Your email address:
36
+ %td= f.text_field :email
37
+ %tr
38
+ %td
39
+ %label{:for => "password" } Select a login password:
40
+ %td= f.password_field :password
41
+ %tr
42
+ %td
43
+ %label{:for => "password_confirmation" } Re-enter your password to confirm:
44
+ %td= f.password_field :password_confirmation
45
+
46
+ %p
47
+ - begin
48
+ = render 'privacy_policy'
49
+ - rescue ActionView::MissingTemplate
50
+ = render 'no_privacy_policy'
51
+ %script{:type=>'text/javascript'}
52
+ document.getElementById('user_login').focus()
@@ -0,0 +1,44 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "authengine/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "authengine"
7
+ s.version = Authengine::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Les Nightingill"]
10
+ s.email = ["codehacker@comcast.net"]
11
+ s.homepage = ""
12
+ s.summary = %q{Unobtrusive authentication and authorization engine}
13
+ s.description = %q{A rails authentication and authorization engine that
14
+ reduces clutter in your controllers and views.
15
+ Includes aliased link_to and button_to helpers that return an empty string
16
+ if the current user is not permitted to follow the link.
17
+ Authorization configuration is removed from the controllers and instead
18
+ is stored in the database and configured through html views.}
19
+
20
+ s.rubyforge_project = "authengine"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.require_paths = ["lib"]
26
+
27
+ # one would think that these were development dependencies,
28
+ # but they are only installed when calling bundle from the
29
+ # host application if they are runtime dependencies! (bug?
30
+ # or misunderstanding?)
31
+ s.add_dependency 'rspec', '>= 2.0.0'
32
+ s.add_dependency 'rails', '~>3.2.5'
33
+ s.add_dependency 'sqlite3-ruby'
34
+ s.add_dependency 'capybara'
35
+ s.add_dependency 'rspec-rails', ">= 2.0.0"
36
+ s.add_dependency 'flexmock'
37
+ s.add_dependency 'faker'
38
+ s.add_dependency 'message_block'
39
+ s.add_dependency 'haml'
40
+ s.add_dependency 'factory_girl_rails'
41
+ s.add_dependency 'database_cleaner'
42
+ s.add_dependency 'jasmine'
43
+ s.add_dependency 'jasminerice'
44
+ end
@@ -0,0 +1 @@
1
+ Dir.new(File.join(File.dirname(__FILE__), '../lib')).entries.each { |f| require f }
@@ -0,0 +1,43 @@
1
+ Rails.application.routes.draw do
2
+ root :to => "authengine/sessions#new"
3
+
4
+ namespace :authengine do
5
+ resources :accounts
6
+ resources :actions
7
+ resources :useractions
8
+ resources :action_roles do
9
+ put 'update_all', :on => :collection
10
+ end
11
+
12
+ resources :sessions
13
+ resources :roles
14
+ resources :users do
15
+ resource :account
16
+ resources :user_roles do
17
+ collection do
18
+ get 'edit'
19
+ put 'update'
20
+ end
21
+ end
22
+
23
+ member do
24
+ put 'enable'
25
+ put 'disable'
26
+ put 'update_self'
27
+
28
+ match 'signup'
29
+ end
30
+
31
+ collection do
32
+ get 'edit_self'
33
+
34
+ match ':activation_code/activate' => 'users#activate', :via => :post
35
+ end
36
+ end
37
+
38
+ match '/activate(/:activation_code)' => "accounts#show", :as => :activate, :via => :get # actually activation_code is always required, but handling it as optional permits its absence to be communicated to the user as a flash message
39
+ end
40
+ match '/login' => "authengine/sessions#new"
41
+ match '/logout' => "authengine/sessions#destroy"
42
+
43
+ end
@@ -0,0 +1,90 @@
1
+ class CreateAuthengineTables < ActiveRecord::Migration
2
+ def self.up
3
+
4
+ create_table "useractions", :force => true do |t|
5
+ t.integer "user_id"
6
+ t.integer "action_id"
7
+ t.string "type"
8
+ t.text "params"
9
+ t.timestamps
10
+ end
11
+
12
+ create_table "user_roles", :force => true do |t|
13
+ t.integer "role_id", :limit => 8, :null => false
14
+ t.integer "user_id", :limit => 8, :null => false
15
+ t.timestamps
16
+ end
17
+
18
+ create_table "roles", :force => true do |t|
19
+ t.string "name"
20
+ t.string "short_name"
21
+ t.timestamps
22
+ end
23
+
24
+ create_table "controllers", :force => true do |t|
25
+ t.string "controller_name"
26
+ t.datetime "last_modified"
27
+ t.timestamps
28
+ end
29
+
30
+ create_table "action_roles", :force => true do |t|
31
+ t.integer "role_id", :limit => 8
32
+ t.integer "action_id", :limit => 8
33
+ t.timestamps
34
+ end
35
+
36
+ create_table "actions", :force => true do |t|
37
+ t.string "action_name"
38
+ t.integer "controller_id"
39
+ t.timestamps
40
+ end
41
+
42
+ create_table "users", :force => true do |t|
43
+ t.string "login"
44
+ t.string "email"
45
+ t.string "crypted_password", :limit => 40
46
+ t.string "salt", :limit => 40
47
+ t.string "remember_token"
48
+ t.datetime "remember_token_expires_at"
49
+ t.string "activation_code", :limit => 40
50
+ t.datetime "activated_at"
51
+ t.string "password_reset_code", :limit => 40
52
+ t.boolean "enabled", :default => true
53
+ t.string "firstName"
54
+ t.string "lastName"
55
+ t.string "type"
56
+ t.string "status"
57
+ t.timestamps
58
+ end
59
+
60
+ User.reset_column_information
61
+ user = User.create(:login => 'admin',
62
+ :email => 'user@example.com',
63
+ :enabled => true,
64
+ :firstName => 'A',
65
+ :lastName => 'User')
66
+ user.update_attribute(:salt, '1641b615ad281759adf85cd5fbf17fcb7a3f7e87')
67
+ user.update_attribute(:activation_code, '9bb0db48971821563788e316b1fdd53dd99bc8ff')
68
+ user.update_attribute(:activated_at, DateTime.new(2011,1,1))
69
+ user.update_attribute(:crypted_password, '660030f1be7289571b0467b9195ff39471c60651')
70
+
71
+ # in the bootstrap scenario, give the administrative user enough
72
+ # access to be able to configure the access tables for admin and other users
73
+ role = Role.create(:name => 'developer')
74
+ Controller.update_table
75
+ Action.all.each { |a| role.actions << a }
76
+ user.roles << role
77
+ user.save
78
+
79
+ end
80
+
81
+ def self.down
82
+ drop_table :useractions
83
+ drop_table :user_roles
84
+ drop_table :roles
85
+ drop_table :controllers
86
+ drop_table :action_roles
87
+ drop_table :actions
88
+ drop_table :users
89
+ end
90
+ end
@@ -0,0 +1,5 @@
1
+ class AddParentIdToRolesTable < ActiveRecord::Migration
2
+ def change
3
+ add_column :roles, :parent_id, :integer, :default => nil
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddTypeFieldToUserRolesTable < ActiveRecord::Migration
2
+ def change
3
+ add_column :user_roles, :type, :string, :default => 'PersistentUserRole'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class AddIndexesToSeveralTables < ActiveRecord::Migration
2
+ def change
3
+ add_index :actions, :action_name
4
+ add_index :controllers, :controller_name
5
+ add_index :users, :login
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,19 @@
1
+ module ApplicationHelper
2
+ def submit_or_return_to(return_path)
3
+ haml_tag :table, {:style => 'padding-top:30px'} do
4
+ haml_tag :tr do
5
+ haml_tag :td, {:width => '180px'} do
6
+ haml_tag :input, {:type => 'submit', :value => 'Save'}
7
+ end
8
+ haml_tag :td do
9
+ haml_tag :a, "Cancel", {:href => return_path}
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ def focus(input)
16
+ haml_tag :script, "$(function(){$('##{input}').focus()})"
17
+ end
18
+
19
+ end
@@ -0,0 +1,5 @@
1
+ module Authengine
2
+ require 'message_block'
3
+ require 'haml'
4
+ require 'authengine/engine'
5
+ end
@@ -0,0 +1,44 @@
1
+ require 'authengine'
2
+ require 'rails'
3
+ require 'action_controller'
4
+ require 'application_helper'
5
+
6
+ module Authengine
7
+ class Engine < Rails::Engine
8
+
9
+ # Config defaults
10
+ config.widget_factory_name = "default factory name"
11
+ config.mount_at = '/'
12
+ config.active_record.observers = :user_observer
13
+
14
+ # Load rake tasks
15
+ #rake_tasks do
16
+ #load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')
17
+ #end
18
+
19
+ # Check the gem config
20
+ initializer "check config" do |app|
21
+ # make sure mount_at ends with trailing slash
22
+ config.mount_at += '/' unless config.mount_at.last == '/'
23
+ end
24
+
25
+ # serve static assets directly from the engine
26
+ initializer "static assets" do |app|
27
+ # need to move ActionDispatch::Static ahead of Rack::Sendfile as the
28
+ # mod_xsendfile is apparently not installed on the Apache server
29
+ # see http://rack.rubyforge.org/doc/classes/Rack/Sendfile.html
30
+ # this was causing blank css files to be sent.
31
+ # 'root' here is the full path to the engine root
32
+ app.middleware.insert_before ::Rack::Lock, ::ActionDispatch::Static, "#{root}/public"
33
+ #app.middleware.use ::ActionDispatch::Static, "#{root}/public"
34
+ end
35
+
36
+ initializer "authengine.application_controller" do |app|
37
+ ActiveSupport.on_load(:action_controller) do
38
+ include AuthenticatedSystem
39
+ include AuthorizedSystem
40
+ end
41
+ end
42
+
43
+ end
44
+ end