added cors bundle to allow external api access (#655)

This commit is contained in:
Kevin Papst
2019-03-23 11:04:55 +01:00
committed by GitHub
parent 13d9f8f3f7
commit 38ae013e03
8 changed files with 103 additions and 1 deletions

View File

@@ -25,3 +25,7 @@ DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://localhost(:[0-9]+)?$
###< nelmio/cors-bundle ###

View File

@@ -30,6 +30,10 @@ The table prefix is now hardcoded to `kimai2_`. If you used another prefix, you
before starting the update process. You can also delete the row `DATABASE_PREFIX` from your `.env` file.
- API: DateTime objects will be returned including timezone identifier (previously 2019-03-02 14:23 - now 2019-03-02T14:23:00+00:00)
**Check if you want to apply changes to your `local.yaml`:**
- New permission is available available: `system_configuration`
## [0.8.1](https://github.com/kevinpapst/kimai2/releases/tag/0.8.1)
A bug fixing release. Remember to execute the necessary timezone conversion script, if you haven't updated to 0.8 before (see below)!

View File

@@ -23,6 +23,7 @@
"kimai/kimai2-composer": "^0.1",
"mpdf/mpdf": "^7.1",
"nelmio/api-doc-bundle": "^3.2",
"nelmio/cors-bundle": "^1.5",
"ocramius/proxy-manager": "2.1.1",
"phpoffice/phpspreadsheet": "^1.4",
"phpoffice/phpword": "^0.15.0",

60
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "df4ac341f40ef97bcd3b78174125b1c5",
"content-hash": "89fb63af4a70745a81b734b4a3efb494",
"packages": [
{
"name": "beberlei/DoctrineExtensions",
@@ -2826,6 +2826,64 @@
],
"time": "2019-01-25T17:25:46+00:00"
},
{
"name": "nelmio/cors-bundle",
"version": "1.5.5",
"source": {
"type": "git",
"url": "https://github.com/nelmio/NelmioCorsBundle.git",
"reference": "adabee944e6fe52ee566caf1770a29355b1e8d83"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/adabee944e6fe52ee566caf1770a29355b1e8d83",
"reference": "adabee944e6fe52ee566caf1770a29355b1e8d83",
"shasum": ""
},
"require": {
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "^1.0 || ^2.0",
"mockery/mockery": "^0.9 || ^1.0",
"symfony/phpunit-bridge": "^2.7 || ^3.0 || ^4.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.5.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 Symfony2 application",
"keywords": [
"api",
"cors",
"crossdomain"
],
"time": "2019-02-27T13:13:15+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.2.0",

View File

@@ -22,4 +22,5 @@ return [
FOS\UserBundle\FOSUserBundle::class => ['all' => true],
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
];

View File

@@ -0,0 +1,21 @@
nelmio_cors:
defaults:
allow_credentials: false
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_headers: []
# allow_headers: ['Content-Type', 'Authorization', 'X-AUTH-USER', 'X-AUTH-TOKEN']
allow_methods: []
# allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
expose_headers: []
# expose_headers: ['Link']
max_age: 0
# max_age: 3600
hosts: []
origin_regex: true
forced_allow_origin_value: ~
paths:
'^/api/':
allow_origin: ['*']
allow_headers: ['X-AUTH-USER', 'X-AUTH-TOKEN']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
max_age: 3600

View File

@@ -25,6 +25,10 @@
<!-- ###+ symfony/swiftmailer-bundle ### -->
<env name="MAILER_URL" value="null://localhost" force="true"/>
<!-- ###- symfony/swiftmailer-bundle ### -->
<!-- ###+ nelmio/cors-bundle ### -->
<env name="CORS_ALLOW_ORIGIN" value="^https?://localhost(:[0-9]+)?$"/>
<!-- ###- nelmio/cors-bundle ### -->
</php>
<testsuites>

View File

@@ -194,6 +194,15 @@
"ref": "c8e0c38e1a280ab9e37587a8fa32b251d5bc1c94"
}
},
"nelmio/cors-bundle": {
"version": "1.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.5",
"ref": "f0436fc35fca88eada758311f8de43bfb61f1980"
}
},
"nikic/php-parser": {
"version": "v4.0.2"
},