Skip to content

fix(laravel): fixes to secure a graphql endpoint #6691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 4, 2024

Conversation

soyuka
Copy link
Member

@soyuka soyuka commented Oct 3, 2024

As @toitzi reported GraphQl endpoints had no way to be secured. After a few messages we decided to introduce a new configuration option:

// app/config/api-platform.php
    'routes' => [
        // Global middleware applied to every API Platform routes
        // 'middleware' => []
    ],

This gives the ability to plugin in a global auth middleware and to use Policies with GraphQl operations.

@soyuka soyuka force-pushed the fix/middleware branch 5 times, most recently from 8ee5f60 to 9ce74cc Compare October 4, 2024 08:47
@soyuka soyuka changed the base branch from main to 4.0 October 4, 2024 08:47
@soyuka soyuka marked this pull request as ready for review October 4, 2024 08:57
@@ -936,51 +940,6 @@ public function register(): void
);
});

if ($this->app['config']->get('api-platform.graphql.enabled')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not good to read configuration inside the register method as it may change when boot is called

$app->make(CallableProcessor::class),
);
});

$app->singleton(ResolverFactoryInterface::class, function (Application $app) {
return new ResolverFactory(
$app->make('api_platform.graphql.state_provider'),
$app->make('api_platform.graphql.state_provider.access_checker'),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinceAmstoutz I splitted the system providers for Laravel!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soyuka 🎉 Can we prepare documentation now and merge it when your PR will be merged?

if (isset($values[$parsedKey[0]])) {
$values = $values[$parsedKey[0]];

if ($filter instanceof FilterInterface) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point this will get deprecated

@soyuka soyuka merged commit f9d96e5 into api-platform:4.0 Oct 4, 2024
60 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants