Only serve ID stuff on main domain and just redirect the id.flashii.net URLs.
This commit is contained in:
parent
6e0726fd3f
commit
8be630531a
6 changed files with 92 additions and 95 deletions
|
@ -7,5 +7,5 @@ database:dsn mariadb://<user>:<pass>@<host>/<name>?charset=utf8mb4
|
|||
;sentry:tracesRate 1.0
|
||||
;sentry:profilesRate 1.0
|
||||
|
||||
domain:localhost main redirect id
|
||||
domain:localhost main redirect
|
||||
domain:localhost:redirect:path /go
|
||||
|
|
|
@ -23,10 +23,10 @@ use Misuzu\OAuth2\OAuth2Context;
|
|||
use Misuzu\Perms\PermissionsData;
|
||||
use Misuzu\Profile\ProfileFieldsData;
|
||||
use Misuzu\Redirects\RedirectsContext;
|
||||
use Misuzu\Routing\BackedRoutingContext;
|
||||
use Misuzu\Routing\{BackedRoutingContext,RoutingContext};
|
||||
use Misuzu\Users\{UsersContext,UserInfo};
|
||||
use RPCii\HmacVerificationProvider;
|
||||
use RPCii\Server\HttpRpcServer;
|
||||
use RPCii\Server\{HttpRpcServer,RpcServer};
|
||||
|
||||
// this class should function as the root for everything going forward
|
||||
// no more magical static classes that are just kind of assumed to exist
|
||||
|
@ -178,84 +178,82 @@ class MisuzuContext {
|
|||
new HmacVerificationProvider(fn() => $this->config->getString('aleister.secret'))
|
||||
));
|
||||
|
||||
if(in_array('main', $purposes)) {
|
||||
$scopedInfo = $hostInfo->scopeTo('main');
|
||||
$scopedCtx = $routingCtx->scopeTo(
|
||||
$scopedInfo->getString('name'),
|
||||
$scopedInfo->getString('path')
|
||||
if(in_array('main', $purposes))
|
||||
$this->registerMainRoutes(
|
||||
$routingCtx->scopeTo($hostInfo->getString('main:path')),
|
||||
$rpcServer
|
||||
);
|
||||
|
||||
$scopedCtx->register($this->deps->constructLazy(Home\HomeRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Users\Assets\AssetsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Info\InfoRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(News\NewsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(
|
||||
Messages\MessagesRoutes::class,
|
||||
config: $this->config->scopeTo('messages')
|
||||
));
|
||||
$scopedCtx->register($this->deps->constructLazy(Forum\ForumCategoriesRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Forum\ForumTopicsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Forum\ForumPostsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Changelog\ChangelogRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(
|
||||
SharpChat\SharpChatRoutes::class,
|
||||
config: $this->config->scopeTo('sockChat'),
|
||||
impersonateConfig: $this->config->scopeTo('impersonate')
|
||||
));
|
||||
$scopedCtx->register($this->deps->constructLazy(
|
||||
Satori\SatoriRoutes::class,
|
||||
config: $this->config->scopeTo('satori')
|
||||
));
|
||||
$scopedCtx->register($this->deps->constructLazy(LegacyRoutes::class));
|
||||
|
||||
$rpcServer->register($this->deps->constructLazy(
|
||||
Auth\AuthRpcHandler::class,
|
||||
impersonateConfig: $this->config->scopeTo('impersonate')
|
||||
));
|
||||
$rpcServer->register($this->deps->constructLazy(Emoticons\EmotesRpcHandler::class));
|
||||
$rpcServer->register($this->deps->constructLazy(Users\UsersRpcHandler::class));
|
||||
|
||||
$hanyuuRpcServer = new HttpRpcServer;
|
||||
$scopedCtx->scopeTo('', '/_hanyuu')->register($hanyuuRpcServer->createRouteHandler(
|
||||
new HmacVerificationProvider(fn() => $this->config->getString('hanyuu.secret'))
|
||||
));
|
||||
|
||||
$hanyuuRpcServer->register($this->deps->constructLazy(
|
||||
Hanyuu\HanyuuRpcHandler::class,
|
||||
getBaseUrl: fn() => $this->config->getString('hanyuu.endpoint'),
|
||||
impersonateConfig: $this->config->scopeTo('impersonate')
|
||||
));
|
||||
}
|
||||
|
||||
if(in_array('id', $purposes)) {
|
||||
$scopedInfo = $hostInfo->scopeTo('id');
|
||||
$scopedCtx = $routingCtx->scopeTo(
|
||||
$scopedInfo->getString('name'),
|
||||
$scopedInfo->getString('path')
|
||||
if(in_array('redirect', $purposes))
|
||||
$this->registerRedirectorRoutes(
|
||||
$routingCtx->scopeTo($hostInfo->getString('redirect:path'))
|
||||
);
|
||||
|
||||
$scopedCtx->register($this->deps->constructLazy(OAuth2\OAuth2ApiRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(OAuth2\OAuth2WebRoutes::class));
|
||||
$rpcServer->register($this->deps->constructLazy(OAuth2\OAuth2RpcHandler::class));
|
||||
}
|
||||
|
||||
if(in_array('redirect', $purposes)) {
|
||||
$scopedInfo = $hostInfo->scopeTo('redirect');
|
||||
$scopedCtx = $routingCtx->scopeTo(
|
||||
$scopedInfo->getString('name'),
|
||||
$scopedInfo->getString('path')
|
||||
);
|
||||
|
||||
$scopedCtx->register($this->deps->constructLazy(Redirects\LandingRedirectsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Redirects\AliasRedirectsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(Redirects\IncrementalRedirectsRoutes::class));
|
||||
$scopedCtx->register($this->deps->constructLazy(
|
||||
Redirects\SocialRedirectsRoutes::class,
|
||||
getWebAssetInfo: $this->getWebAssetInfo(...)
|
||||
));
|
||||
$scopedCtx->register($this->deps->constructLazy(Redirects\NamedRedirectsRoutes::class));
|
||||
}
|
||||
|
||||
return $routingCtx;
|
||||
}
|
||||
|
||||
public function registerMainRoutes(
|
||||
RoutingContext $routingCtx,
|
||||
RpcServer $rpcServer
|
||||
): void {
|
||||
$routingCtx->register($this->deps->constructLazy(Home\HomeRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(Users\Assets\AssetsRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(Info\InfoRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(News\NewsRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(
|
||||
Messages\MessagesRoutes::class,
|
||||
config: $this->config->scopeTo('messages')
|
||||
));
|
||||
|
||||
$routingCtx->register($this->deps->constructLazy(OAuth2\OAuth2ApiRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(OAuth2\OAuth2WebRoutes::class));
|
||||
$rpcServer->register($this->deps->constructLazy(OAuth2\OAuth2RpcHandler::class));
|
||||
|
||||
$routingCtx->register($this->deps->constructLazy(Forum\ForumCategoriesRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(Forum\ForumTopicsRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(Forum\ForumPostsRoutes::class));
|
||||
|
||||
$routingCtx->register($this->deps->constructLazy(Changelog\ChangelogRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(
|
||||
SharpChat\SharpChatRoutes::class,
|
||||
config: $this->config->scopeTo('sockChat'),
|
||||
impersonateConfig: $this->config->scopeTo('impersonate')
|
||||
));
|
||||
|
||||
$routingCtx->register($this->deps->constructLazy(
|
||||
Satori\SatoriRoutes::class,
|
||||
config: $this->config->scopeTo('satori')
|
||||
));
|
||||
|
||||
$routingCtx->register($this->deps->constructLazy(LegacyRoutes::class));
|
||||
|
||||
$rpcServer->register($this->deps->constructLazy(
|
||||
Auth\AuthRpcHandler::class,
|
||||
impersonateConfig: $this->config->scopeTo('impersonate')
|
||||
));
|
||||
$rpcServer->register($this->deps->constructLazy(Emoticons\EmotesRpcHandler::class));
|
||||
$rpcServer->register($this->deps->constructLazy(Users\UsersRpcHandler::class));
|
||||
|
||||
$hanyuuRpcServer = new HttpRpcServer;
|
||||
$routingCtx->scopeTo('', '/_hanyuu')->register($hanyuuRpcServer->createRouteHandler(
|
||||
new HmacVerificationProvider(fn() => $this->config->getString('hanyuu.secret'))
|
||||
));
|
||||
|
||||
$hanyuuRpcServer->register($this->deps->constructLazy(
|
||||
Hanyuu\HanyuuRpcHandler::class,
|
||||
getBaseUrl: fn() => $this->config->getString('hanyuu.endpoint'),
|
||||
impersonateConfig: $this->config->scopeTo('impersonate')
|
||||
));
|
||||
}
|
||||
|
||||
public function registerRedirectorRoutes(RoutingContext $routingCtx): void {
|
||||
$routingCtx->register($this->deps->constructLazy(Redirects\LandingRedirectsRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(Redirects\AliasRedirectsRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(Redirects\IncrementalRedirectsRoutes::class));
|
||||
$routingCtx->register($this->deps->constructLazy(
|
||||
Redirects\SocialRedirectsRoutes::class,
|
||||
getWebAssetInfo: $this->getWebAssetInfo(...)
|
||||
));
|
||||
$routingCtx->register($this->deps->constructLazy(Redirects\NamedRedirectsRoutes::class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ final class OAuth2WebRoutes implements RouteHandler {
|
|||
private OAuth2Context $oauth2Ctx,
|
||||
private UsersContext $usersCtx,
|
||||
private UrlRegistry $urls,
|
||||
private SiteInfo $siteInfo,
|
||||
private AuthInfo $authInfo
|
||||
) {
|
||||
}
|
||||
|
@ -216,8 +215,8 @@ final class OAuth2WebRoutes implements RouteHandler {
|
|||
'user' => [
|
||||
'name' => $this->authInfo->userInfo->name,
|
||||
'colour' => (string)$this->usersCtx->getUserColour($this->authInfo->userInfo),
|
||||
'profile_uri' => $this->siteInfo->url . $this->urls->format('user-profile', ['user' => $this->authInfo->userInfo->id]),
|
||||
'avatar_uri' => $this->siteInfo->url . $this->urls->format('user-avatar', ['user' => $this->authInfo->userInfo->id, 'res' => 120]),
|
||||
'profile_uri' => $this->urls->format('user-profile', ['user' => $this->authInfo->userInfo->id]),
|
||||
'avatar_uri' => $this->urls->format('user-avatar', ['user' => $this->authInfo->userInfo->id, 'res' => 120]),
|
||||
],
|
||||
'scope' => $scope,
|
||||
];
|
||||
|
@ -226,9 +225,9 @@ final class OAuth2WebRoutes implements RouteHandler {
|
|||
$result['user']['guise'] = [
|
||||
'name' => $this->authInfo->realUserInfo->name,
|
||||
'colour' => (string)$this->usersCtx->getUserColour($this->authInfo->realUserInfo),
|
||||
'profile_uri' => $this->siteInfo->url . $this->urls->format('user-profile', ['user' => $this->authInfo->realUserInfo->id]),
|
||||
'revert_uri' => $this->siteInfo->url . $this->urls->format('auth-revert', ['csrf' => CSRF::token()]),
|
||||
'avatar_uri' => $this->siteInfo->url . $this->urls->format('user-avatar', ['user' => $this->authInfo->realUserInfo->id, 'res' => 60]),
|
||||
'profile_uri' => $this->urls->format('user-profile', ['user' => $this->authInfo->realUserInfo->id]),
|
||||
'revert_uri' => $this->urls->format('auth-revert', ['csrf' => CSRF::token()]),
|
||||
'avatar_uri' => $this->urls->format('user-avatar', ['user' => $this->authInfo->realUserInfo->id, 'res' => 60]),
|
||||
];
|
||||
|
||||
return $result;
|
||||
|
@ -411,8 +410,8 @@ final class OAuth2WebRoutes implements RouteHandler {
|
|||
'user' => [
|
||||
'name' => $this->authInfo->userInfo->name,
|
||||
'colour' => (string)$this->usersCtx->getUserColour($this->authInfo->userInfo),
|
||||
'profile_uri' => $this->siteInfo->url . $this->urls->format('user-profile', ['user' => $this->authInfo->userInfo->id]),
|
||||
'avatar_uri' => $this->siteInfo->url . $this->urls->format('user-avatar', ['user' => $this->authInfo->userInfo->id, 'res' => 120]),
|
||||
'profile_uri' => $this->urls->format('user-profile', ['user' => $this->authInfo->userInfo->id]),
|
||||
'avatar_uri' => $this->urls->format('user-avatar', ['user' => $this->authInfo->userInfo->id, 'res' => 120]),
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -420,9 +419,9 @@ final class OAuth2WebRoutes implements RouteHandler {
|
|||
$result['user']['guise'] = [
|
||||
'name' => $this->authInfo->realUserInfo->name,
|
||||
'colour' => (string)$this->usersCtx->getUserColour($this->authInfo->realUserInfo),
|
||||
'profile_uri' => $this->siteInfo->url . $this->urls->format('user-profile', ['user' => $this->authInfo->realUserInfo->id]),
|
||||
'revert_uri' => $this->siteInfo->url . $this->urls->format('auth-revert', ['csrf' => CSRF::token()]),
|
||||
'avatar_uri' => $this->siteInfo->url . $this->urls->format('user-avatar', ['user' => $this->authInfo->realUserInfo->id, 'res' => 60]),
|
||||
'profile_uri' => $this->urls->format('user-profile', ['user' => $this->authInfo->realUserInfo->id]),
|
||||
'revert_uri' => $this->urls->format('auth-revert', ['csrf' => CSRF::token()]),
|
||||
'avatar_uri' => $this->urls->format('user-avatar', ['user' => $this->authInfo->realUserInfo->id, 'res' => 60]),
|
||||
];
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -25,10 +25,10 @@ class BackedRoutingContext implements RoutingContext {
|
|||
$this->urls->register($handler);
|
||||
}
|
||||
|
||||
public function scopeTo(string $namePrefix, string $pathPrefix): RoutingContext {
|
||||
public function scopeTo(string $prefix): RoutingContext {
|
||||
return new ScopedRoutingContext(
|
||||
$this->router->scopeTo($pathPrefix),
|
||||
$this->urls->scopeTo($namePrefix, $pathPrefix)
|
||||
$this->router->scopeTo($prefix),
|
||||
$this->urls->scopeTo(pathPrefix: $prefix)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,5 +7,5 @@ use Index\Urls\UrlSource;
|
|||
|
||||
interface RoutingContext {
|
||||
public function register(RouteHandler|UrlSource $handler): void;
|
||||
public function scopeTo(string $namePrefix, string $pathPrefix): RoutingContext;
|
||||
public function scopeTo(string $prefix): RoutingContext;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ class ScopedRoutingContext implements RoutingContext {
|
|||
$this->urls->register($handler);
|
||||
}
|
||||
|
||||
public function scopeTo(string $namePrefix, string $pathPrefix): RoutingContext {
|
||||
public function scopeTo(string $prefix): RoutingContext {
|
||||
return new ScopedRoutingContext(
|
||||
$this->router->scopeTo($pathPrefix),
|
||||
$this->urls->scopeTo($namePrefix, $pathPrefix)
|
||||
$this->router->scopeTo($prefix),
|
||||
$this->urls->scopeTo(pathPrefix: $prefix)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue