2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-06-02 11:01:16 +00:00
|
|
|
class SMIMESupport < ActiveRecord::Migration[5.2]
|
|
|
|
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')
|
2020-06-02 11:01:16 +00:00
|
|
|
|
|
|
|
Setting.create_if_not_exists(
|
|
|
|
title: 'S/MIME integration',
|
|
|
|
name: 'smime_integration',
|
|
|
|
area: 'Integration::Switch',
|
|
|
|
description: 'Defines if S/MIME encryption is enabled or not.',
|
|
|
|
options: {
|
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
|
|
|
null: true,
|
|
|
|
name: 'smime_integration',
|
|
|
|
tag: 'boolean',
|
|
|
|
options: {
|
|
|
|
true => 'yes',
|
|
|
|
false => 'no',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
state: false,
|
|
|
|
preferences: {
|
|
|
|
prio: 1,
|
|
|
|
authentication: true,
|
|
|
|
permission: ['admin.integration'],
|
|
|
|
},
|
|
|
|
frontend: true
|
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
|
|
|
title: 'S/MIME config',
|
|
|
|
name: 'smime_config',
|
|
|
|
area: 'Integration::SMIME',
|
|
|
|
description: 'Defines the S/MIME config.',
|
|
|
|
options: {},
|
|
|
|
state: {},
|
|
|
|
preferences: {
|
|
|
|
prio: 2,
|
|
|
|
permission: ['admin.integration'],
|
|
|
|
},
|
|
|
|
frontend: true,
|
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
|
|
|
title: 'Defines postmaster filter.',
|
|
|
|
name: '0016_postmaster_filter_smime',
|
|
|
|
area: 'Postmaster::PreFilter',
|
|
|
|
description: 'Defines postmaster filter to handle secure mailing.',
|
|
|
|
options: {},
|
|
|
|
state: 'Channel::Filter::SecureMailing',
|
|
|
|
frontend: false
|
|
|
|
)
|
|
|
|
|
|
|
|
create_table :smime_certificates do |t|
|
|
|
|
t.string :subject, limit: 500, null: false
|
|
|
|
t.string :doc_hash, limit: 250, null: false
|
|
|
|
t.string :fingerprint, limit: 250, null: false
|
|
|
|
t.string :modulus, limit: 1024, null: false
|
2020-10-27 09:37:21 +00:00
|
|
|
t.datetime :not_before_at, null: true # rubocop:disable Zammad/ExistsDateTimePrecision
|
|
|
|
t.datetime :not_after_at, null: true # rubocop:disable Zammad/ExistsDateTimePrecision
|
2020-06-02 11:01:16 +00:00
|
|
|
t.binary :raw, limit: 10.megabytes, null: false
|
|
|
|
t.binary :private_key, limit: 10.megabytes, null: true
|
2020-06-22 09:57:45 +00:00
|
|
|
t.string :private_key_secret, limit: 500, null: true
|
2020-06-02 11:01:16 +00:00
|
|
|
t.timestamps limit: 3, null: false
|
|
|
|
end
|
|
|
|
add_index :smime_certificates, [:fingerprint], unique: true
|
|
|
|
add_index :smime_certificates, [:modulus]
|
|
|
|
add_index :smime_certificates, [:subject]
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|