Skip to content

Commit 5bac602

Browse files
Merge pull request #23 from matomo-org/PG-5113-show-scope
Adds code to show scope in the list view, #PG-5113
2 parents ed8b892 + 8f57d80 commit 5bac602

22 files changed

Lines changed: 138 additions & 44 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
5.0.2 - 2026-04-27
2+
- Added code to show scope in the list view
3+
14
5.0.1 - 2026-04-17
25
- Fixes README.md
36

OAuth2.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Piwik\Db;
1616
use Piwik\DbHelper;
1717
use Piwik\Option;
18+
use Piwik\Piwik;
1819
use Piwik\Plugin;
1920
use Piwik\Plugins\OAuth2\Access\OAuth2Access;
2021
use Piwik\Plugins\OAuth2\Auth\Oauth2Auth;
@@ -27,6 +28,17 @@ class OAuth2 extends Plugin
2728
public const OAUTH2_PRIVATE_OPTION_KEY = 'oauth2_private';
2829
public const OAUTH2_PUBLIC_OPTION_KEY = 'oauth2_public';
2930
public const OAUTH2_ENCRYPTION_OPTION_KEY = 'oauth2_encryption';
31+
32+
public static function getScopeDescriptions(): array
33+
{
34+
return [
35+
'matomo:read' => Piwik::translate('OAuth2_ScopeReadDescription'),
36+
'matomo:write' => Piwik::translate('OAuth2_ScopeWriteDescription'),
37+
'matomo:admin' => Piwik::translate('OAuth2_ScopeAdminDescription'),
38+
'matomo:superuser' => Piwik::translate('OAuth2_ScopeSuperUserDescription'),
39+
];
40+
}
41+
3042
public function registerEvents()
3143
{
3244
return [
@@ -155,6 +167,10 @@ public function getClientSideTranslationKeys(&$translationKeys)
155167
$translationKeys[] = 'OAuth2_ClientSecretVisibleHelp';
156168
$translationKeys[] = 'OAuth2_AdminDescriptionPlaceholder';
157169
$translationKeys[] = 'OAuth2_AdminRotatedNotification';
170+
$translationKeys[] = 'OAuth2_ScopeSuperUserShort';
171+
$translationKeys[] = 'UsersManager_PrivView';
172+
$translationKeys[] = 'UsersManager_PrivWrite';
173+
$translationKeys[] = 'UsersManager_PrivAdmin';
158174
}
159175

160176
public function getTablesInstalled(&$allTablesInstalled)

Repositories/ScopeRepository.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Matomo\Dependencies\Oauth2\League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
1616
use Piwik\Piwik;
1717
use Piwik\Plugins\OAuth2\Entities\ClientEntity;
18+
use Piwik\Plugins\OAuth2\OAuth2;
1819
use Piwik\Plugins\OAuth2\Entities\ScopeEntity;
1920
use Piwik\Plugins\OAuth2\SystemSettings;
2021

@@ -29,12 +30,7 @@ public function __construct(SystemSettings $settings)
2930

3031
public static function getScopeDescriptions(): array
3132
{
32-
return [
33-
'matomo:read' => Piwik::translate('OAuth2_ScopeReadDescription'),
34-
'matomo:write' => Piwik::translate('OAuth2_ScopeWriteDescription'),
35-
'matomo:admin' => Piwik::translate('OAuth2_ScopeAdminDescription'),
36-
'matomo:superuser' => Piwik::translate('OAuth2_ScopeSuperUserDescription'),
37-
];
33+
return OAuth2::getScopeDescriptions();
3834
}
3935

4036
public function getScopeEntityByIdentifier(string $identifier): ?ScopeEntityInterface

SystemSettings.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Piwik\Plugins\OAuth2;
1111

1212
use Piwik\Piwik;
13-
use Piwik\Plugins\OAuth2\Repositories\ScopeRepository;
1413
use Piwik\Settings\FieldConfig;
1514
use Piwik\Settings\Plugin\SystemSettings as BaseSystemSettings;
1615
use Piwik\Settings\Setting;
@@ -73,7 +72,7 @@ protected function init()
7372
$field->title = Piwik::translate('OAuth2_SystemSettingOAuthEnableRefreshTokenTitle');
7473
});
7574

76-
$scopes = ScopeRepository::getScopeDescriptions();
75+
$scopes = OAuth2::getScopeDescriptions();
7776
$defaultScopes = $scopes;
7877
unset($defaultScopes['matomo:superuser']);
7978
$this->defaultScopes = $this->makeSetting('defaultScopes', array_keys($defaultScopes), FieldConfig::TYPE_ARRAY, function (FieldConfig $field) use ($scopes) {

lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"ScopeWriteDescription": "Matomo write level access",
8989
"ScopeAdminDescription": "Matomo admin level access",
9090
"ScopeSuperUserDescription": "Matomo superuser level access",
91+
"ScopeSuperUserShort": "Superuser",
9192
"SystemSettingOAuthAccessTokenLifetimeTitle": "Access token lifetime (seconds)",
9293
"SystemSettingOAuthAccessTokenLifetimeDescription": "Define how long an access token remains valid after it is issued.",
9394
"SystemSettingOAuthRefreshTokenLifetimeTitle": "Refresh token lifetime (seconds)",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "OAuth2",
33
"description": "Provide secure access to the Matomo API using scoped permissions. No static credentials.",
4-
"version": "5.0.1",
4+
"version": "5.0.2",
55
"theme": false,
66
"require": {
77
"php": ">=8.1.0",

stylesheets/oauth2.less

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#content.admin:has(.oauth2-admin) {
2+
max-width: unset !important;
3+
}
4+
15
#oauth2AuthorizePage {
26
display: flex;
37
width: 100%;
@@ -161,4 +165,4 @@
161165
#footerLinks {
162166
margin-top: 1rem;
163167
}
164-
}
168+
}
537 Bytes
Loading
2.06 KB
Loading
1.45 KB
Loading

0 commit comments

Comments
 (0)