commit
1102ece3bd
@ -0,0 +1,57 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* This file contains the necessary elements to implement a Single Sign On |
||||
* using chamilo as a SSO server |
||||
* @package chamilo.auth.sso |
||||
*/ |
||||
class SsoServer |
||||
{ |
||||
/** |
||||
* This is used to get the url with the SSO params |
||||
* @param string $refererSso |
||||
* @param array $additionalParams |
||||
* @return string |
||||
*/ |
||||
public function getUrl($refererSso, $additionalParams = array()) |
||||
{ |
||||
if (empty($refererSso)) { |
||||
return null; |
||||
} |
||||
|
||||
$getParams = parse_url($refererSso, PHP_URL_QUERY); |
||||
$userInfo = api_get_user_info(api_get_user_id(), false, true); |
||||
$chamiloUrl = api_get_path(WEB_PATH); |
||||
$sso = [ |
||||
'username' => $userInfo['username'], |
||||
'secret' => sha1($userInfo['password']), |
||||
'master_domain' => $chamiloUrl, |
||||
'master_auth_uri' => $chamiloUrl.'?submitAuth=true', |
||||
'lifetime' => time() + 3600, |
||||
'target' => $refererSso, |
||||
]; |
||||
|
||||
if (!empty($additionalParams)) { |
||||
foreach ($additionalParams as $key => $value) { |
||||
if (!empty($key)) { |
||||
$sso[$key] = $value; |
||||
|
||||
continue; |
||||
} |
||||
|
||||
$sso[] = $value; |
||||
} |
||||
} |
||||
|
||||
$cookie = base64_encode(serialize($sso)); |
||||
|
||||
return $refererSso |
||||
.($getParams ? '&' : '?') |
||||
.http_build_query([ |
||||
'loginFailed' => 0, |
||||
'sso_referer' => $refererSso, |
||||
'sso_cookie' => $cookie |
||||
]); |
||||
} |
||||
} |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,104 +1,107 @@ |
||||
{% extends template ~ "/layout/page.tpl" %} |
||||
|
||||
{% block body %} |
||||
<div class="row"> |
||||
{% if plugin_main_top %} |
||||
<div class="page-main-top" class="col-md-12"> |
||||
{{ plugin_main_top }} |
||||
<div class="row"> |
||||
<div class="page-main-top" class="col-md-12"> |
||||
{{ plugin_main_top }} |
||||
</div> |
||||
</div> |
||||
{% endif %} |
||||
<div class="col-md-3"> |
||||
<div class="sidebar"> |
||||
{% if plugin_menu_top %} |
||||
<div class="siderbar-menu-top"> |
||||
{{ plugin_menu_top }} |
||||
</div> |
||||
{% endif %} |
||||
|
||||
{% include template ~ "/layout/login_form.tpl" %} |
||||
<div class="row"> |
||||
<div class="col-md-9 col-md-push-3"> |
||||
<div class="page-content"> |
||||
{% if plugin_content_top %} |
||||
<div class="page-content-top"> |
||||
{{ plugin_content_top }} |
||||
</div> |
||||
{% endif %} |
||||
|
||||
{% if _u.logged == 1 %} |
||||
{{ user_image_block }} |
||||
{% endif %} |
||||
{{ sniff_notification }} |
||||
|
||||
{{ profile_block }} |
||||
{{ course_block }} |
||||
{{ teacher_block }} |
||||
{{ skills_block }} |
||||
{{ certificates_search_block }} |
||||
{{ notice_block }} |
||||
{{ help_block }} |
||||
{{ navigation_course_links }} |
||||
{{ search_block }} |
||||
{{ classes_block }} |
||||
{% if home_page_block %} |
||||
<article id="homepage-home"> |
||||
{{ home_page_block }} |
||||
</article> |
||||
{% endif %} |
||||
|
||||
{% if plugin_menu_bottom %} |
||||
<div class="sidebar-menu-bottom"> |
||||
{{ plugin_menu_bottom }} |
||||
</div> |
||||
{% endif %} |
||||
</div> |
||||
</div> |
||||
<div class="col-md-9"> |
||||
<div class="page-content"> |
||||
{% block page_body %} |
||||
{% include template ~ "/layout/page_body.tpl" %} |
||||
{% endblock %} |
||||
|
||||
{% if plugin_content_top %} |
||||
<div class="page-content-top"> |
||||
{{ plugin_content_top }} |
||||
</div> |
||||
{% endif %} |
||||
{% if welcome_to_course_block %} |
||||
<article id="homepage-course"> |
||||
{{ welcome_to_course_block }} |
||||
</article> |
||||
{% endif %} |
||||
|
||||
{{ sniff_notification }} |
||||
{% block content %} |
||||
{% if content is not null %} |
||||
<section id="page" class="{{ course_history_page }}"> |
||||
{{ content }} |
||||
</section> |
||||
{% endif %} |
||||
{% endblock %} |
||||
|
||||
{% if home_page_block %} |
||||
<article id="homepage-home"> |
||||
{{ home_page_block }} |
||||
</article> |
||||
{% endif %} |
||||
{% if announcements_block %} |
||||
<article id="homepage-announcements"> |
||||
{{ announcements_block }} |
||||
</article> |
||||
{% endif %} |
||||
|
||||
{% block page_body %} |
||||
{% include template ~ "/layout/page_body.tpl" %} |
||||
{% endblock %} |
||||
{% if course_category_block %} |
||||
<article id="homepage-course-category"> |
||||
{{ course_category_block }} |
||||
</article> |
||||
{% endif %} |
||||
|
||||
{% if welcome_to_course_block %} |
||||
<article id="homepage-course"> |
||||
{{ welcome_to_course_block }} |
||||
</article> |
||||
{% endif %} |
||||
{% include template ~ "/layout/hot_courses.tpl" %} |
||||
|
||||
{% block content %} |
||||
{% if content is not null %} |
||||
<section id="page" class="{{ course_history_page }}"> |
||||
{{ content }} |
||||
</section> |
||||
{% if plugin_content_bottom %} |
||||
<div id="plugin_content_bottom"> |
||||
{{ plugin_content_bottom }} |
||||
</div> |
||||
{% endif %} |
||||
</div> |
||||
</div> |
||||
<div class="col-md-3 col-md-pull-9"> |
||||
<div class="sidebar"> |
||||
{% if plugin_menu_top %} |
||||
<div class="siderbar-menu-top"> |
||||
{{ plugin_menu_top }} |
||||
</div> |
||||
{% endif %} |
||||
{% endblock %} |
||||
|
||||
{% if announcements_block %} |
||||
<article id="homepage-announcements"> |
||||
{{ announcements_block }} |
||||
</article> |
||||
{% endif %} |
||||
{% include template ~ "/layout/login_form.tpl" %} |
||||
|
||||
{% if course_category_block %} |
||||
<article id="homepage-course-category"> |
||||
{{ course_category_block }} |
||||
</article> |
||||
{% endif %} |
||||
{% if _u.logged == 1 %} |
||||
{{ user_image_block }} |
||||
{% endif %} |
||||
|
||||
{% include template ~ "/layout/hot_courses.tpl" %} |
||||
{{ profile_block }} |
||||
{{ course_block }} |
||||
{{ teacher_block }} |
||||
{{ skills_block }} |
||||
{{ certificates_search_block }} |
||||
{{ notice_block }} |
||||
{{ help_block }} |
||||
{{ navigation_course_links }} |
||||
{{ search_block }} |
||||
{{ classes_block }} |
||||
|
||||
{% if plugin_content_bottom %} |
||||
<div id="plugin_content_bottom"> |
||||
{{plugin_content_bottom}} |
||||
</div> |
||||
{% endif %} |
||||
{% if plugin_menu_bottom %} |
||||
<div class="sidebar-menu-bottom"> |
||||
{{ plugin_menu_bottom }} |
||||
</div> |
||||
{% endif %} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% if plugin_main_bottom %} |
||||
<div class="page-main-bottom" class="col-md-12"> |
||||
{{ plugin_main_bottom }} |
||||
<div class="row"> |
||||
<div class="page-main-bottom" class="col-md-12"> |
||||
{{ plugin_main_bottom }} |
||||
</div> |
||||
</div> |
||||
{% endif %} |
||||
</div> |
||||
{% endblock %} |
||||
|
||||
Loading…
Reference in new issue