Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ba8691

Browse files
authored
Merge pull request#263 from context-hub/hotfix/oauth-init
refactor: enhance OAuth initialization and middleware registration
2 parents2da5e70 +342a5e7 commit5ba8691

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

‎src/McpServer/HttpTransportBootloader.php‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@
3232
useMcp\Server\Authentication\Storage\InMemoryClientRepository;
3333
useMcp\Server\Transports\Middleware\CorsMiddleware;
3434
useMcp\Server\Transports\Middleware\ProxyAwareMiddleware;
35+
usePsr\Container\ContainerInterface;
3536
useSpiral\Boot\Bootloader\Bootloader;
3637
useSpiral\Boot\EnvironmentInterface;
38+
useSpiral\Config\ConfiguratorInterface;
3739
useSpiral\McpServer\MiddlewareRegistryInterface;
3840

3941
finalclass HttpTransportBootloaderextends Bootloader
4042
{
43+
publicfunction__construct(
44+
privatereadonlyConfiguratorInterface$configurator,
45+
) {}
46+
4147
#[\Override]
4248
publicfunctiondefineSingletons():array
4349
{
@@ -177,13 +183,23 @@ public function defineSingletons(): array
177183
];
178184
}
179185

186+
publicfunctioninit(EnvironmentInterface$env):void
187+
{
188+
$this->configurator->setDefaults(OauthConfig::CONFIG, [
189+
'enabled' => (bool)$env->get('OAUTH_ENABLED',false),
190+
'client_id' =>$env->get('OAUTH_CLIENT_ID'),
191+
'client_secret' =>$env->get('OAUTH_CLIENT_SECRET'),
192+
]);
193+
}
194+
180195
publicfunctionboot(
181196
MiddlewareRegistryInterface$registry,
182197
EnvironmentInterface$env,
183-
McpAuthRouter$oauthRouter,
184198
ExceptionHandlerMiddleware$exceptionHandler,
185199
LoggerMiddleware$logger,
186200
AuthMiddleware$authMiddleware,
201+
OauthConfig$oauthConfig,
202+
ContainerInterface$container,
187203
):void {
188204
$convertValues =staticfn(
189205
string|null|bool$values,
@@ -212,8 +228,8 @@ public function boot(
212228
);
213229

214230
// Register OAuth router middleware if enabled
215-
if ((bool)$env->get('OAUTH_ENABLED',false)) {
216-
$registry->register($oauthRouter);
231+
if ($oauthConfig->isEnabled() &&$oauthConfig->hasCredentials()) {
232+
$registry->register($container->get(McpAuthRouter::class));
217233
}
218234

219235
$registry->register($authMiddleware);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp