2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-09-08 08:28:34 +00:00
|
|
|
class LdapSupport < ActiveRecord::Migration[4.2]
|
2017-04-19 10:09:54 +00:00
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2017-04-19 10:09:54 +00:00
|
|
|
|
2017-04-19 13:00:51 +00:00
|
|
|
if !ActiveRecord::Base.connection.table_exists? 'import_jobs'
|
|
|
|
create_table :import_jobs do |t|
|
|
|
|
t.string :name, limit: 250, null: false
|
2017-04-19 10:09:54 +00:00
|
|
|
|
2017-04-19 13:00:51 +00:00
|
|
|
t.boolean :dry_run, default: false
|
2017-04-19 10:09:54 +00:00
|
|
|
|
2017-04-19 13:00:51 +00:00
|
|
|
t.text :payload, limit: 80_000
|
|
|
|
t.text :result, limit: 80_000
|
2017-04-19 10:09:54 +00:00
|
|
|
|
2020-10-27 09:37:21 +00:00
|
|
|
t.datetime :started_at # rubocop:disable Zammad/ExistsDateTimePrecision
|
|
|
|
t.datetime :finished_at # rubocop:disable Zammad/ExistsDateTimePrecision
|
2017-04-19 10:09:54 +00:00
|
|
|
|
2020-10-27 09:37:21 +00:00
|
|
|
t.timestamps null: false # rubocop:disable Zammad/ExistsDateTimePrecision
|
2017-04-19 13:00:51 +00:00
|
|
|
end
|
2017-04-19 10:09:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Setting.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Authentication via %s',
|
|
|
|
name: 'auth_ldap',
|
|
|
|
area: 'Security::Authentication',
|
2017-04-19 10:09:54 +00:00
|
|
|
description: 'Enables user authentication via %s.',
|
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
title_i18n: ['LDAP'],
|
2017-04-19 10:09:54 +00:00
|
|
|
description_i18n: ['LDAP'],
|
2018-12-19 17:31:51 +00:00
|
|
|
permission: ['admin.security'],
|
2017-04-19 10:09:54 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: {
|
2017-04-19 10:09:54 +00:00
|
|
|
adapter: 'Auth::Ldap',
|
2017-11-23 08:09:44 +00:00
|
|
|
login_attributes: %w[login email],
|
2017-04-19 10:09:54 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false
|
2017-04-19 10:09:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'LDAP integration',
|
|
|
|
name: 'ldap_integration',
|
|
|
|
area: 'Integration::Switch',
|
2017-04-19 10:09:54 +00:00
|
|
|
description: 'Defines if LDAP is enabled or not.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2017-04-19 10:09:54 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: true,
|
|
|
|
name: 'ldap_integration',
|
|
|
|
tag: 'boolean',
|
2017-04-19 10:09:54 +00:00
|
|
|
options: {
|
|
|
|
true => 'yes',
|
|
|
|
false => 'no',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: false,
|
2017-04-19 10:09:54 +00:00
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
prio: 1,
|
2017-04-19 10:09:54 +00:00
|
|
|
authentication: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
permission: ['admin.integration'],
|
2017-04-19 10:09:54 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: true
|
2017-04-19 10:09:54 +00:00
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'LDAP config',
|
|
|
|
name: 'ldap_config',
|
|
|
|
area: 'Integration::LDAP',
|
2017-04-19 10:09:54 +00:00
|
|
|
description: 'Defines the LDAP config.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {},
|
|
|
|
state: {},
|
2017-04-19 10:09:54 +00:00
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
prio: 2,
|
2017-04-19 10:09:54 +00:00
|
|
|
permission: ['admin.integration'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2017-04-19 10:09:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
Scheduler.create_or_update(
|
|
|
|
name: 'Import Jobs',
|
2017-04-19 13:00:51 +00:00
|
|
|
method: 'ImportJob.start_registered',
|
2017-04-19 10:09:54 +00:00
|
|
|
period: 1.hour,
|
|
|
|
prio: 1,
|
|
|
|
active: true,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1
|
|
|
|
)
|
|
|
|
|
2017-04-19 13:00:51 +00:00
|
|
|
Setting.create_if_not_exists(
|
|
|
|
title: 'Import Backends',
|
|
|
|
name: 'import_backends',
|
|
|
|
area: 'Import',
|
|
|
|
description: 'A list of active import backends that get scheduled automatically.',
|
|
|
|
options: {},
|
|
|
|
state: ['Import::Ldap'],
|
|
|
|
preferences: {
|
|
|
|
permission: ['admin'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false
|
2017-04-19 13:00:51 +00:00
|
|
|
)
|
|
|
|
|
2017-04-19 10:09:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|