mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Исправлен парсинг списка скоупов, если передан массив
Fixes ACCOUNTS-2NA
This commit is contained in:
28
api/components/OAuth2/Utils/Scopes.php
Normal file
28
api/components/OAuth2/Utils/Scopes.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace api\components\OAuth2\Utils;
|
||||
|
||||
class Scopes {
|
||||
|
||||
/**
|
||||
* По стандарту OAuth2 scopes должны разделяться пробелом, а не запятой. Косяк.
|
||||
* Так что оборачиваем функцию разбора скоупов, заменяя запятые на пробелы.
|
||||
* Заодно учитываем возможность передать скоупы в виде массива.
|
||||
*
|
||||
* @param string|array $scopes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function format($scopes): string {
|
||||
if ($scopes === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_array($scopes)) {
|
||||
return implode(' ', $scopes);
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncompatibleReturnTypeInspection */
|
||||
return str_replace(',', ' ', $scopes);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user