Setting up SimpleSAMLphp as a SP for CodeIgniter - codeigniter-3

I have to continue on an already existing CodeIgniter 3 application (not written by me) which contains multiple applications for different customers, the project structure looks a little like this:
root/
applications/
customer1/
config/, controllers/, models/, views/, ...
third_party/
SimpleSAMLphp/
config/, metadata/, www/, ...
lib/
_autoload.php
customer2/
...
assets/, bundle/, ...
customers/
customer1/
assets/, index.php, ...
customer2/
...
system/
vendor/
composer/
autoload.php
Now for one of the applications I have to replace the ion_auth system with an SSO (setup as a Service Provider from their IdP metadata). I googled a lot and tought SimpleSAMLphp would be my best option.
But I am really struggling just even putting the SimpleSAMLphp SP API into my application and the documentation isn't great.
-I "include_once" the third_party/SimpleSAMLphp/lib/_autoload.php file in the customers/customer1/index.php file (before require_once BASEPATH...)
-I modified third_party/SimpleSAMLphp/lib/_autoload.php so it finds the vendor/autoload.php file
I expect to be able to use the methods of the SimpleSAMLphp library but instead I get the following errors:
-If I follow the code in this guide:
Fatal error: Call to undefined function SimpleSAML\Auth\Simple()
-If use include APPPATH . 'third_party\SimpleSAMLphp\www\index.php in my controller just above the code from above tutorial:
Fatal error: Class 'SimpleSAML\Error\Assertion' not found in
What am I doing wrong in my setup?

Related

setting dropbox as custom backp on whm/cpanel error

I am trying to set dropbox as custom backup destination following below cpanel blog. The connection is working, but the backup files are not being transferred to DropBox. And when I press validate to custom backup destination it gives following error .
https://blog.cpanel.com/cpanel-whm-custom-backup-transport-example-dropbox/
Error: Validation for transport “dropbox” failed: Could not list files in
destination: Executed /usr/local/bin/backup_transport_dropbox.pl ls /
remotehost remoteuser : 2018-08-26T15:54:21 [WebService::Dropbox] [ERROR]
https://api.dropboxapi.com/2/files/list_folder {"path":"/"} -> [400] Error in
call to API function "files/list_folder": request body: path: Specify the root
folder as an empty string rather than as "/". at
/usr/local/share/perl5/WebService/Dropbox.pm line 184.
I am new to dropbox api and have no idea of perl so could not figure out what is discusses on below links.
https://github.com/silexlabs/unifile/issues/77
The error message is correctly indicating that the Dropbox API expects the value "" when referring to the root alone. The code is instead sending the value "/". This looks like a bug in the code.
It looks like you've already opened an issue with the developer for this:
https://github.com/CpanelInc/backup-transport-dropbox/issues/3
They should update the code to use "" when referring to the root folder on Dropbox.

Why I get 500 Error while on XAMPP while loading CodeIgniter 3 database library?

I have gone through number of threads on stackoverflow and on other forums to find the answer but could not find relevant answer. People have applied different approaches but none has worked for me thus far.
I am using CI 3 on XAMPP and whenever I load database library in the model, I run into 500 Error.
Here is my CI database config info:
'hostname' => 'localhost',
'username' => 'my_user',
'password' => 'my_pass',
'database' => 'prod_db',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
PHP ini db libraries are as below:
extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
;extension=php_ftp.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
My model code is as below:
class loginmodel extends CI_Model {
public function validate_login($username, $password) {
$this->load->database();
$var = 0;
return $var;
}
}
Whenever I remove $this->load->database(); from the model, my code runs and i am able to redirect to a "Login Failed" page. BUT, whenever I load my database library in autoload.php or load it in above model, code fails.
Autoload.php
$autoload['libraries'] = array('database');
Apache error logs showed below errors but I could not figure as why this was happening.
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_pdo_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
Please advise.
EDIT:
I verified all config to be OK and as stated in the comments, I added environment variables to windows and verified through PHPInfo that mysqli and mysqlnd were loaded.
Despite getting all the config right, error still persisted and I did a clean install of CI to reproduce library load failure. This time CI returned an error that db access was denied.
I then realized that after migration, database user was not created in the new environment. So once I created the desired user and assigned it required privileges, I was able to run the code just fine.
Therefore, if anyone encounters such issue in future, below steps might help:
First and foremost, verify if your desired user can access the
database.
Modify your .htaccess to use your desired URL schemes only after
verifying that database connection is working
Then verify that absolute path is available in PHP.ini on XAMPP.
Plus, verify that PHP is added in the environment variables. My
Values on Windows 10 are as follows: Variable Name: PHP , Variable
Value: C:\xampp\php\ext
In CI, mysqli is selected as database driver
In PHP.ini mysqli extension is enabled. i.e. php_mysqli.dll
Echo PHPInfo to verify that mysqli and mysqlnd are available in your
installation.
If nothing works, do a clean install of CI on a separate directory and load database library after setting up your database configuration and before setting up .htaccess until you can reproduce the error.
Hope that error will be eliminated!

How to resolve undef error in ejabberd hook

I have added a customized module named mod_confirm_delivery in ejabberd which has compiled and added successfully but when i am sending a message an error is coming in my ejabberd error log file, That is:
2016-03-15 17:03:38.306 [error] <0.2653.0>#ejabberd_hooks:run_fold1:368 {undef,[{mod_confirm_delivery,send_packet,[{xmlel,<<"iq">>,[{<<"xml:lang">>,<<"en">>},{<<"type">>,<<"get">>},{<<"id">>,<<"aacfa">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"query">>,[{<<"xmlns">>,<<"jabber:iq:roster">>}],[]},{xmlcdata,<<"\n">>}]},{state,{socket_state,gen_tcp,#Port<0.58993>,<0.2652.0>},ejabberd_socket,#Ref<0.0.1.25301>,false,<<"12664578908237388886">>,undefined,c2s,c2s_shaper,false,false,false,false,[verify_none,compression_none],true,{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},<<"test1">>,<<"localhost">>,<<"D-5">>,{{1458,41617,630679},<0.2653.0>},{2,{{<<"test2">>,<<"localhost">>,<<>>},{{<<"test1">>,<<"localhost">>,<<>>},nil,nil},nil}},{2,{{<<"test2">>,<<"localhost">>,<<>>},{{<<"test1">>,<<"localhost">>,<<>>},nil,nil},nil}},{0,nil},undefined,undefined,{userlist,none,[],false},c2s,ejabberd_auth_internal,{{127,0,0,1},41928},[],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,true,<<"en">>},{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},{jid,<<"test1">>,<<"localhost">>,<<>>,<<"test1">>,<<"localhost">>,<<>>}],[]},{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run_fold1,4,[{file,"src/ejabberd_hooks.erl"},{line,365}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1268}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
I have ejabberd 16.02.26 and my module code is:
mod_confirm_delivery.erl
This module is working fine with ejabberd 2.1.13 but i want to upgraded my ejabberd. I can't understand what is the problem and how can I resolve this error.
undef error means the function or module is not found. The most likely error is that the mod_confirm_delivery.beam file is not in Erlang VM path.
You should try moving the compiled beam file with other ejabberd beam files or try setting the path used to launch Erlang to the directory where your mod_confirm_delivery.beam file is located. This is the -pa option of the Erlang VM.
If your code if in right place, other option is that the function is undefined. The hook tries to call mod_confirm_delivery:send_packet/4. Your code is wrong as it indeed does not defined send_packet/4 but only send_packet/3. You need to update your code to match new signature for user_send_packet hook:
user_send_packet(Packet, C2SState, From, To) -> Packet
In case of doubt, you can refer to official hook list in ejabberd documentation: https://docs.ejabberd.im/developer/hooks/

OFBiz-11.04 deployment in JBoss-5.1.0

In order to get flexibility in load balancing and clustering, I thought of deploying my OFBiz application in JBoss-5.1.0 as per document (https://cwiki.apache.org/OFBTECH/deploying-ofbiz-904-on-jboss-510.html).
Build was successful and I could see all WAR files in server/default/deploy/OFBiz.ear and other JAR files in lib folder. But I am getting a few issues when starting JBoss server. Please take a look and help me if you have any clues.
Issues:
Could not find definition for entity name EntityKeyStore
......................
Could not find definition for entity name JobSandbox
...................
Entity definitions for EntityKeyStore is located in entitymodel.xml of framework/entity/entitydef folder. I could not find this xml anywhere inside OFBiz.ear. (Not only this XML, none of the entitymodel.xml s are found in ear. But no issue with other entities. I do not know why it is so). I checked my database (server/default/data/derby) and found out ENTITY_KEY_STORE there.
The same is the case for JobSandBox.
After this exception, the server seems to proceed with creating dispatcher for each component and it started with accounting. I am getting another issue here.
Could not get root location for component with name [common], error was: org.ofbiz.base.component.ComponentException: No component found named : common
.....
....
....
---- exception report ----------------------------------------------------------
Error processing include at [component://common/webcommon/WEB-INF/common-controller.xml]:java.net.MalformedURLException: Could not get root location for component with name [common], error was: org.ofbiz.base.component.ComponentException: No component found named : common
Exception: java.net.MalformedURLException
This exception is repeatedly printed in log file. And down the line, the same kind of exception is thrown for other components like commonext, accounting and ecommerce.
After these exceptions "Could not find definition for entity name Tenant" is also thrown.
My OFBiz application uses a multitenant environment. Any help is greatly appreciated.

wsdl xmlns problems with NetBeans and wsimport

Our application provides a SOAP API. Our wsdl starting lines are something like
<wsdl:definitions name='ControlDServices' ... xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' ...
This usually works OK, but a customer complained that when they try to use our SOAP API in NetBeans with the wsdl we provide they got this error:
Web Service can not be created by JAXWS:wsimport utility.
Reason: invalid extension element: "soap:body" (in namespace "http://schemas.xmlsoap.org/wsdl/soap/")
This can be easily recreated by running:
wsimport -d . -extension -Xnocompile -keep -s . -verbose <our wsdl file>
wihch yield the error:
[ERROR] invalid extension element: "soap:body" (in namespace "http://schemas.xmlsoap.org/wsdl/soap/")
unknown location
Our support discovered that changing the xmlns:soap definition to use http://www.w3.org/2001/12/soap-envelope/ solves the problem, but this requires a change in our product, and also contradict most of the places I see on the web where a wsdl:definitions file is defined. Besides, that URI seems to belong to soap-envelop and not to wsdl, and is also for a specific date, and not a general URI.
Is there a way to solve the NetBeans / wsimport problem without changing our wsdl, e.g. by changing parameters? If no, and a change is needed, is it wise to change it to http://www.w3.org/2001/12/soap-envelope/, or should we use something else?
Thanks
splintor
It looks like they don't support SOAP 1.1, only SOAP 1.2.