@@ -1242,6 +1242,40 @@ protected function _perform_ldap_auth($username = '', $password = NULL)
1242
1242
return true ;
1243
1243
}
1244
1244
1245
+ /**
1246
+ * Perform Library Authentication - Override this function to change the way the library is called
1247
+ *
1248
+ * @param string $username The username to validate
1249
+ * @param string $password The password to validate
1250
+ * @return boolean
1251
+ */
1252
+ protected function _perform_library_auth ($ username = '' , $ password = NULL )
1253
+ {
1254
+ if (empty ($ username ))
1255
+ {
1256
+ log_message ('debug ' , 'Library Auth: failure, empty username ' );
1257
+ return false ;
1258
+ }
1259
+
1260
+ $ auth_library_class = strtolower ($ this ->config ->item ('auth_library_class ' ));
1261
+ $ auth_library_function = strtolower ($ this ->config ->item ('auth_library_function ' ));
1262
+
1263
+ if (empty ($ auth_library_class ))
1264
+ {
1265
+ log_message ('debug ' , 'Library Auth: failure, empty auth_library_class ' );
1266
+ return false ;
1267
+ }
1268
+
1269
+ if (empty ($ auth_library_function ))
1270
+ {
1271
+ log_message ('debug ' , 'Library Auth: failure, empty auth_library_function ' );
1272
+ return false ;
1273
+ }
1274
+
1275
+ $ this ->load ->library ($ auth_library_class );
1276
+ return $ this ->$ auth_library_class ->$ auth_library_function ($ username , $ password );
1277
+ }
1278
+
1245
1279
/**
1246
1280
* Check if the user is logged in.
1247
1281
*
@@ -1264,6 +1298,12 @@ protected function _check_login($username = '', $password = NULL)
1264
1298
return $ this ->_perform_ldap_auth ($ username , $ password );
1265
1299
}
1266
1300
1301
+ if ($ auth_source == 'library ' )
1302
+ {
1303
+ log_message ('debug ' , 'performing Library authentication for $username ' );
1304
+ return $ this ->_perform_library_auth ($ username , $ password );
1305
+ }
1306
+
1267
1307
$ valid_logins = $ this ->config ->item ('rest_valid_logins ' );
1268
1308
1269
1309
if ( ! array_key_exists ($ username , $ valid_logins ))
0 commit comments