20190715141227_saml_auth.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class SamlAuth < 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: 'Authentication via %s',
  8. name: 'auth_saml',
  9. area: 'Security::ThirdPartyAuthentication',
  10. description: 'Enables user authentication via %s.',
  11. options: {
  12. form: [
  13. {
  14. display: '',
  15. null: true,
  16. name: 'auth_saml',
  17. tag: 'boolean',
  18. options: {
  19. true => 'yes',
  20. false => 'no',
  21. },
  22. },
  23. ],
  24. },
  25. preferences: {
  26. controller: 'SettingsAreaSwitch',
  27. sub: ['auth_saml_credentials'],
  28. title_i18n: ['SAML'],
  29. description_i18n: ['SAML'],
  30. permission: ['admin.security'],
  31. },
  32. state: false,
  33. frontend: true
  34. )
  35. Setting.create_if_not_exists(
  36. title: 'SAML App Credentials',
  37. name: 'auth_saml_credentials',
  38. area: 'Security::ThirdPartyAuthentication::SAML',
  39. description: 'Enables user authentication via SAML.',
  40. options: {
  41. form: [
  42. {
  43. display: 'IDP SSO target URL',
  44. null: true,
  45. name: 'idp_sso_target_url',
  46. tag: 'input',
  47. placeholder: 'https://capriza.github.io/samling/samling.html',
  48. },
  49. {
  50. display: 'IDP certificate',
  51. null: true,
  52. name: 'idp_cert',
  53. tag: 'input',
  54. placeholder: '-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----',
  55. },
  56. {
  57. display: 'IDP certificate fingerprint',
  58. null: true,
  59. name: 'idp_cert_fingerprint',
  60. tag: 'input',
  61. placeholder: 'E7:91:B2:E1:...',
  62. },
  63. {
  64. display: 'Name Identifier Format',
  65. null: true,
  66. name: 'name_identifier_format',
  67. tag: 'input',
  68. placeholder: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
  69. },
  70. ],
  71. },
  72. state: {},
  73. preferences: {
  74. permission: ['admin.security'],
  75. },
  76. frontend: false
  77. )
  78. end
  79. end