"Fossies" - the Fresh Open Source Software Archive

Member "db/migrate/20170419000001_ldap_support.rb" (25 Mar 2021, 2907 Bytes) of package /linux/www/zammad-4.0.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "20170419000001_ldap_support.rb": 3.5.1_vs_4.0.0.

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