-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add starategy mode for jaas mode jitsi (#9)
* Add starategy mode for jaas mode jitsi * Add variable to TestCase * Add package_status in testcase * Correct bug * Add try catch * Add try catch * Add debug * Add debug * Add debug * Repair tests * Add priority for mode video conference * Remove secret key from config * Add ServiceProvider to testCase * REmove on provider * Add missing provider totestbench * Add provider to testcase file * Remove courses from jitsi composer Co-authored-by: Hubert Krzysztofiak <[email protected]>
- Loading branch information
Showing
20 changed files
with
511 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
return [ | ||
|
||
'jaas_host' => env('JAAS_HOST', 'https://8x8.vc/'), | ||
'aud' => env('JAAS_AUD', 'jitsi'), | ||
'iss' => env('JAAS_ISS', 'chat'), | ||
'sub' => env('JAAS_SUB', ''), | ||
'kid' => env('JAAS_KEY_ID', ''), | ||
'private_key' => env('JAAS_PRIVATE_KEY', '') | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Helpers; | ||
|
||
class StrategyHelper | ||
{ | ||
private string $namespace; | ||
|
||
public function __construct(string $baseStrategyName) | ||
{ | ||
$this->setNamespace($baseStrategyName); | ||
} | ||
|
||
/** | ||
* This method used strategy pattern and execute method given in the parameters | ||
* Strategy dir it must contain minimum to file: BaseStrategy contain in pattern {{parentDir}}Strategy | ||
* in localization ?/Strategies/{{parentDir}} and strategy class in the same localization | ||
* | ||
* @param string $className | ||
* @param string $baseStrategyName | ||
* @param string $method | ||
* @param ...$params | ||
* @return mixed|null | ||
*/ | ||
public static function useStrategyPattern( | ||
string $className, | ||
string $baseStrategyName, | ||
string $method, | ||
...$params | ||
) { | ||
$strategyHelper = new StrategyHelper($baseStrategyName); | ||
$class = $strategyHelper->namespace . '\\' . $className; | ||
$baseStrategyClass = $strategyHelper->namespace . '\\' . $baseStrategyName; | ||
if ( | ||
class_exists($class) && | ||
class_exists($baseStrategyClass) && | ||
method_exists($baseStrategyClass, $method) | ||
) { | ||
return (new $baseStrategyClass( | ||
new $class() | ||
))->$method($params); | ||
} | ||
return null; | ||
} | ||
|
||
private function setNamespace(string $baseStrategyName): void | ||
{ | ||
$this->namespace = 'EscolaLms\Jitsi\Strategies\\' . | ||
preg_replace('/^(.*)Strategy$/', '$1', $baseStrategyName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Services\Contracts; | ||
|
||
use EscolaLms\Auth\Models\User; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
interface JaasServiceContract | ||
{ | ||
public function getChannelData( | ||
User $user, | ||
string $channelDisplayName, | ||
bool $isModerator = false, | ||
array $configOverwrite = [], | ||
$interfaceConfigOverwrite = [] | ||
): array; | ||
public function setConfig(array $config): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace EscolaLms\Jitsi\Services; | ||
|
||
use EscolaLms\Auth\Models\User; | ||
use EscolaLms\Jitsi\Services\Contracts\JaasServiceContract; | ||
use Gnello\Mattermost\Driver; | ||
use Firebase\JWT\JWT; | ||
|
||
class JaasService extends JitsiService implements JaasServiceContract | ||
{ | ||
public Driver $driver; | ||
private array $config; | ||
|
||
public function generateJwt( | ||
User $user, | ||
string $room = '*', | ||
bool $isModerator = false, | ||
int $expireInMinutes = 60 | ||
): string { | ||
$userData = $this->getUserData($user, $isModerator); | ||
$payload = [ | ||
'aud' => $this->config['aud'], | ||
'iss' => $this->config['iss'], | ||
'exp' => now()->addMinutes($expireInMinutes)->timestamp, | ||
'sub' => $this->config['sub'], | ||
'room' => $room, | ||
'context' => [ | ||
'user' => $userData, | ||
], | ||
]; | ||
return JWT::encode($payload, $this->config['private_key'], 'RS256', $this->config['kid']); | ||
} | ||
|
||
public function setConfig(array $config): void | ||
{ | ||
$this->config = $config; | ||
} | ||
} |
Oops, something went wrong.