20241007093655_open_id_connect_settings.rb 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. class OpenIdConnectSettings < ActiveRecord::Migration[7.1]
  3. def change
  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_openid_connect',
  9. area: 'Security::ThirdPartyAuthentication',
  10. description: 'Enables user authentication via %s.',
  11. options: {
  12. form: [
  13. {
  14. display: '',
  15. null: true,
  16. name: 'auth_openid_connect',
  17. tag: 'boolean',
  18. options: {
  19. true => 'yes',
  20. false => 'no',
  21. },
  22. },
  23. ],
  24. },
  25. preferences: {
  26. controller: 'SettingsAreaSwitch',
  27. sub: ['auth_openid_connect_credentials'],
  28. title_i18n: ['OpenID Connect'],
  29. description_i18n: ['OpenID Connect'],
  30. permission: ['admin.security'],
  31. },
  32. state: false,
  33. frontend: true
  34. )
  35. Setting.create_if_not_exists(
  36. title: 'OpenID Connect Options',
  37. name: 'auth_openid_connect_credentials',
  38. area: 'Security::ThirdPartyAuthentication::OIDC',
  39. description: 'Enables user authentication via OpenID Connect.',
  40. options: {
  41. form: [
  42. {
  43. display: 'Display name',
  44. null: true,
  45. name: 'display_name',
  46. tag: 'input',
  47. placeholder: 'OpenID Connect',
  48. },
  49. {
  50. display: 'Identifier',
  51. null: true,
  52. name: 'identifier',
  53. tag: 'input',
  54. required: true,
  55. placeholder: '',
  56. },
  57. {
  58. display: 'Issuer',
  59. null: true,
  60. name: 'issuer',
  61. tag: 'input',
  62. placeholder: 'https://example.com',
  63. required: true,
  64. },
  65. {
  66. display: 'UID Field',
  67. null: true,
  68. name: 'uid_field',
  69. tag: 'input',
  70. placeholder: 'sub',
  71. help: 'Field that uniquely identifies the user. If unset, "sub" is used.'
  72. },
  73. {
  74. display: 'Scopes',
  75. null: true,
  76. name: 'scope',
  77. tag: 'input',
  78. placeholder: 'openid email profile',
  79. help: 'Scopes that are included, separated by a single space character. If unset, "openid email profile" is used.'
  80. },
  81. ],
  82. },
  83. state: {},
  84. preferences: {
  85. permission: ['admin.security'],
  86. },
  87. frontend: false
  88. )
  89. end
  90. end