20170924054554_weibo_oauth2.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class WeiboOauth2 < ActiveRecord::Migration[4.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: 'Authentication via %s',
  8. name: 'auth_weibo',
  9. area: 'Security::ThirdPartyAuthentication',
  10. description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
  11. options: {
  12. form: [
  13. {
  14. display: '',
  15. null: true,
  16. name: 'auth_weibo',
  17. tag: 'boolean',
  18. options: {
  19. true => 'yes',
  20. false => 'no',
  21. },
  22. },
  23. ],
  24. },
  25. preferences: {
  26. controller: 'SettingsAreaSwitch',
  27. sub: ['auth_weibo_credentials'],
  28. title_i18n: ['Weibo'],
  29. description_i18n: ['Weibo', 'Sina Weibo Open Portal', 'http://open.weibo.com'],
  30. permission: ['admin.security'],
  31. },
  32. state: false,
  33. frontend: true
  34. )
  35. Setting.create_if_not_exists(
  36. title: 'Weibo App Credentials',
  37. name: 'auth_weibo_credentials',
  38. area: 'Security::ThirdPartyAuthentication::Weibo',
  39. description: 'Enables user authentication via Sina Weibo.',
  40. options: {
  41. form: [
  42. {
  43. display: 'App ID',
  44. null: true,
  45. name: 'app_id',
  46. tag: 'input',
  47. },
  48. {
  49. display: 'App Secret',
  50. null: true,
  51. name: 'app_secret',
  52. tag: 'input',
  53. },
  54. ],
  55. },
  56. state: {},
  57. preferences: {
  58. permission: ['admin.security'],
  59. },
  60. frontend: false
  61. )
  62. end
  63. end