Skip to content

Commit fb6f6db

Browse files
author
Sk Niyaj Ali
committed
update
1 parent 9f98cd9 commit fb6f6db

File tree

7,683 files changed

+909705
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,683 files changed

+909705
-2
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/public/hot
33
/public/storage
44
/storage/*.key
5-
/vendor
65
.env
76
.env.backup
87
.phpunit.result.cache

vendor/asm89/stack-cors/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2013-2017 Alexander <iam.asm89@gmail.com>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

vendor/asm89/stack-cors/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Stack/Cors
2+
3+
Library and middleware enabling cross-origin resource sharing for your
4+
http-{foundation,kernel} using application. It attempts to implement the
5+
[W3C Recommendation] for cross-origin resource sharing.
6+
7+
[W3C Recommendation]: http://www.w3.org/TR/cors/
8+
9+
Build status: ![.github/workflows/run-tests.yml](https://github.com/asm89/stack-cors/workflows/.github/workflows/run-tests.yml/badge.svg)
10+
11+
## Installation
12+
13+
Require `asm89/stack-cors` using composer.
14+
15+
## Usage
16+
17+
This package can be used as a library or as [stack middleware].
18+
19+
[stack middleware]: http://stackphp.com/
20+
21+
### Options
22+
23+
| Option | Description | Default value |
24+
|------------------------|------------------------------------------------------------|---------------|
25+
| allowedMethods | Matches the request method. | `array()` |
26+
| allowedOrigins | Matches the request origin. | `array()` |
27+
| allowedOriginsPatterns | Matches the request origin with `preg_match`. | `array()` |
28+
| allowedHeaders | Sets the Access-Control-Allow-Headers response header. | `array()` |
29+
| exposedHeaders | Sets the Access-Control-Expose-Headers response header. | `false` |
30+
| maxAge | Sets the Access-Control-Max-Age response header. | `false` |
31+
| supportsCredentials | Sets the Access-Control-Allow-Credentials header. | `false` |
32+
33+
The _allowedMethods_ and _allowedHeaders_ options are case-insensitive.
34+
35+
You don't need to provide both _allowedOrigins_ and _allowedOriginsPatterns_. If one of the strings passed matches, it is considered a valid origin.
36+
37+
If `array('*')` is provided to _allowedMethods_, _allowedOrigins_ or _allowedHeaders_ all methods / origins / headers are allowed.
38+
39+
### Example: using the library
40+
41+
```php
42+
<?php
43+
44+
use Asm89\Stack\CorsService;
45+
46+
$cors = new CorsService(array(
47+
'allowedHeaders' => array('x-allowed-header', 'x-other-allowed-header'),
48+
'allowedMethods' => array('DELETE', 'GET', 'POST', 'PUT'),
49+
'allowedOrigins' => array('http://localhost'),
50+
'allowedOriginsPatterns' => array('/localhost:\d/'),
51+
'exposedHeaders' => false,
52+
'maxAge' => false,
53+
'supportsCredentials' => false,
54+
));
55+
56+
$cors->addActualRequestHeaders(Response $response, $origin);
57+
$cors->handlePreflightRequest(Request $request);
58+
$cors->isActualRequestAllowed(Request $request);
59+
$cors->isCorsRequest(Request $request);
60+
$cors->isPreflightRequest(Request $request);
61+
```
62+
63+
## Example: using the stack middleware
64+
65+
```php
66+
<?php
67+
68+
use Asm89\Stack\Cors;
69+
70+
$app = new Cors($app, array(
71+
// you can use array('*') to allow any headers
72+
'allowedHeaders' => array('x-allowed-header', 'x-other-allowed-header'),
73+
// you can use array('*') to allow any methods
74+
'allowedMethods' => array('DELETE', 'GET', 'POST', 'PUT'),
75+
// you can use array('*') to allow requests from any origin
76+
'allowedOrigins' => array('localhost'),
77+
// you can enter regexes that are matched to the origin request header
78+
'allowedOriginsPatterns' => array('/localhost:\d/'),
79+
'exposedHeaders' => false,
80+
'maxAge' => false,
81+
'supportsCredentials' => false,
82+
));
83+
```

vendor/asm89/stack-cors/composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "asm89/stack-cors",
3+
"description": "Cross-origin resource sharing library and stack middleware",
4+
"keywords": ["stack", "cors"],
5+
"homepage": "https://github.com/asm89/stack-cors",
6+
"type": "library",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Alexander",
11+
"email": "iam.asm89@gmail.com"
12+
}
13+
],
14+
"require": {
15+
"php": "^7.0|^8.0",
16+
"symfony/http-foundation": "~2.7|~3.0|~4.0|~5.0",
17+
"symfony/http-kernel": "~2.7|~3.0|~4.0|~5.0"
18+
},
19+
"require-dev": {
20+
"phpunit/phpunit": "^6|^7|^8|^9",
21+
"squizlabs/php_codesniffer": "^3.5"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Asm89\\Stack\\": "src/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"Asm89\\Stack\\Tests\\": "tests/"
31+
}
32+
},
33+
"scripts": {
34+
"test": "phpunit",
35+
"check-style": "phpcs -p --standard=PSR12 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src",
36+
"fix-style": "phpcbf -p --standard=PSR12 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src"
37+
},
38+
"extra": {
39+
"branch-alias": {
40+
"dev-master": "2.0-dev"
41+
}
42+
}
43+
}

vendor/asm89/stack-cors/src/Cors.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of asm89/stack-cors.
5+
*
6+
* (c) Alexander <iam.asm89@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Asm89\Stack;
13+
14+
use Symfony\Component\HttpKernel\HttpKernelInterface;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\Response;
17+
18+
class Cors implements HttpKernelInterface
19+
{
20+
/**
21+
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
22+
*/
23+
private $app;
24+
25+
/**
26+
* @var \Asm89\Stack\CorsService
27+
*/
28+
private $cors;
29+
30+
private $defaultOptions = array(
31+
'allowedHeaders' => array(),
32+
'allowedMethods' => array(),
33+
'allowedOrigins' => array(),
34+
'allowedOriginsPatterns' => array(),
35+
'exposedHeaders' => array(),
36+
'maxAge' => 0,
37+
'supportsCredentials' => false,
38+
);
39+
40+
public function __construct(HttpKernelInterface $app, array $options = array())
41+
{
42+
$this->app = $app;
43+
$this->cors = new CorsService(array_merge($this->defaultOptions, $options));
44+
}
45+
46+
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
47+
{
48+
if ($this->cors->isPreflightRequest($request)) {
49+
$response = $this->cors->handlePreflightRequest($request);
50+
return $this->cors->varyHeader($response, 'Access-Control-Request-Method');
51+
}
52+
53+
$response = $this->app->handle($request, $type, $catch);
54+
55+
if ($request->getMethod() === 'OPTIONS') {
56+
$this->cors->varyHeader($response, 'Access-Control-Request-Method');
57+
}
58+
59+
return $this->cors->addActualRequestHeaders($response, $request);
60+
}
61+
}

0 commit comments

Comments
 (0)