Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
apisub
Commits
86ea0c64
Commit
86ea0c64
authored
Feb 07, 2019
by
Stephane Crozat
Browse files
Externalisation de la connection Cas dans cas_connexion.php
parent
9432edbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
index.php
View file @
86ea0c64
<?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'
;
...
...
lib/cas_connect.php
0 → 100644
View file @
86ea0c64
<?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
}
?>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment