Commit 86ea0c64 authored by Stephane Crozat's avatar Stephane Crozat

Externalisation de la connection Cas dans cas_connexion.php

parent 9432edbd
<?php
session_start();
if (!isset($_SESSION['ticket'])) {
/* If session is already open for current PHP file, user is already logged in, do nothing
If session is not open on current PHP file, check if it is open on CAS server
If it is open on CAS server retrieve session informations
If it is not on open on CAS server, ask for login to CAS server
*/
include $_SERVER['DOCUMENT_ROOT'].'/apisub/lib/cas.php';
$cas = new CAS('https://cas.utc.fr/cas/','http');
$info = $cas->authenticate();
if ($info != -1) {
$_SESSION['ticket'] = $_GET['ticket'];
$_SESSION['utclogin'] = $info['cas:user'];
$_SESSION['mail'] = $info['cas:attributes']['cas:mail'];
$_SESSION['surname'] = strtoupper($info['cas:attributes']['cas:sn']);
$_SESSION['firstname'] = $info['cas:attributes']['cas:givenName'];
}
else {
$cas->login();
}
$_SESSION['localcopy'] = true; //call localcopy once per session
}
include 'lib/cas_connect.php';
include 'lib/db.php';
include 'lib/views.php';
......
<?php
if (!isset($_SESSION['ticket'])) {
/* If session is already open for current PHP file, user is already logged in, do nothing
If session is not open on current PHP file, check if it is open on CAS server
If it is open on CAS server retrieve session informations
If it is not on open on CAS server, ask for login to CAS server
*/
include 'lib/cas.php';
$cas = new CAS('https://cas.utc.fr/cas/','http');
$info = $cas->authenticate();
if ($info != -1) {
$_SESSION['ticket'] = $_GET['ticket'];
$_SESSION['utclogin'] = $info['cas:user'];
$_SESSION['mail'] = $info['cas:attributes']['cas:mail'];
$_SESSION['surname'] = strtoupper($info['cas:attributes']['cas:sn']);
$_SESSION['firstname'] = $info['cas:attributes']['cas:givenName'];
}
else {
$cas->login();
}
$_SESSION['localcopy'] = true; //call localcopy once per session
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment