wobauth 3.4.4

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 (188) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +165 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/wobauth/admin.js +13 -0
  5. data/app/assets/javascripts/wobauth/authorities.js.coffee +31 -0
  6. data/app/assets/javascripts/wobauth/groups.js +2 -0
  7. data/app/assets/javascripts/wobauth/memberships.js +2 -0
  8. data/app/assets/javascripts/wobauth/roles.js +2 -0
  9. data/app/assets/stylesheets/wobauth/application.css +15 -0
  10. data/app/assets/stylesheets/wobauth/authorities.css +4 -0
  11. data/app/assets/stylesheets/wobauth/groups.css +4 -0
  12. data/app/assets/stylesheets/wobauth/memberships.css +4 -0
  13. data/app/assets/stylesheets/wobauth/roles.css +4 -0
  14. data/app/controllers/wobauth/ad_users_controller.rb +24 -0
  15. data/app/controllers/wobauth/application_controller.rb +25 -0
  16. data/app/controllers/wobauth/authorities_controller.rb +88 -0
  17. data/app/controllers/wobauth/groups/authorities_controller.rb +11 -0
  18. data/app/controllers/wobauth/groups/memberships_controller.rb +11 -0
  19. data/app/controllers/wobauth/groups_controller.rb +60 -0
  20. data/app/controllers/wobauth/login_controller.rb +10 -0
  21. data/app/controllers/wobauth/memberships_controller.rb +79 -0
  22. data/app/controllers/wobauth/registrations_controller.rb +26 -0
  23. data/app/controllers/wobauth/roles_controller.rb +30 -0
  24. data/app/controllers/wobauth/users/authorities_controller.rb +11 -0
  25. data/app/controllers/wobauth/users/memberships_controller.rb +11 -0
  26. data/app/controllers/wobauth/users_controller.rb +76 -0
  27. data/app/helpers/wobauth/ad_users_helper.rb +60 -0
  28. data/app/helpers/wobauth/application_helper.rb +53 -0
  29. data/app/helpers/wobauth/authorities_helper.rb +9 -0
  30. data/app/models/wobauth/ad_user.rb +4 -0
  31. data/app/models/wobauth/admin_ability.rb +67 -0
  32. data/app/models/wobauth/authority.rb +17 -0
  33. data/app/models/wobauth/group.rb +18 -0
  34. data/app/models/wobauth/membership.rb +11 -0
  35. data/app/models/wobauth/role.rb +19 -0
  36. data/app/models/wobauth/user.rb +11 -0
  37. data/app/services/wobauth/search_ad_user_service.rb +53 -0
  38. data/app/views/devise/registrations/edit.html.erb +25 -0
  39. data/app/views/devise/sessions/new.html.erb +17 -0
  40. data/app/views/devise/shared/_links.html.erb +0 -0
  41. data/app/views/wobauth/ad_users/index.html.erb +69 -0
  42. data/app/views/wobauth/authorities/_form.html.erb +32 -0
  43. data/app/views/wobauth/authorities/edit.html.erb +1 -0
  44. data/app/views/wobauth/authorities/index.html.erb +41 -0
  45. data/app/views/wobauth/authorities/new.html.erb +1 -0
  46. data/app/views/wobauth/authorities/show.html.erb +45 -0
  47. data/app/views/wobauth/groups/_form.html.erb +20 -0
  48. data/app/views/wobauth/groups/_group_memberships.html.erb +21 -0
  49. data/app/views/wobauth/groups/_group_roles.html.erb +23 -0
  50. data/app/views/wobauth/groups/edit.html.erb +1 -0
  51. data/app/views/wobauth/groups/index.html.erb +31 -0
  52. data/app/views/wobauth/groups/new.html.erb +1 -0
  53. data/app/views/wobauth/groups/show.html.erb +45 -0
  54. data/app/views/wobauth/memberships/_form.html.erb +20 -0
  55. data/app/views/wobauth/memberships/edit.html.erb +1 -0
  56. data/app/views/wobauth/memberships/index.html.erb +33 -0
  57. data/app/views/wobauth/memberships/new.html.erb +1 -0
  58. data/app/views/wobauth/memberships/show.html.erb +28 -0
  59. data/app/views/wobauth/roles/_role_authorities.html.erb +21 -0
  60. data/app/views/wobauth/roles/index.html.erb +26 -0
  61. data/app/views/wobauth/roles/show.html.erb +18 -0
  62. data/app/views/wobauth/shared/_accounting.html.erb +25 -0
  63. data/app/views/wobauth/shared/_admin.html.erb +13 -0
  64. data/app/views/wobauth/users/_form.html.erb +28 -0
  65. data/app/views/wobauth/users/_user_groups.html.erb +22 -0
  66. data/app/views/wobauth/users/_user_roles.html.erb +23 -0
  67. data/app/views/wobauth/users/edit.html.erb +1 -0
  68. data/app/views/wobauth/users/index.html.erb +52 -0
  69. data/app/views/wobauth/users/new.html.erb +1 -0
  70. data/app/views/wobauth/users/show.html.erb +130 -0
  71. data/config/initializers/assets.rb +1 -0
  72. data/config/initializers/devise.rb +260 -0
  73. data/config/initializers/devise_failure_app.rb +21 -0
  74. data/config/initializers/simple_form.rb +169 -0
  75. data/config/initializers/simple_form_bootstrap.rb +154 -0
  76. data/config/initializers/wobapphelpers.rb +18 -0
  77. data/config/locales/de.yml +80 -0
  78. data/config/locales/devise.de.yml +60 -0
  79. data/config/locales/devise.en.yml +59 -0
  80. data/config/locales/en.yml +27 -0
  81. data/config/locales/simple_form.en.yml +31 -0
  82. data/config/locales/wobapphelpers.de.yml +10 -0
  83. data/config/locales/wobapphelpers.en.yml +8 -0
  84. data/config/routes.rb +24 -0
  85. data/db/migrate/20140501113226_create_wobauth_roles.rb +9 -0
  86. data/db/migrate/20140501150743_create_wobauth_groups.rb +10 -0
  87. data/db/migrate/20140504124045_create_wobauth_memberships.rb +11 -0
  88. data/db/migrate/20140504143328_create_wobauth_authorities.rb +15 -0
  89. data/db/migrate/20140508120810_devise_create_wobauth_users.rb +55 -0
  90. data/db/migrate/20171231084355_additional_fields_to_wobauth_user.rb +8 -0
  91. data/lib/concerns/models/user.rb +44 -0
  92. data/lib/generators/templates/initializers/wobauth.rb +20 -0
  93. data/lib/generators/wobauth/install_generator.rb +20 -0
  94. data/lib/tasks/wobauth_tasks.rake +4 -0
  95. data/lib/templates/erb/scaffold/_form.html.erb +26 -0
  96. data/lib/templates/erb/scaffold/edit.html.erb +1 -0
  97. data/lib/templates/erb/scaffold/index.html.erb +32 -0
  98. data/lib/templates/erb/scaffold/new.html.erb +1 -0
  99. data/lib/templates/erb/scaffold/show.html.erb +15 -0
  100. data/lib/templates/rails/scaffold_controller/controller.rb +66 -0
  101. data/lib/wobauth/engine.rb +33 -0
  102. data/lib/wobauth/version.rb +4 -0
  103. data/lib/wobauth.rb +57 -0
  104. data/test/dummy/db/test.sqlite3 +0 -0
  105. data/test/dummy/db/test1.sqlite3 +0 -0
  106. data/test/dummy/log/test.log +1954 -0
  107. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-6/-6x3utBDawbjV5d477TJ9PeEoQTk9Yh292Yg_8Ox16U.cache +1 -0
  108. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-A/-A9u9WxFQ9YT2TSLvmYJYJf2Kg9JfDoIt6YZQRcwUHE.cache +0 -0
  109. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-C/-CJCPQLf_lB4gJr983MP5sZdH3uZuYPIe-xSw4QBln4.cache +1 -0
  110. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-K/-K6Cz6iJ4bgvnwN-rMFxBtyYEU6EGdLH9b4N38_GwIs.cache +1 -0
  111. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-x/-xwsVQHMHEQFqvVNjKKkEiujw9_CUgnJ2Hmzampfy60.cache +1 -0
  112. data/test/dummy/tmp/cache/assets/sprockets/v3.0/2J/2JNdqFTZ9i8DAT1rZCc-Xj70u9zcQtlJoqEK68sRPVM.cache +0 -0
  113. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4N/4NSPDtUmuTVU5uLI-eBtnORjzrwVgeLgrgIJh4tjWeQ.cache +1 -0
  114. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4u/4uuqiFX5bLo0J5QqMPSZc642NRkdX4l-Vguvyq6Oe3U.cache +1 -0
  115. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5O/5Oqd8RObzOeHuHy3NTiGE5p_ZkpftjQQgJgS_3KKdH0.cache +1 -0
  116. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6U/6UZEqCkIx3XO_NjOjjWyLET2-dS4Gs_RPAB9NtA99-A.cache +0 -0
  117. data/test/dummy/tmp/cache/assets/sprockets/v3.0/76/767sF803BgrHtDgUPUUn-HN41e6fklZIQkVKyKD59P4.cache +1 -0
  118. data/test/dummy/tmp/cache/assets/sprockets/v3.0/77/77ZyE9pECDHt-19ik7nBaJXJQT-7V2UDr49kFOIO1DM.cache +1 -0
  119. data/test/dummy/tmp/cache/assets/sprockets/v3.0/7n/7nJvPEaj-WV6RCKHc3hpHsAbWek8cidSKvDKLedQpH4.cache +3 -0
  120. data/test/dummy/tmp/cache/assets/sprockets/v3.0/85/856_llbCcD4ntIG6h4uR2WQY9SrutzA-9K6xT53ZPTY.cache +0 -0
  121. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9A/9A6WX6bvqMDoyDrYrGQy2l6nf_JtHoQZsa-pEJ0FgDU.cache +0 -0
  122. data/test/dummy/tmp/cache/assets/sprockets/v3.0/BA/BABtX6k2NZISYrxZSviAXC8UIxZfRhEDDbx7dMf_ShQ.cache +1 -0
  123. data/test/dummy/tmp/cache/assets/sprockets/v3.0/D4/D4_Vl_wB6Vq8O0LvQ9iHt-YqG_c0fUR4af06OZlk10k.cache +3 -0
  124. data/test/dummy/tmp/cache/assets/sprockets/v3.0/DX/DXGc2xprS_TuG5PzNCaBHKBMWTlyrZZYA9jlvlcBn3M.cache +1 -0
  125. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ex/ExDgDLUsesHZC1FAxhQLmTyBpg6IW4gVCUB8U8Ov-X4.cache +1 -0
  126. data/test/dummy/tmp/cache/assets/sprockets/v3.0/F8/F8M6mPdg93dPiXZzHGo3Y0I42et4yc5Hr-eCfuOUeac.cache +1 -0
  127. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Hk/Hkx4xbJvgHfFgfNDKyHxertTGvARWOgVuNuGU-OWPEU.cache +0 -0
  128. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Jo/Jom6Wnb-Sd-d3W24hNHS58BHtuw5Dsm7vvWVPtLB0PA.cache +0 -0
  129. data/test/dummy/tmp/cache/assets/sprockets/v3.0/K5/K5UnItDV1g9ixIoFloUxCNirxL5UFrOT0jz1vKy5shc.cache +31 -0
  130. data/test/dummy/tmp/cache/assets/sprockets/v3.0/K6/K6geC8zADOljHu2R2-DHUgVrgGyij9e4dnxgIdEypMU.cache +2 -0
  131. data/test/dummy/tmp/cache/assets/sprockets/v3.0/KW/KWpcGMHEfc0mpysCx46leXLgyrzubUIXWouB91Ia5Ik.cache +1 -0
  132. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LD/LD1fywEt5YfgacZhvpug0VXFakWRb1jidort_y8Fl00.cache +3 -0
  133. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LT/LTqeGcgCnDytohL1bGvcUZdnrp6gImr9Gzgfj6sYtW4.cache +1 -0
  134. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LX/LXirLCvjN2zWwKoda0ZdfOoFufIGRC9bZFKo95Kxs2w.cache +3 -0
  135. data/test/dummy/tmp/cache/assets/sprockets/v3.0/MH/MH3Sbn3D_A-k2L9Qd_MSjC2d6zv52DnzX3REO1P8n-E.cache +1 -0
  136. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Nm/NmUDbY8fbYAMYUH3HOmHzTLkeJaf-49yXUpF5TXGnYM.cache +3 -0
  137. data/test/dummy/tmp/cache/assets/sprockets/v3.0/O1/O1xVVUGePb-AZZi4nfbefQqZJEuQKvVAnHbbksdys0g.cache +0 -0
  138. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Og/Og28UaPh4fHs8CazZFMRRClJKMdtcZ6TLkcrwXO9888.cache +0 -0
  139. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Py/Py0iDud1Fnb6eLZHFV1BlJ1PKkeJS5bSVb8DL5Lyoyo.cache +2 -0
  140. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Qs/QscUYhnZ_Tw9H1UICqO4jqvLwSznyhEMlkTJRFR63Qk.cache +0 -0
  141. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Rx/RxBkonRxRoJzfP-2eiuZPIg4Wy1eaNd6MQ6N0QTzLbw.cache +1 -0
  142. data/test/dummy/tmp/cache/assets/sprockets/v3.0/S_/S_VAM9XIEPYa1eIrH2MGCvwgC6UuKNU3IsOsXYCbRfE.cache +1 -0
  143. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TK/TK13HHucosr5_ne6uScM6nK6naCAYu11S4GxXyvGEA4.cache +1 -0
  144. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TP/TPYDffricRYUN-8EoF99EbRAm5m9QVJ4NsV4JQHUaTU.cache +2 -0
  145. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TQ/TQZclZQajgRAt0UPyDLa5SDHOXXd7nrs_Aw1guZ1EDE.cache +0 -0
  146. data/test/dummy/tmp/cache/assets/sprockets/v3.0/U-/U-j-KeDrdeyrmflpuJSSH3aH_tGth_0zwnjl9eaecCU.cache +0 -0
  147. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ui/Ui_ImrdWE848w92udaqCheUJypT-7QIicGTDDcF94ZY.cache +2 -0
  148. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Vy/VyeoEaFiHk-BFfUz0QQyO1ywWUjhhvXaWjOhrueWuz4.cache +1 -0
  149. data/test/dummy/tmp/cache/assets/sprockets/v3.0/WC/WCZBAZL9AYx33c-WzmPLL8ZaSkyPBwQEpJSzDMruSTA.cache +0 -0
  150. data/test/dummy/tmp/cache/assets/sprockets/v3.0/XG/XG-1Cxql9XcU0QzVsKfaImD2F-_fbQakmCOO1PZeiO8.cache +1 -0
  151. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Y-/Y-mfMOkq6o7o6NIVKY5m1HzoQPj6deRrSVoSnePwWDg.cache +0 -0
  152. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Z5/Z56duv_o-wQlnyich8DqrY8VfI5mRampXLuyzcCQSes.cache +0 -0
  153. data/test/dummy/tmp/cache/assets/sprockets/v3.0/_X/_XFCt_G6l_CeYOky6Ky04YbAJMGmZ1S55wnsXuzjbFQ.cache +3 -0
  154. data/test/dummy/tmp/cache/assets/sprockets/v3.0/_c/_cAbQgu5_t6QaopeTV6bHpVH6nABdZSHUD3dtw3TFvI.cache +1 -0
  155. data/test/dummy/tmp/cache/assets/sprockets/v3.0/aU/aUB5QePK5Y_57d0ISu6VcHykCHzl47ej-nXJSzHo7mM.cache +0 -0
  156. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ao/ao7sMvRzih2MlCNwwQnYbm-FUNM2rl1wlruiVgH8VbE.cache +0 -0
  157. data/test/dummy/tmp/cache/assets/sprockets/v3.0/b8/b8sc4SHWqZyiR9LoszM7AwU7Z9RStRdUzs5Cm4b1xi4.cache +1 -0
  158. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dG/dGu-1JGz62Geuns1TpCaYbAwvwLKjSjDp_VhKV3nWOw.cache +3 -0
  159. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dH/dHU4yPNGwU72V1rymqid8RLS4ole8B-9UGSJG-QyDsQ.cache +3 -0
  160. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ei/eiJS8jxPa_CT4ECt01iVkhPzc9QQShE__hFgFUVMqhc.cache +1 -0
  161. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hq/hqAVf5Mc94swL5QKxbwrtNQ1F6-4shrOpiZMk60yjMM.cache +0 -0
  162. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hz/hzzNh1KGk98zydo_p20ZW15iDYFoCsUZuYdK99A54Mo.cache +1 -0
  163. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ip/ip5FbXNQpdaOzVbU6_r90bYcY8R47qbE2_C79IUdlvQ.cache +1 -0
  164. data/test/dummy/tmp/cache/assets/sprockets/v3.0/je/je9xQVOnasRNd1k49Q5KJdmxQscPKO-8qeVDMmmsVrI.cache +1 -0
  165. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jt/jtOzRwEskymBEhztMwmAwvXzROImYepCy7Zb25fxexQ.cache +2 -0
  166. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m3/m3BDc8KCgIUXE0VeZ142byDvlbYuOEBpNW_2ucKyb3M.cache +0 -0
  167. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mf/mfkdFcsUrRviUKGZkElnxw6dCyhyArAFbAVNuqQKcsE.cache +1 -0
  168. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mx/mxQkXyjT__7etUOHa4WpbGL4YguqInaF8rQXNK4c6JU.cache +1 -0
  169. data/test/dummy/tmp/cache/assets/sprockets/v3.0/o4/o4yHfopv-ZxcXaMdi1_2O0CkBEWWQEd0wR0tEwKJ8s8.cache +0 -0
  170. data/test/dummy/tmp/cache/assets/sprockets/v3.0/oF/oFjp7US8e9Cu4GOLqlO_vPIaX9jYwqrYbCFq6mgaYWE.cache +1 -0
  171. data/test/dummy/tmp/cache/assets/sprockets/v3.0/op/opKuUcXieH4Q4hch708zXOG2Rud2bhIilb38wKiOdjA.cache +1 -0
  172. data/test/dummy/tmp/cache/assets/sprockets/v3.0/p4/p4U2tbFHGXaOchAVtbEfIHRvWKO2i-0nsq_4vtGNABU.cache +2 -0
  173. data/test/dummy/tmp/cache/assets/sprockets/v3.0/s4/s4jckxw_fz9fwDYqkrZPCsD7cCATrXbD5R7ducBhtoU.cache +0 -0
  174. data/test/dummy/tmp/cache/assets/sprockets/v3.0/uP/uPXk7u0shmDjGGOhtU06VSo7E81DYc2t9OGhQUvxEA0.cache +1 -0
  175. data/test/dummy/tmp/cache/assets/sprockets/v3.0/vS/vSQW3iohJ14LLnwWgoHFeHB-I3yIzLi9tLoZkUaE81M.cache +0 -0
  176. data/test/dummy/tmp/cache/assets/sprockets/v3.0/vu/vuRt78a_J3dg7DUMHX1Nx9DYLME15Z1NjQ-4V8BoNCU.cache +1 -0
  177. data/test/dummy/tmp/cache/assets/sprockets/v3.0/w6/w6Gz48zxIouRBGOu5VmTHWsL9r0M4LKp124UOJ3mZN0.cache +1 -0
  178. data/test/dummy/tmp/cache/assets/sprockets/v3.0/wj/wjsRbpDa20LzSzj66UKcgy3Wif53rLBEoeuyKIKz4pk.cache +3 -0
  179. data/test/dummy/tmp/cache/assets/sprockets/v3.0/wo/wo1g4ZKtmQmol-3MoVPFApwd5fnGEA23tCRCLuEw3D0.cache +1 -0
  180. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xG/xGQ1RojQn3N9C51pkj4Flt274TjVuszRi1Puir0p6dE.cache +0 -0
  181. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xN/xNqJDUb7i6VSD0HU-EV3dcNYRoz2d48cGwn1CBqLvVU.cache +1 -0
  182. data/test/dummy/tmp/cache/assets/sprockets/v3.0/y1/y1pwuOg2qdJFc_DgDEw6OIyr6GbmGpwV-p7X2sS64sU.cache +0 -0
  183. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zO/zOWzdA_n0s0vjbJ6IGB8gj1-mbqzbCywIQCMLr71qDE.cache +1 -0
  184. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zV/zVdKofyDUgEZzwP0GQ8q4RxOoxo-qoGazLMre0zxw9c.cache +0 -0
  185. data/test/tmp/config/initializers/wobauth.rb +15 -0
  186. data/test/tmp/config/locales/wobauth.de.yml +42 -0
  187. data/test/tmp/config/locales/wobauth.en.yml +27 -0
  188. metadata +636 -0
@@ -0,0 +1,11 @@
1
+ module Wobauth
2
+ class Users::AuthoritiesController < AuthoritiesController
3
+ before_action :set_authorizable
4
+
5
+ private
6
+
7
+ def set_authorizable
8
+ @authorizable = User.find(params[:user_id])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Wobauth
2
+ class Users::MembershipsController < MembershipsController
3
+ before_action :set_membershipable
4
+
5
+ private
6
+
7
+ def set_membershipable
8
+ @membershipable = User.find(params[:user_id])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,76 @@
1
+ require_dependency "wobauth/application_controller"
2
+
3
+ module Wobauth
4
+ class UsersController < ApplicationController
5
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
6
+ before_action :add_breadcrumb_show, only: [:show]
7
+
8
+ # GET /users
9
+ def index
10
+ @users = User.all
11
+ respond_with(@users)
12
+ end
13
+
14
+ # GET /users/1
15
+ def show
16
+ respond_with(@user)
17
+ end
18
+
19
+ # GET /users/new
20
+ def new
21
+ @user = User.new(new_user_params)
22
+ respond_with(@user)
23
+ end
24
+
25
+ # GET /users/1/edit
26
+ def edit
27
+ end
28
+
29
+ # POST /users
30
+ def create
31
+ @user = User.new(user_params)
32
+
33
+ @user.save
34
+ respond_with(@user)
35
+ end
36
+
37
+ # PATCH/PUT /users/1
38
+ def update
39
+ @user.update(user_params)
40
+ respond_with(@user)
41
+ end
42
+
43
+ # DELETE /users/1
44
+ def destroy
45
+ @user.destroy
46
+ respond_with(@user)
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_user
52
+ @user = User.find(params[:id])
53
+ end
54
+
55
+ # Only allow a trusted parameter "white list" through.
56
+ def user_params
57
+ if params[:user][:password].blank? && action_name == 'update'
58
+ params[:user].delete(:password)
59
+ params[:user].delete(:password_confirmation)
60
+ end
61
+ params.require(:user).permit(
62
+ :username, :gruppen, :sn, :givenname, :displayname,
63
+ :telephone, :email, :password, :password_confirmation,
64
+ :title, :position, :department, :company
65
+ )
66
+ end
67
+
68
+ def new_user_params
69
+ params.slice(
70
+ :username, :gruppen, :sn, :givenname, :displayname,
71
+ :telephone, :email, :password, :password_confirmation,
72
+ :title, :position, :department, :company
73
+ ).permit!
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,60 @@
1
+ module Wobauth
2
+ module AdUsersHelper
3
+ def new_from_aduser_link(model, aduser)
4
+ return unless (aduser.present? && model.present?)
5
+ case aduser_class(model, aduser)
6
+ when "table-danger"
7
+ if can? :create, model
8
+ link_to icon_new, new_polymorphic_path([wobauth, model], aduser_attributes(aduser)),
9
+ class: 'btn btn-danger',
10
+ data: {
11
+ confirm: "Der Eintrag enthält keine E-Mail-Adresse. Wenn es einen ähnlichen Eintrag mit gepflegter E-Mail-Adresse gibt, ist dies hier womöglich der falsche Eintrag. Wollen Sie dennoch weitermachen? Sie können die Daten im folgenden Formular noch korrigieren."
12
+ }
13
+ end
14
+ when "table-primary"
15
+ if can? :create, model
16
+ link_to icon_new, new_polymorphic_path([wobauth, model], aduser_attributes(aduser)),
17
+ class: 'btn btn-primary'
18
+ end
19
+ when "table-success"
20
+ show_link([wobauth, model.where(email: aduser.mail).first])
21
+ end
22
+ end
23
+
24
+ def aduser_class(model, aduser)
25
+ return unless (aduser.present? && model.present?)
26
+ if aduser.mail.blank?
27
+ "table-danger"
28
+ elsif model.exists?(email: aduser.mail)
29
+ "table-success"
30
+ else
31
+ "table-primary"
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def aduser_attributes(aduser)
38
+ {
39
+ username: aduser.username,
40
+ sn: aduser.sn,
41
+ givenname: aduser.givenname,
42
+ displayname: aduser.displayname,
43
+ cn: aduser.cn,
44
+ dn: aduser.dn,
45
+ email: aduser.mail,
46
+ position: aduser.title,
47
+ telephone: aduser.telephonenumber,
48
+ telefax: aduser.facsimiletelephonenumber,
49
+ mobile: aduser.mobile,
50
+ description: aduser.description,
51
+ department: aduser.department,
52
+ company: aduser.company,
53
+ plz: aduser.postalcode,
54
+ ort: aduser.l,
55
+ streetaddress: aduser.streetaddress,
56
+ }
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,53 @@
1
+ module Wobauth
2
+ module ApplicationHelper
3
+ include Wobapphelpers::Helpers::All
4
+
5
+ def polymorphic_selector(form, poly, types, group_method = :all)
6
+ msg = ""
7
+ # -- object available?
8
+ if form.object.send(poly).present?
9
+ msg += poly_type_display(form, poly)
10
+ msg += poly_id_select(form, poly, form.object.send("#{poly}_type"), :all)
11
+ else
12
+ msg += poly_type_select(form, poly, types)
13
+ msg += poly_id_select(form, poly, types, group_method)
14
+ end
15
+ msg.html_safe
16
+ end
17
+
18
+ def navigation_admin_links
19
+ render partial: 'wobauth/shared/admin'
20
+ end
21
+
22
+ def navigation_account_links
23
+ render partial: 'wobauth/shared/accounting'
24
+ end
25
+
26
+ def admin_active_class
27
+ if [:users, :groups, :memberships, :roles, :authorities].include?(controller.controller_name.to_sym)
28
+ "active"
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def poly_type_select(f, poly, types)
35
+ f.input "#{poly}_type".to_sym, collection: types,
36
+ label_method: lambda {|x| t('activerecord.models.' + x.underscore)}
37
+ end
38
+
39
+ def poly_type_display(f, poly)
40
+ f.input("#{poly}_type".to_sym, collection: Array(f.object.send("#{poly}_type")),
41
+ label_method: lambda {|x| t('activerecord.models.' + x.underscore)},
42
+ disabled: true) +
43
+ f.hidden_field("#{poly}_type".to_sym, value: f.object.send("#{poly}_type"))
44
+ end
45
+
46
+ def poly_id_select(f, poly, types, group_method)
47
+ collections = Array(types).map {|t| t.constantize}
48
+ f.input "#{poly}_id".to_sym, collection: collections,
49
+ as: :grouped_select, group_method: group_method
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,9 @@
1
+ module Wobauth
2
+ module AuthoritiesHelper
3
+ def authorized_for_link(authorized_for)
4
+ unless authorized_for.nil?
5
+ link_to authorized_for, main_app.polymorphic_path(authorized_for)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module Wobauth
2
+ class AdUser
3
+ end
4
+ end
@@ -0,0 +1,67 @@
1
+ module Wobauth
2
+ # AdminAbility - abilities for wobauth
3
+ # Mostly you have own abilities for your application.
4
+ # If you need access to Wobauth models for non admin users,
5
+ # there are some restrictions: i.e. navigate to Wobauth::User
6
+ # means AdminAbility is active and your abilities from your application
7
+ # are not visible. Or you may overwrite the default abilities for 'Admin',
8
+ # 'OrgaAdmin' or 'UserAdmin'
9
+ # To resolve this, extend Woauth::AdminAbility
10
+ # Example:
11
+ # role 'UserAdmin' should have only read access to all Wobauth models.
12
+ # Add a new method :user_admin to Wobauth::AdminAbility (separate file
13
+ # in your application) and define abilities for 'UserAdmin' there:
14
+ #
15
+ # --- file your_application/app/models/wobauth_ability.rb
16
+ # require 'wobauth/admin_ability'
17
+ # module Wobauth
18
+ # class AdminAbility
19
+ # include CanCan::Ability
20
+ # def user_admin(rights_for)
21
+ # can :read, [Wobauth::User, Wobauth::Group, ...]
22
+ # can :whateverelse ....
23
+ # end
24
+ # end
25
+ # end
26
+ # ---
27
+ # at least: don't forget to load wobauth_ability.rb
28
+
29
+ class AdminAbility
30
+ include CanCan::Ability
31
+
32
+ def initialize(user)
33
+ @user = user
34
+ return if @user.nil?
35
+ authorities = (@user.authorities + @user.group_authorities)
36
+ add_abilities(authorities)
37
+ end
38
+
39
+ private
40
+ def add_abilities(authorities)
41
+ Array(authorities).each do |authority|
42
+ add_ability(authority)
43
+ end
44
+ end
45
+
46
+ def add_ability(authority)
47
+ role = authority.role.name.underscore
48
+ if respond_to?(role)
49
+ send(role, authority.authorized_for)
50
+ else
51
+ fallback(authority)
52
+ end
53
+ end
54
+
55
+ def fallback(authority)
56
+ role = authority.role.to_s
57
+ if role == 'Admin'
58
+ can :manage, :all
59
+ elsif role == 'UserAdmin'
60
+ can :manage, :all
61
+ elsif role == 'OrgaAdmin'
62
+ can :read, :all
63
+ can :navigate, Wobauth::User
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,17 @@
1
+ module Wobauth
2
+ class Authority < ActiveRecord::Base
3
+ # -- associations
4
+ belongs_to :authorizable, polymorphic: true
5
+ belongs_to :role
6
+ belongs_to :authorized_for, polymorphic: true, optional: true
7
+
8
+ # -- configuration
9
+ # -- validations and callbacks
10
+ validates :authorizable_id, :authorizable_type,
11
+ :role_id, presence: true
12
+
13
+ scope :valid, ->(date) {
14
+ where('(valid_until >= ? OR valid_until is NULL) AND (valid_from <= ? OR valid_from is NULL)', date, date)
15
+ }
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Wobauth
2
+ class Group < ActiveRecord::Base
3
+ # -- associations
4
+ has_many :authorities, as: :authorizable
5
+ has_many :roles, through: :authorities
6
+ has_many :memberships
7
+ has_many :users, -> { uniq }, through: :memberships,
8
+ source: :user
9
+ # -- configuration
10
+ # -- validations and callbacks
11
+ validates :name, :presence => true, :uniqueness => true
12
+
13
+
14
+ def to_s
15
+ name
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module Wobauth
2
+ class Membership < ActiveRecord::Base
3
+ # -- associations
4
+ belongs_to :user
5
+ belongs_to :group
6
+
7
+ # -- configuration
8
+ # -- validations and callbacks
9
+ validates :user_id, :group_id, presence: true
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Wobauth
2
+ class Role < ActiveRecord::Base
3
+ # -- associations
4
+ has_many :authorities
5
+ has_many :users, through: :authorities,
6
+ source: :authorizable,
7
+ source_type: Wobauth::User
8
+ has_many :groups, through: :authorities,
9
+ source: :authorizable,
10
+ source_type: Wobauth::Group
11
+ # -- configuration
12
+ # -- validations and callbacks
13
+ validates :name, :presence => true, :uniqueness => true
14
+
15
+ def to_s
16
+ name
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Wobauth
2
+ class User < ActiveRecord::Base
3
+ # dependencies within wobauth models
4
+   include Wobauth::Concerns::Models::User
5
+
6
+ # Include default devise modules. Others available are:
7
+ # :confirmable, :lockable, :timeoutable and :omniauthable
8
+ devise :database_authenticatable, :registerable,
9
+ :recoverable, :rememberable, :trackable
10
+ end
11
+ end
@@ -0,0 +1,53 @@
1
+ module Wobauth
2
+ class SearchAdUserService
3
+ Result = ImmutableStruct.new( :success?, :error_messages, :ad_users )
4
+
5
+ def initialize(options = {})
6
+ @options = options.symbolize_keys
7
+ @ldap_options = options.fetch(:ldap_options, Wobauth.ldap_options)
8
+ if @ldap_options.blank?
9
+ raise RuntimeError, "ldap_options not set!"
10
+ end
11
+ @query = options.fetch(:query, false)
12
+ end
13
+
14
+ def call
15
+ unless query
16
+ return Result.new(success: false, error_messages: ["no query given"], ad_users: [])
17
+ end
18
+
19
+ ldap = Wobaduser::LDAP.new(ldap_options: ldap_options)
20
+ if ldap.errors.any?
21
+ return Result.new(success: false, error_messages: ldap.errors, ad_users: [])
22
+ end
23
+
24
+ search = Wobaduser::User.search(ldap: ldap, filter: user_filter(query))
25
+ if search.success?
26
+ result = Result.new(success: true, error_messages: [], ad_users: search.entries)
27
+ else
28
+ result = Result.new(success: false, error_messages: search.errors, ad_users: [])
29
+ end
30
+ end
31
+
32
+ private
33
+ attr_reader :query, :ldap_options
34
+
35
+ # use filter in Wobaduser::User.search
36
+ # objectclass=user will be implicit added via Wobaduser::User.filter
37
+ def user_filter(query)
38
+ filter = "(&"
39
+ filter += "(|(sn=#{query}*)(givenName=#{query}*)(mail=#{query}*))"
40
+ filter += "(!(sAMAccountname=admin*))"
41
+ filter += "(!(sAMAccountname=*test*))"
42
+ filter += "(!(sn=*test*))"
43
+ filter += "(!(sn=*admin*))"
44
+ filter += "(!(givenName=*admin*))"
45
+ filter += "(UserAccountControl:1.2.840.113556.1.4.803:=512)"
46
+ filter += "(!(UserAccountControl:1.2.840.113556.1.4.803:=2))"
47
+ filter += "(!(primaryGroupID=512))"
48
+ filter += "(!(msExchHideFromAddressLists=TRUE))"
49
+ filter += ")"
50
+ filter = Net::LDAP::Filter.construct(filter)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,25 @@
1
+ <div class="container">
2
+ <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'card' }) do |f| %>
3
+ <%= f.error_notification %>
4
+
5
+ <div class="card-header">
6
+ <%= form_legend %>
7
+ </div>
8
+
9
+ <div class="card-body">
10
+
11
+ <%= f.input :email, required: true, autofocus: true %>
12
+
13
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
14
+ <p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
15
+ <% end %>
16
+
17
+ <%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %>
18
+ <%= f.input :password_confirmation, required: false %>
19
+ <%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %>
20
+
21
+ <%= f.button :submit, class: 'btn btn-primary' %>
22
+ <%= cancel_button %>
23
+ </div>
24
+ <% end %>
25
+ </div>
@@ -0,0 +1,17 @@
1
+ <div class="container">
2
+ <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name),
3
+ html: { class: 'card'}) do |f| %>
4
+ <div class="card-header">
5
+ <h3>Login</h3>
6
+ </div>
7
+
8
+ <div class="card-body">
9
+ <%= f.input :username, required: true, autofocus: true %>
10
+ <%= f.input :password, required: true %>
11
+
12
+ <%= f.button :submit, "Log in" %>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= render "devise/shared/links" %>
17
+ </div>
File without changes
@@ -0,0 +1,69 @@
1
+ <div class="card col-sm-4 bg-light">
2
+ <div class="card-body p-1 m-1">
3
+ <%= form_tag( url_for(:action => 'index'),
4
+ :class => "") do -%>
5
+ <div class="form-group">
6
+ <label>Name, Vorname oder E-Mail-Adresse:</label>
7
+ <%= text_field_tag :query, '', class: 'form-control'-%>
8
+ </div>
9
+ <% end -%>
10
+ </div>
11
+ </div>
12
+ <br>
13
+
14
+ <table id="adusers" class="table table-bordered table-striped dataTable" role="datatable">
15
+ <thead>
16
+ <tr>
17
+ <th><%= t('attributes.sn') %></th>
18
+ <th><%= t('attributes.givenname') %></th>
19
+ <th><%= t('attributes.ort') %></th>
20
+ <th><%= t('attributes.plz') %></th>
21
+ <th><%= t('attributes.streetaddress') %></th>
22
+ <th><%= t('attributes.department') %></th>
23
+ <th><%= t('attributes.company') %></th>
24
+ <th><%= t('attributes.mail') %></th>
25
+ <th><%= t('attributes.telephonenumber') %></th>
26
+ <th><%= t('attributes.facsimiletelephonenumber') %></th>
27
+ <th><%= t('attributes.mobile') %></th>
28
+ <th><%= t('attributes.username') %></th>
29
+ <th><%= t('wobauth.action') %></th>
30
+ </tr>
31
+ </thead>
32
+ <tfoot>
33
+ <tr>
34
+ <th></th>
35
+ <th></th>
36
+ <th></th>
37
+ <th></th>
38
+ <th></th>
39
+ <th></th>
40
+ <th></th>
41
+ <th></th>
42
+ <th></th>
43
+ <th></th>
44
+ <th></th>
45
+ <th></th>
46
+ <th></th>
47
+ </tr>
48
+ </tfoot>
49
+
50
+ <tbody>
51
+ <% @ad_users.each do |ad_user| %>
52
+ <%= content_tag(:tr, class: aduser_class(Wobauth::User, ad_user)) do %>
53
+ <td><%= ad_user.sn %></td>
54
+ <td><%= ad_user.givenname %></td>
55
+ <td><%= ad_user.l %></td>
56
+ <td><%= ad_user.postalcode %></td>
57
+ <td><%= ad_user.streetaddress %></td>
58
+ <td><%= ad_user.department %></td>
59
+ <td><%= ad_user.company %></td>
60
+ <td><%= ad_user.mail %></td>
61
+ <td><%= ad_user.telephonenumber %></td>
62
+ <td><%= ad_user.facsimiletelephonenumber %></td>
63
+ <td><%= ad_user.mobile %></td>
64
+ <td><%= ad_user.username %></td>
65
+ <td><%= new_from_aduser_link(Wobauth::User, ad_user) %></td>
66
+ <% end %>
67
+ <% end %>
68
+ </tbody>
69
+ </table>
@@ -0,0 +1,32 @@
1
+ <div class="container">
2
+ <%= simple_form_for([wobauth, @authorizable, @authority],
3
+ html: { class: 'form-horizontal card' }
4
+ ) do |f| %>
5
+
6
+ <div class="card-header">
7
+ <%= form_legend %>
8
+ </div>
9
+
10
+ <div class="card-body">
11
+ <%= polymorphic_selector(f,
12
+ 'authorizable',
13
+ Wobauth.authorizable_types,
14
+ Wobauth.authorizable_group_method) %>
15
+ <%= f.association :role %>
16
+ <%= polymorphic_selector(f,
17
+ 'authorized_for',
18
+ Wobauth.authorized_for_types,
19
+ Wobauth.authorized_for_group_method) %>
20
+
21
+ <%= f.input :valid_from, as: :string, class: 'datepicker'
22
+ %>
23
+ <%= f.input :valid_until, as: :string, class: 'datepicker'
24
+ %>
25
+
26
+ <%= f.button :submit, class: 'btn btn-primary' %>
27
+ <%= cancel_button %>
28
+ </div>
29
+ <% end %>
30
+ </div>
31
+
32
+ <%= javascript_include_tag "wobauth/authorities" %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,41 @@
1
+ <h1><%= t('controller.wobauth/authorities') %></h1>
2
+
3
+ <%= content_tag :table, id: :wobauth_authorities, role: :wobauth_datatable,
4
+ class: "table table-bordered table-striped dataTable" do %>
5
+ <thead>
6
+ <tr>
7
+ <th><%= t('attributes.authorizable') %></th>
8
+ <th><%= t('attributes.authorizable_type') %></th>
9
+ <th><%= t('attributes.role') %></th>
10
+ <th><%= t('attributes.authorized_for') %></th>
11
+ <th><%= t('attributes.authorized_for_type') %></th>
12
+ <th><%= t('attributes.valid_from') %></th>
13
+ <th><%= t('attributes.valid_until') %></th>
14
+ <th><%= t('wobauth.action') %></th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+
19
+ <% @authorities.each do |authority| %>
20
+ <%= content_tag_for(:tr, authority) do %>
21
+ <td><%= authority.authorizable %></td>
22
+ <td><%= authority.authorizable_type %></td>
23
+ <td><%= authority.role %></td>
24
+ <td><%= authority.authorized_for %></td>
25
+ <td><%= authority.authorized_for_type %></td>
26
+ <td><%= authority.valid_from %></td>
27
+ <td><%= authority.valid_until %></td>
28
+ <td class="nowrap">
29
+ <%= show_link [wobauth, authority] %>
30
+ <%= edit_link [wobauth, authority] %>
31
+ <%= delete_link [wobauth, authority] %>
32
+ </td>
33
+ <% end %>
34
+ <% end %>
35
+ </tbody>
36
+ <% end %>
37
+
38
+ <br />
39
+
40
+ <%= back_link %>
41
+ <%= new_link [wobauth, Wobauth::Authority] %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,45 @@
1
+ <div class="card">
2
+ <div class="card-header">
3
+ <h4><%= t('activerecord.models.wobauth/authority') %></h4>
4
+ </div>
5
+ <div class="card-body">
6
+ <table class="table table-bordered table-hover autowidth">
7
+ <tr>
8
+ <th><%= t('attributes.authorizable')%>:</th>
9
+ <td><%= @authority.authorizable %></td>
10
+ </tr>
11
+ <tr>
12
+ <th><%= t('attributes.authorizable_type')%>:</th>
13
+ <td><%= @authority.authorizable_type %></td>
14
+ </tr>
15
+ <tr>
16
+ <th><%= t('attributes.role')%>:</th>
17
+ <td><%= @authority.role %></td>
18
+ </tr>
19
+ <tr>
20
+ <th><%= t('attributes.authorized_for')%>:</th>
21
+ <td><%= @authority.authorized_for %></td>
22
+ </tr>
23
+ <tr>
24
+ <th><%= t('attributes.authorized_for_type')%>:</th>
25
+ <td><%= @authority.authorized_for_type %></td>
26
+ </tr>
27
+ <tr>
28
+ <th><%= t('attributes.valid_from')%>:</th>
29
+ <td><%= @authority.valid_from %></td>
30
+ </tr>
31
+ <tr>
32
+ <th><%= t('attributes.valid_until')%>:</th>
33
+ <td><%= @authority.valid_until %></td>
34
+ </tr>
35
+ </table>
36
+ <div role="toolbar">
37
+ <%= back_link %>
38
+ <%= edit_link([wobauth, @authority]) %>
39
+ <%= delete_link([wobauth, @authority]) %>
40
+ <%= new_link [wobauth, Wobauth::Authority] %>
41
+ </div>
42
+ </div>
43
+ </div>
44
+
45
+