Skip to content
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

[api-platform/core] prevent a deprecation warning and sync with upstream #1227

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api-platform/core/3.1/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
api_platform:
title: Hello API Platform
version: 1.0.0
# Good defaults for REST APIs
defaults:
stateless: true
Copy link
Member

Choose a reason for hiding this comment

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

This might be too opinionated? If you create a frontend on the same domain that logs in via cookies, then authentication wouldn't work, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Cookies can be used, but the session cannot. It's one of the mandatory constraints of the REST architecture.

IMHO it's not opinionated, it's just encouraging the correct way of creating REST APIs (and web applications in general).

Better let the user remove this line only if they know what they are doing (and by doing that they are probably doing a mistake) than having them creating non-stateless "REST" APIs.

Copy link
Member Author

Choose a reason for hiding this comment

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

By the way since 6.3 stateless routes automatically enable stateless firewalls, so enabling this feature shouldn't be an issue even when using the default config of firewalls: https://symfony.com/doc/current/reference/configuration/security.html#stateless

Copy link
Member

Choose a reason for hiding this comment

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

but if this is the good thing to do, why isn't it the default in ApiPlatform then ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I'm talking about the default in the Configuration class of the bundle (i.e. the actual default value of the setting), not the config provided in the API platform distribution.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this would be a BC break. We'll maybe do that for API Platform 4 next year.

cache_headers:
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true
4 changes: 4 additions & 0 deletions api-platform/core/3.1/config/routes/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
api_platform:
resource: .
type: api_platform
prefix: /api
9 changes: 9 additions & 0 deletions api-platform/core/3.1/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bundles": {
"ApiPlatform\\Symfony\\Bundle\\ApiPlatformBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/",
"src/": "%SRC_DIR%/"
}
}
8 changes: 8 additions & 0 deletions api-platform/core/3.1/post-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Your API is almost ready:
1. Create your first API resource in <info>src/ApiResource</info>;
dunglas marked this conversation as resolved.
Show resolved Hide resolved
2. Go to <info>/api</info> to browse your API

* To enable the GraphQL support, run <comment>composer require webonyx/graphql-php</>,
then browse <info>/api/graphql</info>.

* <fg=blue>Read</> the documentation at <comment>https://api-platform.com/docs</>
Empty file.
Loading