forum-oauth-center/extend.php

66 lines
3.3 KiB
PHP
Raw Permalink Normal View History

2023-09-28 17:42:13 +08:00
<?php
/*
* This file is part of foskym/flarum-oauth-center.
*
* Copyright (c) 2023 FoskyM.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace RhodesIsland\OAuthCenter;
2023-09-28 17:42:13 +08:00
use Flarum\Extend;
use Flarum\Http\Middleware\AuthenticateWithHeader;
2023-10-02 03:37:57 +08:00
use Flarum\Http\Middleware\CheckCsrfToken;
use RhodesIsland\OAuthCenter\Middlewares\ResourceScopeMiddleware;
use RhodesIsland\OAuthCenter\Middlewares\UnsetCsrfMiddleware;
use RhodesIsland\OAuthCenter\Middlewares\UserCredentialsMiddleware;
2023-09-28 17:42:13 +08:00
return [
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
2023-09-29 14:47:36 +08:00
->css(__DIR__.'/less/forum.less')
->route('/oauth/authorize', 'oauth.authorize'),
2023-09-28 17:42:13 +08:00
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/less/admin.less'),
new Extend\Locales(__DIR__.'/locale'),
2023-09-29 14:47:36 +08:00
(new Extend\Routes('forum'))
2023-10-02 03:37:57 +08:00
->post('/oauth/authorize', 'oauth.authorize.post', Controllers\AuthorizeController::class)
->post('/oauth/authorize/redirect', 'oauth.authorize.redirect', Controllers\AuthorizeRedirectController::class)
2023-10-02 03:37:57 +08:00
->post('/oauth/token', 'oauth.token', Controllers\TokenController::class),
2023-10-01 16:55:27 +08:00
2023-09-29 22:25:55 +08:00
(new Extend\Routes('api'))
2023-10-01 16:55:27 +08:00
->get('/oauth-clients', 'oauth.clients.list', Api\Controller\ListClientController::class)
->post('/oauth-clients', 'oauth.clients.create', Api\Controller\CreateClientController::class)
2023-10-01 17:41:52 +08:00
->get('/oauth-clients/{client_id}', 'oauth.clients.show', Api\Controller\ShowClientController::class)
2023-10-01 16:55:27 +08:00
->patch('/oauth-clients/{id}', 'oauth.clients.update', Api\Controller\UpdateClientController::class)
2023-10-01 19:41:17 +08:00
->delete('/oauth-clients/{id}', 'oauth.clients.delete', Api\Controller\DeleteClientController::class)
2023-10-01 19:43:01 +08:00
->get('/oauth-scopes', 'oauth.scopes.list', Api\Controller\ListScopeController::class)
->post('/oauth-scopes', 'oauth.scopes.create', Api\Controller\CreateScopeController::class)
->patch('/oauth-scopes/{id}', 'oauth.scopes.update', Api\Controller\UpdateScopeController::class)
->delete('/oauth-scopes/{id}', 'oauth.scopes.delete', Api\Controller\DeleteScopeController::class)
->get('/oauth-records', 'oauth.records.list', Api\Controller\ListRecordController::class)
->get('/user', 'user.show', Controllers\ApiUserController::class),
2023-09-29 14:47:36 +08:00
2023-10-01 18:18:43 +08:00
(new Extend\Settings)
->serializeToForum('rhodes-island-oauth-center.display_mode', 'rhodes-island-oauth-center.display_mode')
2024-02-25 04:55:37 +08:00
->serializeToForum('rhodes-island-oauth-center.allow_implicit', 'rhodes-island-oauth-center.allow_implicit', 'boolval')
->serializeToForum('rhodes-island-oauth-center.enforce_state', 'rhodes-island-oauth-center.enforce_state', 'boolval')
->serializeToForum('rhodes-island-oauth-center.require_exact_redirect_uri', 'rhodes-island-oauth-center.require_exact_redirect_uri', 'boolval')
->serializeToForum('rhodes-island-oauth-center.use_redirect_authorize', 'rhodes-island-oauth-center.use_redirect_authorize', 'boolval'),
2023-10-01 18:18:43 +08:00
(new Extend\Middleware('api'))
->insertAfter(AuthenticateWithHeader::class, ResourceScopeMiddleware::class),
2023-10-02 03:37:57 +08:00
(new Extend\Middleware('forum'))
->insertBefore(CheckCsrfToken::class, UnsetCsrfMiddleware::class)
->insertAfter(CheckCsrfToken::class, UserCredentialsMiddleware::class),
2023-09-28 17:42:13 +08:00
];