20170713000001_omniauth_office365_setting.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. class OmniauthOffice365Setting < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. Setting.create_if_not_exists(
  6. title: 'Authentication via %s',
  7. name: 'auth_microsoft_office365',
  8. area: 'Security::ThirdPartyAuthentication',
  9. description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
  10. options: {
  11. form: [
  12. {
  13. display: '',
  14. null: true,
  15. name: 'auth_microsoft_office365',
  16. tag: 'boolean',
  17. options: {
  18. true => 'yes',
  19. false => 'no',
  20. },
  21. },
  22. ],
  23. },
  24. preferences: {
  25. controller: 'SettingsAreaSwitch',
  26. sub: ['auth_microsoft_office365_credentials'],
  27. title_i18n: ['Office 365'],
  28. description_i18n: ['Office 365', 'Microsoft Application Registration Portal', 'https://apps.dev.microsoft.com'],
  29. permission: ['admin.security'],
  30. },
  31. state: false,
  32. frontend: true
  33. )
  34. Setting.create_if_not_exists(
  35. title: 'Office 365 App Credentials',
  36. name: 'auth_microsoft_office365_credentials',
  37. area: 'Security::ThirdPartyAuthentication::Office365',
  38. description: 'Enables user authentication via Office 365.',
  39. options: {
  40. form: [
  41. {
  42. display: 'App ID',
  43. null: true,
  44. name: 'app_id',
  45. tag: 'input',
  46. },
  47. {
  48. display: 'App Secret',
  49. null: true,
  50. name: 'app_secret',
  51. tag: 'input',
  52. },
  53. ],
  54. },
  55. state: {},
  56. preferences: {
  57. permission: ['admin.security'],
  58. },
  59. frontend: false
  60. )
  61. end
  62. end