Skip to content

Commit

Permalink
Merge pull request #5 from inka-pallycon/feature/v2.2.0
Browse files Browse the repository at this point in the history
Feature/v2.2.0
  • Loading branch information
jinseok-Noh authored Feb 8, 2023
2 parents 0bc49f1 + 69392e5 commit 4f36fb9
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
36 changes: 23 additions & 13 deletions doc/README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

- If you test the sample player player page online(other than localhost), the page URL should be HTTPS. (SSL/TLS is required)
- PHP Version 7.3 or later.
- The TokenSample folder is a token creation PHP sample source(drm-token-sample-php).
- The TokenSample folder is a token creation PHP sample source(drm-token-sample-php).

##### PHP.ini Dynamic Extensions
- curl
- openssl
- openssl

### Configuring Config.php
- [Config.php](../src/Config/Config.php)
Expand All @@ -31,12 +31,12 @@ proxy_response_format=>[original|json]
```

- pallycon.token.response.format: Set the license response type of PallyCon license server
- original: basic license information only (same as the response of v1.0 spec)
- json: responds in JSON type with additional information such as Device ID
- original: basic license information only (same as the response of v1.0 spec)
- json: responds in JSON type with additional information such as Device ID

- pallycon.response.format: Set the type of license response to be sent from the proxy server to the client
- original: basic license information only (same as the response of v1.0 spec)
- json: response in JSON type with additional information. In order to play DRM content with the response, a function to parse the response additionally must be implemented on the client side.
- original: basic license information only (same as the response of v1.0 spec)
- json: response in JSON type with additional information. In order to play DRM content with the response, a function to parse the response additionally must be implemented on the client side.


### Notes
Expand All @@ -47,18 +47,18 @@ proxy_response_format=>[original|json]

## Default configuration of this sample

1. url : http://localhost/{base_path}/proxy.php?drmType={drmType}
- drmType : fairplay, playready, widevine, ncg
2. cid : test
3. userId : proxySample
1. url : http://localhost/{base_path}/proxy.php?drmType={drmType}
- drmType : fairplay, playready, widevine, ncg
2. cid : test
3. userId : proxySample
4. license Rule : license duration is 3600 seconds

## TODO

1. For testing, you need to update the `TODO` items in the `createPallyConCustomdata` method.

- [PHP](../src/Service/ProxyService.php)
- [Config](../src/Config/Config.php)
- [PHP](../src/Service/ProxyService.php)
- [Config](../src/Config/Config.php)


2. When the client (SDK, Browser) and proxy server connection, if `user_id` and `content_id` need to connection with the proxy server, the encryption method used by the company shall be applied and communicated.
Expand All @@ -68,7 +68,17 @@ proxy_response_format=>[original|json]
3. Specify the policy to be used using `new PallyConDrmTokenClient()`



4. The device information header `pallycon-client-meta` allows you to receive information from the client. ( Pallycon SDK sends it by default. )
- Original Value String : `ewoJImRldmljZV9pbmZvIjogewoJCSJkZXZpY2VfbW9kZWwiOiAiaVBob25lIFNFIChpUGhvbmU4LDQpIiwKCQkib3NfdmVyc2lvbiI6IjE1LjcuMiIKCX0KfQ==`
- Base64 Decoding :
```JSON
{
"device_info": {
"device_model": "iPhone SE (iPhone8,4)",
"os_version":"15.7.2"
}
}
```

***

Expand Down
30 changes: 21 additions & 9 deletions doc/README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

- 재생 테스트용 플레이어 웹페이지가 로컬호스트(http://localhost)가 아닌 경우, 해당 URL에 HTTPS 설정이 필수입니다. (테스트용 웹 서버에 SSL/TLS 적용 필요)
- PHP Version 7.3 or later.
- TokenSample 폴더는 토큰생성 PHP 샘플 소스 입니다(drm-token-sample-php).
- TokenSample 폴더는 토큰생성 PHP 샘플 소스 입니다(drm-token-sample-php).

##### PHP.ini Dynamic Extensions
- curl
- openssl
- openssl

### Config 세팅
- [Config.php](../src/Config/Config.php)
Expand Down Expand Up @@ -45,22 +45,22 @@ proxy_response_format=>[original|json]
2. NCG는 최초 라이센스 인증시 `mode=getserverinfo`를 호출하여 기기별 인증서를 다운받은 후 라이센스 요청을 한다.



## 샘플 프로젝트 기본 설정

1. url : http://localhost/{base_path}/proxy.php?drmType={drmType}
- drmType : fairplay, playready, widevine, ncg
2. cid : test
3. userId : proxySample
1. url : http://localhost/{base_path}/proxy.php?drmType={drmType}
- drmType : fairplay, playready, widevine, ncg
2. cid : test
3. userId : proxySample
4. license Rule : 라이선스 만료 시간 3600초


## TODO

1. 테스트를 위해서는 기본 설정 완료 후 `createPallyConCustomdata` 메소드의 `TODO` 사항들을 업데이트해야 합니다.

- [PHP](../src/Service/ProxyService.php)
- [Config](../src/Config/Config.php)
- [PHP](../src/Service/ProxyService.php)
- [Config](../src/Config/Config.php)

2. Client( SDK, Browser ) 와 Proxy Server가 통신 할때 `user_id`, `content_id`를 Proxy Server와 통신이 필요 할 경우 당사에서 사용하고 있는 암호화 방식을 적용하여 통신하여야 한다.
- 회사 마다 암호화 방식이 다르므로 별도로 가이드를 제공하지는 않습니다.
Expand All @@ -69,6 +69,18 @@ proxy_response_format=>[original|json]
3. 사용하고자 하는 Policy를 `new PallyConDrmTokenClient()` 를 사용하여 지정한다.


4. 디바이스 정보 Header `pallycon-client-meta` 를 통해 Client의 정보를 받을수 있다. ( Pallycon SDK에서는 기본으로 보내줌. )
- Original Value String : `ewoJImRldmljZV9pbmZvIjogewoJCSJkZXZpY2VfbW9kZWwiOiAiaVBob25lIFNFIChpUGhvbmU4LDQpIiwKCQkib3NfdmVyc2lvbiI6IjE1LjcuMiIKCX0KfQ==`
- Base64 Decoding :
```JSON
{
"device_info": {
"device_model": "iPhone SE (iPhone8,4)",
"os_version":"15.7.2"
}
}
```

***

https://pallycon.com | cbiz@inka.co.kr
Expand Down
3 changes: 2 additions & 1 deletion src/Common/AutoLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

foreach($dirs as $dir) {

$base_path = __DIR__. "".DIRECTORY_SEPARATOR;
$base_path = __DIR__."".DIRECTORY_SEPARATOR;
$class_path = $base_path . $className . '.php';
$class_path = str_replace("\\", "/", $class_path);

if ( $dir == "TokenSample/" ){ // TokenSample Path
$class_path = str_replace(DIRECTORY_SEPARATOR ."Common". DIRECTORY_SEPARATOR."PallyCon".DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR."TokenSample".DIRECTORY_SEPARATOR, $class_path);
Expand Down
15 changes: 9 additions & 6 deletions src/Service/ProxyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function __construct() {
}


public function getLicenseData($_mode, $_sampleData, $_requestBody, $_drmType){
public function getLicenseData($_mode, $_pallyconClientMeta, $_requestBody, $_drmType){
$_responseData = null;

// Token creation
$_pallyconCustomData = $this->createPallyConCustomData($_sampleData, $_drmType);
$_pallyconCustomData = $this->createPallyConCustomData($_drmType);

// license server
$_licenseResponse = $this->callLicenseServer($_mode, $this->_config['license_url'], $_requestBody, $_pallyconCustomData, $_drmType);
$_licenseResponse = $this->callLicenseServer($_mode, $this->_config['license_url'], $_requestBody, $_pallyconCustomData, $_drmType, $_pallyconClientMeta);

// response data
$_responseData = $this->checkResponseData($_licenseResponse, $_drmType);
Expand All @@ -47,12 +47,11 @@ public function getLicenseData($_mode, $_sampleData, $_requestBody, $_drmType){
/**
* Token creation
*
* @param $_sampleData
* @param $_drmType
* @return string
* @throws \PallyCon\Exception\PallyConTokenException
*/
private function createPallyConCustomData($_sampleData, $_drmType){
private function createPallyConCustomData($_drmType){
$_siteKey = $this->_config['siteKey'];
$_accessKey = $this->_config['accessKey'];
$_siteId = $this->_config['siteId'];
Expand Down Expand Up @@ -129,7 +128,7 @@ private function createPallyConCustomData($_sampleData, $_drmType){
* @return string
* @throws PallyConProxyException
*/
private function callLicenseServer($_mode, $_url, $_requestBody, $_pallyconCustomData, $_drmType){
private function callLicenseServer($_mode, $_url, $_requestBody, $_pallyconCustomData, $_drmType, $_pallyconClientMeta){

$_handle = curl_init();
$_headerData = array();
Expand Down Expand Up @@ -172,6 +171,10 @@ private function callLicenseServer($_mode, $_url, $_requestBody, $_pallyconCusto
array_push($_headerData, "pallycon-customdata-v2: " . $_pallyconCustomData);
}

if ( $_pallyconClientMeta != null && $_pallyconClientMeta != "" ) {
array_push($_headerData, "pallycon-client-meta: " . $_pallyconClientMeta);
}

curl_setopt($_handle, CURLOPT_HTTPHEADER, $_headerData);

if ( $_requestBody != null && $_requestBody != "") {
Expand Down
6 changes: 3 additions & 3 deletions src/proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@

// get Header
$_headers = apache_request_headers();
$_sampleData = $_headers["sample-data"];
$_contentType = $_headers["Content-Type"];
$_pallyconClientMeta = @$_headers["pallycon-client-meta"];

// get Parameter
$_requestBody = file_get_contents("php://input"); // get raw data
$_drmType = $_REQUEST["drmType"];
$_spc = $_POST["spc"];
$_mode = $_REQUEST["mode"];
$_mode = @$_REQUEST["mode"];

// FairPlay
if ( strtoupper($_drmType) == $drmType::FAIRPLAY ) {
$_requestBody = $util->getBytes($_spc);
}

// get License data
$_responseData = $proxyService->getLicenseData($_mode, $_sampleData, $_requestBody, $_drmType);
$_responseData = $proxyService->getLicenseData($_mode, $_pallyconClientMeta, $_requestBody, $_drmType);

print_r($_responseData);

Expand Down

0 comments on commit 4f36fb9

Please sign in to comment.