20200121000001_smime_support.rb 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class SMIMESupport < ActiveRecord::Migration[5.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. Setting.create_if_not_exists(
  7. title: 'S/MIME integration',
  8. name: 'smime_integration',
  9. area: 'Integration::Switch',
  10. description: 'Defines if S/MIME encryption is enabled or not.',
  11. options: {
  12. form: [
  13. {
  14. display: '',
  15. null: true,
  16. name: 'smime_integration',
  17. tag: 'boolean',
  18. options: {
  19. true => 'yes',
  20. false => 'no',
  21. },
  22. },
  23. ],
  24. },
  25. state: false,
  26. preferences: {
  27. prio: 1,
  28. authentication: true,
  29. permission: ['admin.integration'],
  30. },
  31. frontend: true
  32. )
  33. Setting.create_if_not_exists(
  34. title: 'S/MIME config',
  35. name: 'smime_config',
  36. area: 'Integration::SMIME',
  37. description: 'Defines the S/MIME config.',
  38. options: {},
  39. state: {},
  40. preferences: {
  41. prio: 2,
  42. permission: ['admin.integration'],
  43. },
  44. frontend: true,
  45. )
  46. Setting.create_if_not_exists(
  47. title: 'Defines postmaster filter.',
  48. name: '0016_postmaster_filter_smime',
  49. area: 'Postmaster::PreFilter',
  50. description: 'Defines postmaster filter to handle secure mailing.',
  51. options: {},
  52. state: 'Channel::Filter::SecureMailing',
  53. frontend: false
  54. )
  55. create_table :smime_certificates do |t|
  56. t.string :subject, limit: 500, null: false
  57. t.string :doc_hash, limit: 250, null: false
  58. t.string :fingerprint, limit: 250, null: false
  59. t.string :modulus, limit: 1024, null: false
  60. t.datetime :not_before_at, null: true # rubocop:disable Zammad/ExistsDateTimePrecision
  61. t.datetime :not_after_at, null: true # rubocop:disable Zammad/ExistsDateTimePrecision
  62. t.binary :raw, limit: 10.megabytes, null: false
  63. t.binary :private_key, limit: 10.megabytes, null: true
  64. t.string :private_key_secret, limit: 500, null: true
  65. t.timestamps limit: 3, null: false
  66. end
  67. add_index :smime_certificates, [:fingerprint], unique: true
  68. add_index :smime_certificates, [:modulus]
  69. add_index :smime_certificates, [:subject]
  70. end
  71. end