Skip to content

Commit

Permalink
Merge pull request #485 from jrchamp/bc-break/drop-jwt-support
Browse files Browse the repository at this point in the history
jwt: remove support for deprecated token method
  • Loading branch information
jrchamp authored Jul 3, 2023
2 parents 217250f + df3de2e commit 0605afa
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 822 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ jobs:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
MUSTACHE_IGNORE_NAMES: 'mobile_view_page_latest.mustache,mobile_view_page_ionic3.mustache'
PHPDOC_IGNORE_PATHS: 'jwt'

- name: PHP Lint
if: ${{ always() }}
Expand Down
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ Optional functionality can be enabled by granting additional scopes:
- webinar:read:admin
- webinar:write:admin

### JWT
JWT will be deprecated in June 2023. To create an account-level JWT app the 'JWT' permission is
required.

You will need to [create a JWT app](https://developers.zoom.us/docs/platform/build/jwt-app/) and that will generate the API key and secret.

## Installation

1. [Install plugin](https://docs.moodle.org/en/Installing_plugins#Installing_a_plugin) to the /mod/zoom folder in Moodle.
Expand All @@ -54,13 +48,6 @@ You will need to [create a JWT app](https://developers.zoom.us/docs/platform/bui
- Zoom client ID (mod_zoom | clientid)
- Zoom client secret (mod_zoom | clientsecret)

JWT will be deprecated in June 2023. For a JWT app, you need to set the following settings to enable the plugin:

- Zoom API key (mod_zoom | apikey)
- Zoom API secret (mod_zoom | apisecret)

Please note that the API key and secret are not the same as the LTI key/secret.

If you get "Access token is expired" errors, make sure the date/time on your
server is properly synchronized with the time servers.

Expand Down
46 changes: 1 addition & 45 deletions classes/webservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@
require_once($CFG->dirroot . '/mod/zoom/locallib.php');
require_once($CFG->libdir . '/filelib.php');

// Some plugins already might include this library, like mod_bigbluebuttonbn.
// Hacky, but need to create list of plugins that might have JWT library.
// NOTE: Remove file_exists checks and the JWT library in mod when versions prior to Moodle 3.7 is no longer supported.
if (!class_exists('Firebase\JWT\JWT')) {
if (file_exists($CFG->libdir . '/php-jwt/src/JWT.php')) {
require_once($CFG->libdir . '/php-jwt/src/JWT.php');
} else {
if (file_exists($CFG->dirroot . '/mod/bigbluebuttonbn/vendor/firebase/php-jwt/src/JWT.php')) {
require_once($CFG->dirroot . '/mod/bigbluebuttonbn/vendor/firebase/php-jwt/src/JWT.php');
} else {
require_once($CFG->dirroot . '/mod/zoom/jwt/JWT.php');
}
}
}

/**
* Web service class.
*/
Expand Down Expand Up @@ -85,18 +70,6 @@ class mod_zoom_webservice {
*/
protected $accountid;

/**
* API key
* @var string
*/
protected $apikey;

/**
* API secret
* @var string
*/
protected $apisecret;

/**
* API base URL.
* @var string
Expand Down Expand Up @@ -146,14 +119,6 @@ public function __construct() {
'accountid',
];

// TODO: Remove when JWT is no longer supported in June 2023.
if (empty($config->clientid) || empty($config->clientsecret) || empty($config->accountid)) {
$requiredfields = [
'apikey',
'apisecret',
];
}

try {
// Get and remember each required field.
foreach ($requiredfields as $requiredfield) {
Expand Down Expand Up @@ -256,16 +221,7 @@ private function make_call($path, $data = [], $method = 'get') {
$url = $this->apiurl . $path;
$method = strtolower($method);

// TODO: Remove JWT auth when deprecated in June 2023.
if (isset($this->clientid) && isset($this->clientsecret) && isset($this->accountid)) {
$token = $this->get_access_token();
} else {
$payload = [
'iss' => $this->apikey,
'exp' => time() + 40,
];
$token = \Firebase\JWT\JWT::encode($payload, $this->apisecret, 'HS256');
}
$token = $this->get_access_token();

$curl = $this->get_curl_object();
$curl->setHeader('Authorization: Bearer ' . $token);
Expand Down
8 changes: 0 additions & 8 deletions jwt/BeforeValidException.php

This file was deleted.

8 changes: 0 additions & 8 deletions jwt/ExpiredException.php

This file was deleted.

173 changes: 0 additions & 173 deletions jwt/JWK.php

This file was deleted.

Loading

0 comments on commit 0605afa

Please sign in to comment.