20170419000001_ldap_support.rb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class LdapSupport < ActiveRecord::Migration[4.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. if !ActiveRecord::Base.connection.table_exists? 'import_jobs'
  7. create_table :import_jobs do |t|
  8. t.string :name, limit: 250, null: false
  9. t.boolean :dry_run, default: false # rubocop:disable Rails/ThreeStateBooleanColumn
  10. t.text :payload, limit: 80_000
  11. t.text :result, limit: 80_000
  12. t.datetime :started_at # rubocop:disable Zammad/ExistsDateTimePrecision
  13. t.datetime :finished_at # rubocop:disable Zammad/ExistsDateTimePrecision
  14. t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
  15. end
  16. end
  17. Setting.create_or_update(
  18. title: 'Authentication via %s',
  19. name: 'auth_ldap',
  20. area: 'Security::Authentication',
  21. description: 'Enables user authentication via %s.',
  22. preferences: {
  23. title_i18n: ['LDAP'],
  24. description_i18n: ['LDAP'],
  25. permission: ['admin.security'],
  26. },
  27. state: {
  28. adapter: 'Auth::Ldap',
  29. login_attributes: %w[login email],
  30. },
  31. frontend: false
  32. )
  33. Setting.create_if_not_exists(
  34. title: 'LDAP integration',
  35. name: 'ldap_integration',
  36. area: 'Integration::Switch',
  37. description: 'Defines if LDAP is enabled or not.',
  38. options: {
  39. form: [
  40. {
  41. display: '',
  42. null: true,
  43. name: 'ldap_integration',
  44. tag: 'boolean',
  45. options: {
  46. true => 'yes',
  47. false => 'no',
  48. },
  49. },
  50. ],
  51. },
  52. state: false,
  53. preferences: {
  54. prio: 1,
  55. authentication: true,
  56. permission: ['admin.integration'],
  57. },
  58. frontend: true
  59. )
  60. Setting.create_if_not_exists(
  61. title: 'LDAP config',
  62. name: 'ldap_config',
  63. area: 'Integration::LDAP',
  64. description: 'Defines the LDAP config.',
  65. options: {},
  66. state: {},
  67. preferences: {
  68. prio: 2,
  69. permission: ['admin.integration'],
  70. },
  71. frontend: false,
  72. )
  73. Scheduler.create_or_update(
  74. name: 'Import Jobs',
  75. method: 'ImportJob.start_registered',
  76. period: 1.hour,
  77. prio: 1,
  78. active: true,
  79. updated_by_id: 1,
  80. created_by_id: 1
  81. )
  82. Setting.create_if_not_exists(
  83. title: 'Import Backends',
  84. name: 'import_backends',
  85. area: 'Import',
  86. description: 'A list of active import backends that get scheduled automatically.',
  87. options: {},
  88. state: ['Import::Ldap'],
  89. preferences: {
  90. permission: ['admin'],
  91. },
  92. frontend: false
  93. )
  94. end
  95. end