How to create a simple login page

18 views
Skip to first unread message

Stéphane PAUTRAT

unread,
Oct 4, 2017, 8:56:24 AM10/4/17
to SimpleSAMLphp
hi,

I have installed simplesamlphp and I try to make a simple page to realize the login such as:
<?
  require_once($_SERVER['DOCUMENT_ROOT'] . '/../simplesaml/lib/_autoload.php');
 
  $as = new SimpleSAML_Auth_Simple('default-sp');
  $as->requireAuth();
  
  print_r($as);
  exit(0);
  
  $attributes = $as->getAttributes();
?>
<html>
<head><title>My First Service Provider in PHP</title></head>
<body>
<h1>My First SP</h1>
<p>Hello world!</p>
 
<h2>Your attributes:</h2>
<pre><?php print_r($attributes); ?></pre>
 
</body></html>

but every time, this page automatically redirects me to the interface of simplesamlphp to ask me to choose my idp !
ca you help me ?
thanks

Peter Schober

unread,
Oct 4, 2017, 10:46:34 AM10/4/17
to SimpleSAMLphp
* Stéphane PAUTRAT <paut...@gmail.com> [2017-10-04 14:56]:
> *I have installed simplesamlphp and I try to make a simple page to realize
> the login such as:*
>
> *<? require_once($_SERVER['DOCUMENT_ROOT'] .
> '/../simplesaml/lib/_autoload.php'); $as = new
> SimpleSAML_Auth_Simple('default-sp'); $as->requireAuth();
> print_r($as); exit(0); $attributes =
> $as->getAttributes();?><html><head><title>My First Service Provider in
> PHP</title></head><body><h1>My First SP</h1><p>Hello world!</p> <h2>Your
> attributes:</h2><pre><?php print_r($attributes); ?></pre>
> </body></html>

Not sure what the exit(0) is supposed to do here (other than prevent
getAttributes() from running?) but that seems to be close enough to
the documented example:
https://simplesamlphp.org/docs/stable/simplesamlphp-sp#section_6

> but every time, this page automatically redirects me to the
> interface of simplesamlphp to ask me to choose my idp !

You only fail to state where/what the error is.

*If* this deployment is meant to be limited to a single IDP (which you
did not say) and would like to avoid having the subject to select the
IDP (granted, a choice of 1 is nonsensical) you can set the IDP with
an appropriate API method or set it statically with the 'idp'
parameter of the 'saml:SP' authsource (in config/authsources.php).

-peter
Reply all
Reply to author
Forward
0 new messages