Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From v2.7 to psvamb 43876 fix ks when AC is on #95

Open
wants to merge 3 commits into
base: v2.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions lib/Kaltura/Client/ClientBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,32 @@ public static function generateSessionV2($adminSecretForSigning, $userId, $type,

protected static function aesEncrypt($key, $message)
{
return mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
substr(sha1($key, true), 0, 16),
$message,
MCRYPT_MODE_CBC,
str_repeat("\0", 16) // no need for an IV since we add a random string to the message anyway
);
$iv = str_repeat("\0", 16); // no need for an IV since we add a random string to the message anyway
$key = substr(sha1($key, true), 0, 16);
if (function_exists('openssl_encrypt')) {
// Pad with null byte to be compatible with mcrypt PKCS#5 padding
// See http://thefsb.tumblr.com/post/110749271235/using-opensslendecrypt-in-php-instead-of as reference
$blockSize = 16;
if (strlen($message) % $blockSize) {
$padLength = $blockSize - strlen($message) % $blockSize;
$message .= str_repeat("\0", $padLength);
}
return openssl_encrypt(
$message,
'AES-128-CBC',
$key,
OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING,
$iv
);
} else {
return mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
$key,
$message,
MCRYPT_MODE_CBC,
$iv
);
}
}

private function hash ( $salt , $str )
Expand Down
13 changes: 12 additions & 1 deletion lib/KalturaHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ public static function getServerUrl($path = null) {
return esc_url_raw( $url );
}

public static function createPlayerKs() {
$adminSecret = sanitize_text_field(KalturaHelpers::getOption( 'kaltura_admin_secret' ));
$userId = ''; // anonymous user
$clientType = Kaltura_Client_Enum_SessionType::ADMIN;
$partnerId = intval( KalturaHelpers::getOption( 'kaltura_partner_id' ) );
$privileges = 'sview:1_c1uw0vjb,setrole:PLAYBACK_BASE_ROLE';
$ks = Kaltura_Client_ClientBase::generateSessionV2($adminSecret, $userId, $clientType, $partnerId, 86400, $privileges);

return $ks;
}

public static function getCdnUrl($path = null) {
$url = KalturaHelpers::getOption( 'cdn_url' );
$url = rtrim( $url, '/' );
Expand Down Expand Up @@ -657,4 +668,4 @@ public static function getStates() {
'WY' => 'WY',
);
}
}
}
2 changes: 1 addition & 1 deletion lib/KalturaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class KalturaModel {
protected $_partnerId = null;


private function KalturaModel() {
private function __construct() {
$config = KalturaHelpers::getKalturaConfiguration();
$this->_client = new KalturaWordpressClientBase( $config );
$this->_userId = sanitize_user( KalturaHelpers::getLoggedUserId() );
Expand Down
7 changes: 5 additions & 2 deletions view/embed-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$thumbnailDivId = 'kaltura_thumbnail_' . $randId;
$playerId = 'kaltura_player_' . $randId;
$scriptSrc = KalturaHelpers::getServerUrl() . '/p/' . KalturaHelpers::getOption( 'kaltura_partner_id' ) . '/sp/' . KalturaHelpers::getOption( 'kaltura_partner_id' ) . '00/embedIframeJs/uiconf_id/' . (int)$embedOptions['uiconfid'] . '/partner_id/' . KalturaHelpers::getOption( 'kaltura_partner_id' );

$ks = KalturaHelpers::createPlayerKs();
?>

<script src="<?php echo esc_url($scriptSrc); ?>"></script>
Expand Down Expand Up @@ -65,6 +65,9 @@
"targetId": <?php echo wp_json_encode($playerId); ?>,
"wid": <?php echo wp_json_encode($wid); ?>,
"uiconf_id": <?php echo wp_json_encode($embedOptions['uiconfid']); ?>,
"entry_id": <?php echo wp_json_encode($entryId); ?>
"entry_id": <?php echo wp_json_encode($entryId); ?>,
"flashvars": {
"ks": <?php echo wp_json_encode($ks); ?>,
}
});
</script>