Copyright © 2012 Kaltura Inc.
All Rights Reserved. Designated trademarks and brands are the property of their respective owners.
Use of this web site constitutes acceptance of the Terms of Use and Privacy Policy.
EduVideo.org
Hi,
I have activated "Advanced Security" option for my videos so everyone who wants to view a video needs a valid kaltura session.
I have tested this option with the following code:
// Your Kaltura credentials
define("PARTNER_ID", "--Set your partner id here--");
define("USER_SECRET", "--Set your user secret here--");
define("ENTRY_ID", "--Set the entry id of a video with relevant KS access control applied that belong to the above partner id--");
define("UICONF_ID", "--Set the uiconf id of the player you'd like to use. You can find this id in the players list on the Studio tab in KMC--");
$user = "SomeoneWeKnow"; // Whatever user id you want to set (This is according to your system deployment)
require_once "client/KalturaClient.php";
//Connect to your authorization system here, this is just a mockup for the example...
$approved = false;
$user_name = $_POST['username'];
$password = $_POST['password'];
if ($user_name == 'demo' && $password == 'pass')
{
$approved = true;
} else {
$approved = false;
}
//Create a session
$conf = new KalturaConfiguration(PARTNER_ID);
$client = new KalturaClient($conf);
//This is the session start function signature: start($secret, $userId = "", $type = 0, $partnerId = -1, $expiry = 86400, $privileges = "")
//It is important that we pass the special permission "sview:ENTRY_ID" to provide access for the specific entry we want to play.
//This generated KS (Kaltura Session) will then be rendered to the page if the user has permissions to access the full video.
//If the user doesn't have permissions to access the full video, we'll not render a KS in the flashvars,
//and Kaltura will only stream the preview part of the video as defined in the access control profile.
$session = $client->session->start(USER_SECRET, $user, KalturaSessionType::USER, PARTNER_ID, 86400, 'sview:'.ENTRY_ID);
if (!isset($session)) {
die("Could not establish Kaltura session with OLD session credentials. Please verify that you are using valid Kaltura partner credentials.");
}
$client->setKs($session);
echo '<h1>Status: '.($approved ? 'Approved' : 'Denied').'</h1>';
$flashvars = '';
if ($approved) {
$flashvars .= 'ks=' . $session;
}
if ($approved == false)
echo '<form method="POST" action="">
UserName: <input value="demo" type="text" name="username">
Password: <input value="pass" type="password" name="password">
<input type="submit" value="Login">
</form>';
?>
It works very well - but I need the USER_SECRET to create the session. And I don't have the USER_SECRET in my CMS.
So I tried to use this session call
It creates also a valid session to access the video file, but now I can access any file - even from other partners!
Is there any problem with my code?
Greetings
Michael L.
Ok - You say I have to use this command to make the session:
$session = $client->session->start(USER_SECRET, $user, KalturaSessionType::USER, PARTNER_ID, 86400, 'sview:'.ENTRY_ID);
Is this correct?
You need to use the USER secret. it's available in your KMC under Settings -> Integration Settings