Repository navigation
Expand file tree
/
Copy pathextend.php
More file actions
88 lines (72 loc) · 3.7 KB
/
Copy pathextend.php
File metadata and controls
88 lines (72 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\OAuthProvider;
use Flarum\Audit\Extend\Audit;
use Flarum\Extend;
use Flarum\Gdpr\Extend\UserData as GdprUserData;
use Flarum\Search\Database\DatabaseSearchDriver;
use Flarum\User\Event\LoggedOut;
use Flarum\User\Event\PasswordChanged;
use Flarum\User\Search\UserSearcher;
use Illuminate\Console\Scheduling\Event;
return [
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/resources/less/admin.less')
->jsDirectory(__DIR__.'/js/dist/admin'),
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/resources/less/forum.less'),
new Extend\Locales(__DIR__.'/resources/locale'),
(new Extend\Routes('forum'))
->get('/oauth/authorize', 'oauthProvider.authorize', Http\Controller\AuthorizeController::class)
->post('/oauth/authorize', 'oauthProvider.authorize.post', Http\Controller\AuthorizeController::class)
->post('/oauth/token', 'oauthProvider.token', Http\Controller\TokenController::class)
->get('/oauth/userinfo', 'oauthProvider.userinfo', Http\Controller\UserInfoController::class)
->post('/oauth/revoke', 'oauthProvider.revoke', Http\Controller\RevokeController::class)
->post('/oauth/register', 'oauthProvider.register', Http\Controller\RegisterClientController::class)
->get('/.well-known/openid-configuration', 'oauthProvider.discovery', Http\Controller\OpenIdConfigurationController::class)
->get('/.well-known/oauth-authorization-server', 'oauthProvider.metadata', Http\Controller\AuthorizationServerMetadataController::class)
->get('/.well-known/jwks.json', 'oauthProvider.jwks', Http\Controller\JwksController::class),
// Called by OAuth clients without a session; they authenticate as clients, not users.
(new Extend\Csrf())
->exemptRoute('oauthProvider.token')
->exemptRoute('oauthProvider.revoke')
->exemptRoute('oauthProvider.register'),
new Extend\ApiResource(Api\Resource\ClientResource::class),
new Extend\ApiResource(Api\Resource\ConsentResource::class),
(new Extend\SearchDriver(DatabaseSearchDriver::class))
->addFilter(UserSearcher::class, Search\ConnectedClientFilter::class),
(new Extend\Settings())
->default(ClientRegistration\AllowedClients::SELF_REGISTERED_SETTING, true)
->default(ClientRegistration\AllowedClients::ADMIN_SETTING, true),
(new Extend\Conditional())
// The applications a member connected are personal data: exported
// with the member, disconnected when they are anonymised or erased.
->whenExtensionEnabled('flarum-gdpr', fn () => [
(new GdprUserData())
->addType(Data\ConnectedApplications::class),
])
->whenExtensionEnabled('flarum-audit', fn () => [
(new Audit())
->group('flarum-oauth-provider')
->using(new AuditIntegration()),
]),
(new Extend\Event())
->listen(LoggedOut::class, Listener\DisconnectApplicationsOnGlobalLogout::class)
->listen(PasswordChanged::class, Listener\DisconnectApplicationsOnPasswordChange::class),
(new Extend\View())
->namespace('flarum-oauth-provider', __DIR__.'/resources/views'),
(new Extend\ServiceProvider())
->register(Provider\OAuthProviderServiceProvider::class),
(new Extend\Console())
->command(Console\PruneClientsCommand::class)
->schedule(Console\PruneClientsCommand::class, function (Event $event): void {
$event->daily();
}),
];