Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion lib/ClientRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

class ClientRegistration {
public static function getRegistration($clientId) {
if (preg_match("/^http(s)?:/", $clientId)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should support http without SSL/TLS. 🤔

return self::getRemoteRegistration($clientId);
}

Db::connect();
$query = Db::$pdo->prepare(
'SELECT clientData FROM clients WHERE clientId=:clientId'
Expand All @@ -18,7 +22,13 @@ public static function getRegistration($clientId) {
}
return false;
}


public static function getRemoteRegistration($url) {
$clientDocument = file_get_contents($url);
$clientRegistration = json_decode($clientDocument, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding JSON_THROW_ON_ERROR so parse errors can be caught instead of failing silently.

return $clientRegistration;
}

public static function saveClientRegistration($clientData) {
Db::connect();
if (!isset($clientData['client_name'])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Routes/SolidIdp.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function respondToAuthorize() {
$approval = true;
} else {
$clientRegistration = ClientRegistration::getRegistration($clientId);
if (in_array($clientRegistration['origin'], TRUSTED_APPS)) {
if (isset($clientRegistration['origin']) && in_array($clientRegistration['origin'], TRUSTED_APPS)) {
$approval = true;
}
}
Expand Down
Loading