ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
Auth_Controller Class Reference
+ Collaboration diagram for Auth_Controller:

Public Member Functions

 Auth_Controller (&$auth_obj, $login='login.php', $default='index.php', $accessList=array())
 Constructor. More...
 
 setAutoRedirectBack ($flag=true)
 Enables auto redirection when login is done. More...
 
 redirectBack ()
 Redirects Back to the calling page. More...
 
 redirectLogin ()
 Redirects to the login Page if not authorised. More...
 
 start ()
 Starts the Auth Procedure. More...
 
 isAuthorised ()
 Checks is the user is logged on. More...
 
 checkAuth ()
 Proxy call to auth. More...
 
 logout ()
 Proxy call to auth. More...
 
 getUsername ()
 Proxy call to auth. More...
 
 getStatus ()
 Proxy call to auth. More...
 

Data Fields

 $auth = null
 
 $login = null
 
 $default = null
 
 $autoRedirectBack = false
 

Detailed Description

Definition at line 61 of file Controller.php.

Member Function Documentation

◆ Auth_Controller()

Auth_Controller::Auth_Controller ( $auth_obj,
  $login = 'login.php',
  $default = 'index.php',
  $accessList = array() 
)

Constructor.

Parameters
AuthAn auth instance
stringThe login page
stringThe default page to go to if return page is not set
arraySome rules about which urls need to be sent to the login page
Returns
void
Todo:
Add a list of urls which need redirection

Definition at line 107 of file Controller.php.

References $_GET, $default, and $login.

108  {
109  $this->auth =& $auth_obj;
110  $this->_loginPage = $login;
111  $this->_defaultPage = $default;
112  @session_start();
113  if (!empty($_GET['return']) && $_GET['return'] && !strstr($_GET['return'], $this->_loginPage)) {
114  $this->auth->setAuthData('returnUrl', $_GET['return']);
115  }
116 
117  if(!empty($_GET['authstatus']) && $this->auth->status == '') {
118  $this->auth->status = $_GET['authstatus'];
119  }
120  }
$_GET["client_id"]

◆ checkAuth()

Auth_Controller::checkAuth ( )

Proxy call to auth.

See also
Auth::checkAuth()

Definition at line 257 of file Controller.php.

258  {
259  return($this->auth->checkAuth());
260  }

◆ getStatus()

Auth_Controller::getStatus ( )

Proxy call to auth.

See also
Auth::getStatus()

Definition at line 293 of file Controller.php.

294  {
295  return($this->auth->getStatus());
296  }

◆ getUsername()

Auth_Controller::getUsername ( )

Proxy call to auth.

See also
Auth::getUsername()

Definition at line 281 of file Controller.php.

282  {
283  return($this->auth->getUsername());
284  }

◆ isAuthorised()

Auth_Controller::isAuthorised ( )

Checks is the user is logged on.

See also
Auth::checkAuth()

Definition at line 245 of file Controller.php.

246  {
247  return($this->auth->checkAuth());
248  }

◆ logout()

Auth_Controller::logout ( )

Proxy call to auth.

See also
Auth::logout()

Definition at line 269 of file Controller.php.

270  {
271  return($this->auth->logout());
272  }

◆ redirectBack()

Auth_Controller::redirectBack ( )

Redirects Back to the calling page.

Returns
void

Definition at line 145 of file Controller.php.

References $url.

Referenced by start().

146  {
147  // If redirectback go there
148  // else go to the default page
149 
150  $returnUrl = $this->auth->getAuthData('returnUrl');
151  if(!$returnUrl) {
152  $returnUrl = $this->_defaultPage;
153  }
154 
155  // Add some entropy to the return to make it unique
156  // avoind problems with cached pages and proxies
157  if(strpos($returnUrl, '?') === false) {
158  $returnUrl .= '?';
159  }
160  $returnUrl .= uniqid('');
161 
162  // Track the auth status
163  if($this->auth->status != '') {
164  $url .= '&authstatus='.$this->auth->status;
165  }
166  header('Location:'.$returnUrl);
167  print("You could not be redirected to <a href=\"$returnUrl\">$returnUrl</a>");
168  }
$url
Definition: shib_logout.php:72
+ Here is the caller graph for this function:

◆ redirectLogin()

Auth_Controller::redirectLogin ( )

Redirects to the login Page if not authorised.

put return page on the query or in auth

Returns
void

Definition at line 180 of file Controller.php.

References $_SERVER, and $url.

Referenced by start().

181  {
182  // Go to the login Page
183 
184  // For Auth, put some check to avoid infinite redirects, this should at least exclude
185  // the login page
186 
187  $url = $this->_loginPage;
188  if(strpos($url, '?') === false) {
189  $url .= '?';
190  }
191 
192  if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage)) {
193  $url .= 'return='.urlencode($_SERVER['PHP_SELF']);
194  }
195 
196  // Track the auth status
197  if($this->auth->status != '') {
198  $url .= '&authstatus='.$this->auth->status;
199  }
200 
201  header('Location:'.$url);
202  print("You could not be redirected to <a href=\"$url\">$url</a>");
203  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$url
Definition: shib_logout.php:72
+ Here is the caller graph for this function:

◆ setAutoRedirectBack()

Auth_Controller::setAutoRedirectBack (   $flag = true)

Enables auto redirection when login is done.

Parameters
boolSets the autoRedirectBack flag to this
See also
Auth_Controller::autoRedirectBack
Returns
void

Definition at line 132 of file Controller.php.

133  {
134  $this->autoRedirectBack = $flag;
135  }

◆ start()

Auth_Controller::start ( )

Starts the Auth Procedure.

If the page requires login the user is redirected to the login page otherwise the Auth::start is called to initialize Auth

Returns
void
Todo:
Implement an access list which specifies which urls/pages need login and which do not

Definition at line 217 of file Controller.php.

References $_SERVER, redirectBack(), and redirectLogin().

218  {
219  // Check the accessList here
220  // ACL should be a list of urls with allow/deny
221  // If allow set allowLogin to false
222  // Some wild card matching should be implemented ?,*
223  if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage) && !$this->auth->checkAuth()) {
224  $this->redirectLogin();
225  } else {
226  $this->auth->start();
227  // Logged on and on login page
228  if(strstr($_SERVER['PHP_SELF'], $this->_loginPage) && $this->auth->checkAuth()){
229  $this->autoRedirectBack ?
230  $this->redirectBack() :
231  null ;
232  }
233  }
234 
235 
236  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
redirectLogin()
Redirects to the login Page if not authorised.
Definition: Controller.php:180
redirectBack()
Redirects Back to the calling page.
Definition: Controller.php:145
+ Here is the call graph for this function:

Field Documentation

◆ $auth

Auth_Controller::$auth = null

Definition at line 71 of file Controller.php.

◆ $autoRedirectBack

Auth_Controller::$autoRedirectBack = false

Definition at line 92 of file Controller.php.

◆ $default

Auth_Controller::$default = null

Definition at line 84 of file Controller.php.

Referenced by Auth_Controller().

◆ $login

Auth_Controller::$login = null

Definition at line 77 of file Controller.php.

Referenced by Auth_Controller().


The documentation for this class was generated from the following file: