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

SSL verification #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
103 changes: 103 additions & 0 deletions classes/Rest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public function authorize() {
$request->setAuth($constants->KEY, $constants->SECRET, HTTP_Request2::AUTH_BASIC);
$request->setBody('grant_type=client_credentials');
$request->setHeader('Content-Type', 'application/x-www-form-urlencoded');
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));



try {
Expand Down Expand Up @@ -46,6 +51,11 @@ public function createDatasource($access_token) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($datasource));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -71,6 +81,11 @@ public function readDatasource($access_token, $dsk_id) {

$request = new HTTP_Request2($constants->HOSTNAME . $constants->DSK_PATH . '/' . $dsk_id, HTTP_Request2::METHOD_GET);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -100,6 +115,10 @@ public function updateDatasource($access_token, $dsk_id) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($datasource));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));

try {
$response = $request->send();
Expand All @@ -125,6 +144,11 @@ public function deleteDatasource($access_token, $dsk_id) {
$request = new HTTP_Request2($constants->HOSTNAME . $constants->DSK_PATH . '/' . $dsk_id, HTTP_Request2::METHOD_DELETE);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -156,6 +180,10 @@ public function createTerm($access_token, $dsk_id) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($term));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));

try {
$response = $request->send();
Expand All @@ -181,6 +209,11 @@ public function readTerm($access_token, $term_id) {

$request = new HTTP_Request2($constants->HOSTNAME . $constants->TERM_PATH . '/' . $term_id, HTTP_Request2::METHOD_GET);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -211,6 +244,11 @@ public function updateTerm($access_token, $dsk_id, $term_id) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($term));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -236,6 +274,11 @@ public function deleteTerm($access_token, $term_id) {
$request = new HTTP_Request2($constants->HOSTNAME . $constants->TERM_PATH . '/' . $term_id, HTTP_Request2::METHOD_DELETE);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -268,6 +311,11 @@ public function createCourse($access_token, $dsk_id, $term_id) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($course));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -293,6 +341,11 @@ public function readCourse($access_token, $course_id) {

$request = new HTTP_Request2($constants->HOSTNAME . $constants->COURSE_PATH . '/' . $course_id, HTTP_Request2::METHOD_GET);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -326,6 +379,11 @@ public function updateCourse($access_token, $dsk_id, $course_id, $course_uuid, $
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($course));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -351,6 +409,11 @@ public function deleteCourse($access_token, $course_id) {
$request = new HTTP_Request2($constants->HOSTNAME . $constants->COURSE_PATH . '/' . $course_id, HTTP_Request2::METHOD_DELETE);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -384,6 +447,11 @@ public function createUser($access_token, $dsk_id) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($user));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -409,6 +477,11 @@ public function readUser($access_token, $user_id) {

$request = new HTTP_Request2($constants->HOSTNAME . $constants->USER_PATH . '/' . $user_id, HTTP_Request2::METHOD_GET);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -441,6 +514,11 @@ public function updateUser($access_token, $dsk_id, $user_id, $user_uuid, $user_c
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($user));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -466,6 +544,11 @@ public function deleteUser($access_token, $user_id) {
$request = new HTTP_Request2($constants->HOSTNAME . $constants->USER_PATH . '/' . $user_id, HTTP_Request2::METHOD_DELETE);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -501,6 +584,11 @@ public function createMembership($access_token, $dsk_id, $course_id, $user_id) {
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($membership));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -526,6 +614,11 @@ public function readMembership($access_token, $course_id, $user_id) {

$request = new HTTP_Request2($constants->HOSTNAME . $constants->COURSE_PATH . '/' . $course_id . '/users/' . $user_id, HTTP_Request2::METHOD_GET);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down Expand Up @@ -558,6 +651,11 @@ public function updateMembership($access_token, $dsk_id, $course_id, $user_id, $
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setBody(json_encode($membership));
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand All @@ -583,6 +681,11 @@ public function deleteMembership($access_token, $course_id, $user_id) {
$request = new HTTP_Request2($constants->HOSTNAME . $constants->COURSE_PATH . '/' . $course_id . '/users/' . $user_id, HTTP_Request2::METHOD_DELETE);
$request->setHeader('Authorization', 'Bearer ' . $access_token);
$request->setHeader('Content-Type', 'application/json');
$request->setConfig(array(
'ssl_verify_peer' => $constants->ssl_verify_peer,
'ssl_verify_host' => $constants->ssl_verify_host
));


try {
$response = $request->send();
Expand Down