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

[php-slim4] Add lazy CORS implementation #11941

Merged
merged 2 commits into from Mar 23, 2022

Conversation

ybelenko
Copy link
Contributor

Core team Slim member recommends to apply CORS headers via custom response emitter to also catch any exceptions.
Ref: slimphp/Slim#2999 (comment)

Closes #6851

Of course I've checked it locally:

* Preparing request to http://phpslim4.test/v2/pet/5
* Current time is 2022-03-22T18:24:37.435Z
* Using libcurl/7.69.1 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.7 libidn2/2.1.1 libssh2/1.9.0 nghttp2/1.41.0
* Using default HTTP version
* Enable timeout of 1000000ms
* Enable automatic URL encoding
* Enable SSL validation
* Enable cookie sending with jar of 0 cookies
* Hostname phpslim4.test was found in DNS cache
*   Trying 127.0.0.1:80...
* Connected to phpslim4.test (127.0.0.1) port 80 (#27)

> OPTIONS /v2/pet/5 HTTP/1.1
> Host: phpslim4.test
> User-Agent: insomnia/2020.4.0
> Access-Control-Request-Method: DELETE
> Access-Control-Request-Headers: Content-Type,X-PINGOTHER
> Origin: http://localhost
> Accept: */*

* Mark bundle as not supporting multiuse

< HTTP/1.1 200 OK
< Date: Tue, 22 Mar 2022 18:24:37 GMT
< Server: Apache/2.4.46 (Unix) PHP/7.4.22
< X-Powered-By: PHP/7.4.22
< Access-Control-Allow-Origin: http://localhost
< Access-Control-Allow-Credentials: true
< Vary: Origin
< Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE
< Access-Control-Allow-Headers: authorization, content-type, x-requested-with
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8


* Received 5 B chunk
* Connection #27 to host phpslim4.test left intact

cc @jebentier, @dkarlovi, @mandrean, @jfastnacht, @renepardon

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

While Slim4 doc applies CORS headers via middleware but their code team
member recommends to use custom response emitter.

Ref: slimphp/Slim#2999 (comment)
@ybelenko ybelenko added this to In progress in PHP Slim4 Server Generator via automation Mar 22, 2022
@ybelenko ybelenko moved this from In progress to Needs review in PHP Slim4 Server Generator Mar 22, 2022
@wing328 wing328 added this to the 6.0.0 milestone Mar 23, 2022
@wing328 wing328 merged commit 7b59e60 into OpenAPITools:master Mar 23, 2022
PHP Slim4 Server Generator automation moved this from Needs review to Done Mar 23, 2022
@ybelenko ybelenko deleted the 6851_slim4_cors_emitter branch March 24, 2022 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[REQ][php-slim4] Add CORS middleware
2 participants