authentication.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. App.Authentication = DS.Model.extend({
  19. method:DS.attr('boolean'), // use LDAP
  20. primaryServer:DS.attr('string'),
  21. secondaryServer:DS.attr('string'),
  22. useSsl:DS.attr('boolean'),
  23. bindMethod:DS.attr('boolean'), // use credentials
  24. bindUser:DS.attr('string'),
  25. password:DS.attr('string'),
  26. passwordRetype:DS.attr('string'),
  27. searchBaseDn:DS.attr('string'),
  28. usernameAttribute:DS.attr('string')
  29. });
  30. App.Authentication.FIXTURES = [
  31. {
  32. id:1,
  33. method:0,
  34. primary_server:"",
  35. secondary_server:"",
  36. use_ssl:false,
  37. bind_method:0,
  38. bind_user:"",
  39. password:"",
  40. password_retype:"",
  41. search_base_dn:"",
  42. username_attribute:""
  43. }
  44. ]
  45. App.AuthenticationForm = App.Form.extend({
  46. testResult:false,
  47. fieldsOptions:[
  48. { name:"method", displayName:"", isRequired:false, displayType:"select",
  49. values:[
  50. {value:0, label:Em.I18n.t("admin.authentication.form.method.database")},
  51. {value:1, label:Em.I18n.t("admin.authentication.form.method.ldap")}
  52. ]
  53. },
  54. { name:"primaryServer", displayName:Em.I18n.t("admin.authentication.form.primaryServer"), /*validator:'ipaddress',*/
  55. isRequired:function () {
  56. return this.get('form.field.method.value');
  57. }.property('form.field.method.value')
  58. },
  59. { name:"secondaryServer", displayName:Em.I18n.t("admin.authentication.form.secondaryServer"), /*validator:'ipaddress',*/ isRequired:false},
  60. { name:"useSsl", displayName:Em.I18n.t("admin.authentication.form.useSsl"), displayType:"checkbox", isRequired:false },
  61. { name:"bindMethod", displayName:'', displayType:"select", isRequired:false,
  62. values:[
  63. {value:0, label:Em.I18n.t("admin.authentication.form.bind.anonymously")},
  64. {value:1, label:Em.I18n.t("admin.authentication.form.bind.useCrenedtials")}
  65. ]},
  66. { name:"bindUser", displayName:Em.I18n.t('admin.authentication.form.bindUserDN'), isRequired:function () {
  67. return this.get('form.field.bindMethod.value');
  68. }.property('form.field.bindMethod.value')},
  69. { name:"password", displayName:Em.I18n.t('common.password'), displayType:"password",
  70. isRequired:function () {
  71. return this.get('form.field.bindMethod.value');
  72. }.property('form.field.bindMethod.value') },
  73. { name:"passwordRetype", displayName:Em.I18n.t('form.passwordRetype'), displayType:"password",
  74. validator: "passwordRetype",
  75. isRequired:function () {
  76. return this.get('form.field.bindMethod.value');
  77. }.property('form.field.bindMethod.value')},
  78. { name:"searchBaseDn", displayName:Em.I18n.t('admin.authentication.form.searchBaseDN'),
  79. isRequired:function () {
  80. return this.get('form.field.method.value');
  81. }.property('form.field.method.value')
  82. },
  83. { name:"usernameAttribute", displayName:Em.I18n.t('admin.authentication.form.usernameAttribute'),
  84. isRequired:function () {
  85. return this.get('form.field.method.value');
  86. }.property('form.field.method.value')
  87. },
  88. { name:"userDN", displayName:Em.I18n.t('admin.authentication.form.userDN') },
  89. { name:"userPassword", displayName:Em.I18n.t('common.password'), displayType:'password'}
  90. ],
  91. fields:[],
  92. testConfiguration:function () {
  93. console.warn('Configuration test is randomized');
  94. this.set('testResult', parseInt(Math.random() * 2));
  95. return true;
  96. },
  97. testConfigurationMessage:function () {
  98. return this.get('testResult') ? Em.I18n.t('admin.authentication.form.test.success') : Em.I18n.t('admin.authentication.form.test.fail');
  99. }.property('testResult'),
  100. testConfigurationClass:function () {
  101. return this.get('testResult') ? "text-success" : "text-error";
  102. }.property('testConfigurationMessage')
  103. })
  104. ;