simplesamlphp in custom web application (session problem) -- need held !!!

348 views
Skip to first unread message

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 6:21:20 AM4/3/18
to SimpleSAMLphp
Hi,

I am using simplesamlphp  in a custom web application.  When users hit my application it takes to authentication and after successful login, it returns to my application. 

Custom Application: Index.php

require_once('/var/www/html/simplesamlphp/lib/_autoload.php');  
$as = new SimpleSAML_Auth_Simple('authtfaga');          
$as->requireAuth();
$attributes = $as->getAttributes();

I am able to get my user attributes successfully.  After I am creating a new session in my application. 

$_SESSION["appusermail"] =$attributes['uid'][0];
if(!empty($_SESSION["appusermail"]))
{
header("Location: home.php");
}
.
After it redirects to home.php, but in home.php I am not able to get my sessions. It throws no session here. 

Home.php:

session_start();
echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';

-- getting an empty array.


But at the same time in index.php all session exists. 


Can anyone help me out, how to solve this problem or did missing something in configuration?  I am totally new to simplesamlphp. 


Thanks,
Mathi
Message has been deleted

Dubravko Voncina

unread,
Apr 3, 2018, 7:46:25 AM4/3/18
to simple...@googlegroups.com
Hi,

Try commenting out the 'session_start()' line:

Home.php:

// session_start();

echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';


Regards,

Dubravko Voncina
Middleware and Data Services Department
University of Zagreb, University Computing Centre, www.srce.unizg.hr
dubravko...@srce.hr, tel: +385 98 219273, fax: +385 1 6165559




On 03 Apr 2018, at 12:16, mat...@cloudnowtech.com wrote:

Hi,

I am using simplesamlphp as idp in a custom web application.  When users hit my application it takes to idp authentication and after successful login, it returns to my application. 


Custom Application: Index.php

require_once('/var/www/html/simplesamlphp/lib/_autoload.php');  
$as = new SimpleSAML_Auth_Simple('authtfaga');          
$as->requireAuth();
$attributes = $as->getAttributes();

I am able to get my user attributes successfully.  After I am creating a new session in my application. 

$_SESSION["appusermail"] =$attributes['uid'][0];
if(!empty($_SESSION["usermail"]))

{
header("Location: home.php");
}
.
After it redirects to home.php, but in home.php I am not able to get my sessions. It throws no session here. 

Home.php:

session_start();
echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';

-- getting an empty array.


But at the same time in index.php all session exists. 


Can anyone help me out, how to solve this problem or did missing something in configuration?  I am totally new to simplesamlphp. 


Thanks,
Mathi



 


-- 
This is a mailing list for users of SimpleSAMLphp, not a support service. If you are willing to buy commercial support, please take a look here:
 
https://simplesamlphp.org/support
 
Before sending your question, make sure it is related to SimpleSAMLphp, and not your web server's configuration or any other third-party software. This mailing list cannot help with software that uses SimpleSAMLphp, only regarding SimpleSAMLphp itself.
 
Make sure to read the documentation:
 
https://simplesamlphp.org/docs/stable/
 
If you have an issue with SimpleSAMLphp that you cannot resolve and reading the documentation doesn't help, you are more than welcome to ask here for help. Subscribe to the list and send an email with your question. However, you will be expected to comply with some minimum, common sense standards in your questions. Please read this carefully:
 
http://catb.org/~esr/faqs/smart-questions.html
--- 
You received this message because you are subscribed to the Google Groups "SimpleSAMLphp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simplesamlph...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 7:52:24 AM4/3/18
to SimpleSAMLphp
Hi Dubravko,

Thank you for your response. I commented and still not able to get my sessions. 

Note: I am using simplesamlphp as idp in my web application for SSO service.


Thanks,
Mathi

Peter Schober

unread,
Apr 3, 2018, 7:54:14 AM4/3/18
to SimpleSAMLphp
* <mat...@cloudnowtech.com> [2018-04-03 13:52]:
> Note: I am using simplesamlphp as idp in my web application for SSO service.

The IDP and the SP only communicate via sending each other standard
SAML protocol messages. So the implemenatation of the other side is
irrelevant (which is the point of having standard protocols).
Your issue does not involve the IDP at all, AFAICT.
-peter

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 8:01:45 AM4/3/18
to SimpleSAMLphp
Hi Peter,

Thank you for your reply. 

But after successful login why my custom application sessions are not showing on other pages? 
In normal login, it works perfectly.  After calling simplesamlphp auth I am not able to get my sessions on other pages of my application.


Thanks,
Mathi

Meijer, Harmen, Bohn Stafleu van Loghum

unread,
Apr 3, 2018, 8:28:12 AM4/3/18
to simple...@googlegroups.com

Hi Mathi,

 

Try this:

 

Index.php:

 

require_once('/var/www/html/simplesamlphp/lib/_autoload.php');  

session_name("myapplicationcookie"); /* important: name and start your application session first. */

session_start();

$_SESSION[appusermail] = ‘unknown’;

$as = new SimpleSAML_Auth_Simple('authtfaga');          

$as->requireAuth();

$attributes = $as->getAttributes();

$session->cleanup(); /* close SSP session and resume your initial application session */

$_SESSION["appusermail"] =$attributes['uid'][0];

if(!empty($_SESSION["appusermail"]))

{

                                header("Location: home.php");

}             

 

home.php:

 

session_name("myapplicationcookie");

session_start();

echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';

 

Regards,

Harmen

--

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 8:56:49 AM4/3/18
to SimpleSAMLphp
Hi Meijer,

Thank you so much for your response.  It works like charm and I can able to get sessions in my home.php file.

But the thing is I am using simplesamlphp as idp in my application. If we close SSP session then users cannot able to login SSO service like G-suite, DropBox etc. So, we need to call again SMAL idp auth for SSO service.  

Can we achieve this without closing SSP sessions?  

Thanks,
Mathi T   

Jaime Perez Crespo

unread,
Apr 3, 2018, 9:06:51 AM4/3/18
to SimpleSAMLphp
Hi Mathi,

On 3 Apr 2018, at 14:56 PM, mat...@cloudnowtech.com wrote:
> Hi Meijer,
>
> Thank you so much for your response. It works like charm and I can able to get sessions in my home.php file.
>
> But the thing is I am using simplesamlphp as idp in my application.

No, you are not. If you are using SimpleSAMLphp’s API to delegate authentication in your application, then you are using it as an SP (Service Provider).

> If we close SSP session then users cannot able to login SSO service like G-suite, DropBox etc. So, we need to call again SMAL idp auth for SSO service.

No, that’s not true. Closing SSP’s session means committing it to the session storage and restoring your own application’s session, not invalidating or destroying SSP’s session in any way. Much less the IdP’s session, which is the entity that G-suite, Dropbox, etc, will contact for authentication. Remember, you are an SP, not an IdP.


Jaime Pérez
UNINETT / Feide

jaime...@uninett.no
jaime...@protonmail.com
9A08 EA20 E062 70B4 616B 43E3 562A FE3A 6293 62C2

"Two roads diverged in a wood, and I, I took the one less traveled by, and that has made all the difference."
- Robert Frost

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 9:11:37 AM4/3/18
to SimpleSAMLphp
Hi Jaime,

Thank you for your clarification. 


Thank you all :) 


Thanks,
Mathi

Meijer, Harmen, Bohn Stafleu van Loghum

unread,
Apr 3, 2018, 9:47:28 AM4/3/18
to simple...@googlegroups.com

Hi Mathi,

 

I assume you found that in my example I forgot to add this line after SSP is loaded:

$session = SimpleSAML_Session::getSessionFromRequest();

Otherwise it fails.

 

Anyway, glad it worked out for you.

 

Regards,

Harmen

Peter Schober

unread,
Apr 3, 2018, 9:56:50 AM4/3/18
to SimpleSAMLphp
* mat...@cloudnowtech.com <mat...@cloudnowtech.com> [2018-04-03 14:01]:
> But after successful login why my custom application sessions are
> not showing on other pages?

Probably because You're Doing It Wrong.

> In normal login, it works perfectly. After calling simplesamlphp
> auth I am not able to get my sessions on other pages of my
> application.

Does the last part of section 6 in the SP docs help?
https://simplesamlphp.org/docs/stable/simplesamlphp-sp#section_6

-peter

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 10:01:00 AM4/3/18
to SimpleSAMLphp
Hi Harmen,

Yeah i used,  $session = SimpleSAML_Session::getSessionFromRequest();. Then only it works correctly.

Anyway, thank you, dude. :)

mat...@cloudnowtech.com

unread,
Apr 3, 2018, 10:02:00 AM4/3/18
to SimpleSAMLphp
Hi Peter,

Yeah now I understood very well and everything is working fine. 

Thank you so much for all :). 

Thanks,
Mathi 
Reply all
Reply to author
Forward
0 new messages