From 3e10baf9010c5271baf02435b949f8d5e9ecad29 Mon Sep 17 00:00:00 2001 From: Lawrence Oks Date: Fri, 19 Nov 2021 15:23:06 -0500 Subject: [PATCH] adds third party oauth check when uploading media files --- fuel/app/classes/controller/media.php | 11 +++++--- fuel/app/classes/thirdparty/oauth.php | 39 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 fuel/app/classes/thirdparty/oauth.php diff --git a/fuel/app/classes/controller/media.php b/fuel/app/classes/controller/media.php index ed3506046..274a23c28 100644 --- a/fuel/app/classes/controller/media.php +++ b/fuel/app/classes/controller/media.php @@ -5,6 +5,7 @@ */ use \Materia\Widget_Asset_Manager; use \Materia\Widget_Asset; +use \Thirdparty\Oauth; class Controller_Media extends Controller { @@ -64,8 +65,11 @@ public function get_import() // This currently assumes a single uploaded file at a time public function action_upload() { - // Validate Logged in - if (\Service_User::verify_session() !== true) throw new HttpNotFoundException; + // Either Validate Logged in + // or validate a third party server thru Oauth + if (\Service_User::verify_session() !== true) + if (Oauth::validate_post() !== true) + throw new HttpNotFoundException; $res = new Response(); // Make sure file is not cached (as it happens for example on iOS devices) @@ -74,6 +78,7 @@ public function action_upload() $res->set_header('Cache-Control', 'no-store, no-cache, must-revalidate'); $res->set_header('Pragma', 'no-cache'); + // Upload::process is called automatically if (\Upload::is_valid()) \Upload::save(); @@ -89,7 +94,7 @@ public function action_upload() } $uploaded_file = \Upload::get_files(0); - + if ( ! $uploaded_file) { trace('Unable to process upload'); diff --git a/fuel/app/classes/thirdparty/oauth.php b/fuel/app/classes/thirdparty/oauth.php new file mode 100644 index 000000000..146b36444 --- /dev/null +++ b/fuel/app/classes/thirdparty/oauth.php @@ -0,0 +1,39 @@ +getMessage(), \Uri::current(), print_r(\Input::post(), 1)], 'lti-error-dump'); + } + + return false; + } +} \ No newline at end of file