force allow cors

This commit is contained in:
Hesabix 2023-12-30 06:45:30 +00:00
parent 82055b5b60
commit 9daa4bdad0
69 changed files with 5881 additions and 5791 deletions

View file

@ -22,3 +22,7 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###> symfony/mailer ### ###> symfony/mailer ###
MAILER_DSN=null://null MAILER_DSN=null://null
###< symfony/mailer ### ###< symfony/mailer ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='*'
###< nelmio/cors-bundle ###

View file

@ -18,6 +18,7 @@
"gregwar/captcha-bundle": "^2.2", "gregwar/captcha-bundle": "^2.2",
"melipayamak/php": "1.0.0", "melipayamak/php": "1.0.0",
"mpdf/mpdf": "^8.2", "mpdf/mpdf": "^8.2",
"nelmio/cors-bundle": "^2.4",
"phpdocumentor/reflection-docblock": "^5.3", "phpdocumentor/reflection-docblock": "^5.3",
"phpoffice/phpspreadsheet": "^1.29", "phpoffice/phpspreadsheet": "^1.29",
"phpstan/phpdoc-parser": "^1.16", "phpstan/phpdoc-parser": "^1.16",

View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d64efcccc20c485b523c63e628808194", "content-hash": "bf4224d6036db7f5892091d37f3160dc",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -2441,6 +2441,68 @@
], ],
"time": "2023-03-08T13:26:56+00:00" "time": "2023-03-08T13:26:56+00:00"
}, },
{
"name": "nelmio/cors-bundle",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/nelmio/NelmioCorsBundle.git",
"reference": "78fcdb91f76b080a1008133def9c7f613833933d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/78fcdb91f76b080a1008133def9c7f613833933d",
"reference": "78fcdb91f76b080a1008133def9c7f613833933d",
"shasum": ""
},
"require": {
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"mockery/mockery": "^1.3.6",
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Nelmio\\CorsBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nelmio",
"homepage": "http://nelm.io"
},
{
"name": "Symfony Community",
"homepage": "https://github.com/nelmio/NelmioCorsBundle/contributors"
}
],
"description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application",
"keywords": [
"api",
"cors",
"crossdomain"
],
"support": {
"issues": "https://github.com/nelmio/NelmioCorsBundle/issues",
"source": "https://github.com/nelmio/NelmioCorsBundle/tree/2.4.0"
},
"time": "2023-11-30T16:41:19+00:00"
},
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
"version": "v9.99.100", "version": "v9.99.100",
@ -10864,5 +10926,5 @@
"ext-iconv": "*" "ext-iconv": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.6.0" "plugin-api-version": "2.2.0"
} }

View file

@ -14,4 +14,5 @@ return [
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true], Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true], FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
]; ];

View file

@ -0,0 +1,10 @@
nelmio_cors:
defaults:
origin_regex: false
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['*']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null

View file

@ -41,11 +41,10 @@ class ApiKeyAuthenticator extends AbstractAuthenticator
public function authenticate(Request $request): Passport public function authenticate(Request $request): Passport
{ {
$apiToken = $request->headers->get('X-AUTH-TOKEN'); $apiToken = $request->headers->get('X-AUTH-TOKEN');
if (null == $apiToken) { if (null == $apiToken) {
// The token header was empty, authentication fails with HTTP Status // The token header was empty, authentication fails with HTTP Status
// Code 401 "Unauthorized" // Code 401 "Unauthorized"
//throw new CustomUserMessageAuthenticationException('No API token provided'); throw new CustomUserMessageAuthenticationException('No API token provided');
} }
@ -68,6 +67,8 @@ class ApiKeyAuthenticator extends AbstractAuthenticator
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
{ {
echo 55;
die();
$data = [ $data = [
// you may want to customize or obfuscate the message first // you may want to customize or obfuscate the message first
'message' => strtr($exception->getMessageKey(), $exception->getMessageData()) 'message' => strtr($exception->getMessageKey(), $exception->getMessageData())

View file

@ -50,6 +50,18 @@
"gregwar/captcha-bundle": { "gregwar/captcha-bundle": {
"version": "v2.2.0" "version": "v2.2.0"
}, },
"nelmio/cors-bundle": {
"version": "2.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.5",
"ref": "6bea22e6c564fba3a1391615cada1437d0bde39c"
},
"files": [
"config/packages/nelmio_cors.yaml"
]
},
"phpunit/phpunit": { "phpunit/phpunit": {
"version": "9.6", "version": "9.6",
"recipe": { "recipe": {

View file

@ -1,8 +1,7 @@
<?php <?php
use App\Kernel; use App\Kernel;
require_once dirname(__DIR__).'/hesabixCore/vendor/autoload_runtime.php'; require_once dirname(__DIR__).'/hesabixCore/vendor/autoload_runtime.php';
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Credentials: true");
return function (array $context) { return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
}; };