jmtrevaskis

Yubiradius 3.5.1 OTP Only - Full patch for adding temptoken

Feb 26th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. --- ropverify.bak.120328 2014-02-27 10:42:30.000000000 +1030
  2. +++ ropverify.php 2014-02-27 10:42:25.000000000 +1030
  3. @@ -42,6 +42,12 @@
  4. $skipLdapAuth = 1;
  5. }
  6.  
  7. +//added to allow 8 digit temporary tokens
  8. +if ($otpOnlyAuthAllow == 1 && $passwdlen == 8) {
  9. + $otp = $passwd;
  10. + $skipLdapAuth = 1;
  11. +}
  12. +
  13. //james debug
  14. if ($debug) {
  15. $myLog->log(LOG_ERR, $otp);
  16. root@spcppv03:/var/www/wsapi/aa# ls
  17. ropverify.140227.diff ropverify.140227full.diff ropverify.bak.120328 ropverify.bak.php ropverify.php
  18. root@spcppv03:/var/www/wsapi/aa# cat ropverify.140227full.diff
  19. --- ropverify.bak.php 2014-02-27 10:43:49.000000000 +1030
  20. +++ ropverify.php 2014-02-27 10:42:25.000000000 +1030
  21. @@ -28,6 +28,34 @@
  22. $timestamp = getHttpVal('timestamp', 0);
  23. $username = strtolower(getHttpVal('user', 0));
  24. $passwd = getHttpVal('password', null);
  25. +
  26. +
  27. +//james vars
  28. +$debug = 0;
  29. +$otpOnlyAuthAllow = 1; //change to enable OTP only
  30. +$skipLdapAuth = 0; //dont edit this one
  31. +
  32. +//james script, if not OTP token, then set passwd as OTP for citrix
  33. +$passwdlen = strlen($passwd);
  34. +if ($otpOnlyAuthAllow == 1 && $passwdlen == 44) {
  35. + $otp = $passwd;
  36. + $skipLdapAuth = 1;
  37. +}
  38. +
  39. +//added to allow 8 digit temporary tokens
  40. +if ($otpOnlyAuthAllow == 1 && $passwdlen == 8) {
  41. + $otp = $passwd;
  42. + $skipLdapAuth = 1;
  43. +}
  44. +
  45. +//james debug
  46. +if ($debug) {
  47. + $myLog->log(LOG_ERR, $otp);
  48. + $myLog->log(LOG_ERR, $passwd);
  49. + $myLog->log(LOG_ERR, $passwdlen);
  50. +}
  51. +
  52. +
  53. if($otp && $username && $passwd){
  54. if($user_domain = seperatUsersAndDomain($username)){
  55. $user = $user_domain[0];
  56. @@ -147,7 +175,7 @@
  57. $appended = seperateTempPass($passwd,$temp_pass_length_from_glob);
  58. if($appended){
  59. $passwd_temp = $appended[0];
  60. - $otp_temp = $appended[1];
  61. + $otp_temp = $appended[1];
  62. }
  63. if(temp_validate_password($otp_temp,$domain,$user)){
  64. if(($confs['domainconf']['temp_passwd_enable']== 1)&&($confs['domainconf']['max_auth_allowed'] > 0)&&($confs['domainconf']['temp_passwd_expiry'] >= date("Y-m-d"))){
  65. @@ -402,6 +430,15 @@
  66. global $confs,$ldap_host,$ldap_port,$ldap_version,$ldap_secured,$ldap_timeout,$ldap_host1,$user_full_name;
  67. $myLog->log(LOG_DEBUG, 'Authenticating with LDAP/AD...');
  68.  
  69. + //james, if password length is 44, it means only token is present, so skip LDAP auth
  70. + global $skipLdapAuth,$debug;
  71. + if ($skipLdapAuth == 1) {
  72. + if ($debug) {
  73. + $myLog->log(LOG_ERR, 'skipping ldap auth');
  74. + }
  75. + return true;
  76. + }
  77. +
  78. // Connect to LDAP server
  79. $ldap_host = $confs["ldapconf"]["host"];
  80. $ldap_port = $confs["ldapconf"]["port"];
  81. @@ -423,14 +460,13 @@
  82. $myLog->log(LOG_DEBUG, "LDAP protocol version: " . $ldap_version);
  83. } else {
  84. $myLog->log(LOG_DEBUG, "Failed to set LDAP protocol version to: " . $ldap_version);
  85. - }
  86. + }
  87.  
  88. $rdn = $confs["domainconf"]["user_dn"];
  89. -
  90. // Bind to LDAP server
  91. $myLog->log(LOG_DEBUG, "Trying to bind to LDAP server with RDN: " . $rdn);
  92.  
  93. - $r = ldap_bind($ds, $rdn, $passwd);
  94. + $r = ldap_bind($ds, $rdn, $passwd);
  95. if(ldap_errno($ds)== -1){
  96. $ds = ldap_connect($ldap_url_1);
  97. if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $ldap_version)) {
  98. @@ -439,7 +475,7 @@
  99. $myLog->log(LOG_ERR, "Failed to set LDAP protocol version to: " . $ldap_version);
  100. }
  101. $r = ldap_bind($ds, $rdn, $passwd);
  102. -
  103. +
  104. }
  105. if(!$r) {
  106. $myLog->log(LOG_ERR, "Failed to bind to LDAP server");
  107. @@ -456,7 +492,7 @@
  108. $user = $confs["domainconf"]["login_name"];
  109. $fullusername = $user . "@". $confs["domainconf"]["domain"];
  110. $myLog->log(LOG_DEBUG, "Login Name:" . $user . "; Full Name: " . $fullusername);
  111. - ldap_close($ds);
  112. + ldap_close($ds);
  113. $myLog->log(LOG_DEBUG, "Successfully bound to LDAP server" . $r);
  114. return true;
  115. }
  116. @@ -471,6 +507,8 @@
  117. }
  118. }
  119.  
  120. +
  121. +
  122. // STEP#3: Verify the mapping
  123. function verificationOfYkmaping($user,$yubikeyid,$fullusername)
  124. {
Add Comment
Please, Sign In to add comment