1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Merge pull request #3882 from wallabag/fix/cors

Fix CORS for API
This commit is contained in:
Kevin Decherf 2019-02-13 15:05:57 +01:00 committed by GitHub
commit b1992b340e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 16 deletions

View file

@ -147,18 +147,18 @@ nelmio_cors:
paths: paths:
'^/api/': '^/api/':
allow_origin: ['*'] allow_origin: ['*']
allow_headers: ['X-Custom-Auth'] allow_headers: ['Authorization','content-type']
allow_methods: ['POST', 'PUT', 'PATCH','GET', 'DELETE'] allow_methods: ['POST', 'PUT', 'PATCH','GET', 'DELETE']
max_age: 3600 max_age: 3600
'^/oauth/': '^/oauth/':
allow_origin: ['*'] allow_origin: ['*']
allow_headers: ['X-Custom-Auth'] allow_headers: ['Authorization','content-type']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE'] allow_methods: ['POST', 'PUT', 'GET', 'DELETE']
max_age: 3600 max_age: 3600
'^/': '^/':
#origin_regex: true #origin_regex: true
allow_origin: ['^http://localhost:[0-9]+'] allow_origin: ['*']
allow_headers: ['X-Custom-Auth'] allow_headers: ['Authorization','content-type']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE'] allow_methods: ['POST', 'PUT', 'GET', 'DELETE']
max_age: 3600 max_age: 3600
hosts: ['^api\.'] hosts: ['^api\.']

View file

@ -108,7 +108,7 @@ class EntryFilterType extends AbstractType
->add('httpStatus', TextFilterType::class, [ ->add('httpStatus', TextFilterType::class, [
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
$value = $values['value']; $value = $values['value'];
if (false === array_key_exists($value, Response::$statusTexts)) { if (false === \array_key_exists($value, Response::$statusTexts)) {
return; return;
} }

View file

@ -23,7 +23,7 @@ class PreparePagerForEntries
* @param AdapterInterface $adapter * @param AdapterInterface $adapter
* @param User $user If user isn't logged in, we can force it (like for rss) * @param User $user If user isn't logged in, we can force it (like for rss)
* *
* @return null|Pagerfanta * @return Pagerfanta|null
*/ */
public function prepare(AdapterInterface $adapter, User $user = null) public function prepare(AdapterInterface $adapter, User $user = null)
{ {

View file

@ -22,7 +22,7 @@ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository
* @param string $host * @param string $host
* @param int $userId * @param int $userId
* *
* @return null|array * @return array|null
*/ */
public function findOneByHostAndUser($host, $userId) public function findOneByHostAndUser($host, $userId)
{ {

View file

@ -77,7 +77,7 @@ abstract class BrowserImport extends AbstractImport
*/ */
public function parseEntry(array $importedEntry) public function parseEntry(array $importedEntry)
{ {
if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && \is_array(reset($importedEntry))) { if ((!\array_key_exists('guid', $importedEntry) || (!\array_key_exists('id', $importedEntry))) && \is_array(reset($importedEntry))) {
if ($this->producer) { if ($this->producer) {
$this->parseEntriesForProducer($importedEntry); $this->parseEntriesForProducer($importedEntry);
@ -89,7 +89,7 @@ abstract class BrowserImport extends AbstractImport
return; return;
} }
if (array_key_exists('children', $importedEntry)) { if (\array_key_exists('children', $importedEntry)) {
if ($this->producer) { if ($this->producer) {
$this->parseEntriesForProducer($importedEntry['children']); $this->parseEntriesForProducer($importedEntry['children']);
@ -101,11 +101,11 @@ abstract class BrowserImport extends AbstractImport
return; return;
} }
if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) { if (!\array_key_exists('uri', $importedEntry) && !\array_key_exists('url', $importedEntry)) {
return; return;
} }
$url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url']; $url = \array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
$existingEntry = $this->em $existingEntry = $this->em
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
@ -126,7 +126,7 @@ abstract class BrowserImport extends AbstractImport
// update entry with content (in case fetching failed, the given entry will be return) // update entry with content (in case fetching failed, the given entry will be return)
$this->fetchContent($entry, $data['url'], $data); $this->fetchContent($entry, $data['url'], $data);
if (array_key_exists('tags', $data)) { if (\array_key_exists('tags', $data)) {
$this->tagsAssigner->assignTagsToEntry( $this->tagsAssigner->assignTagsToEntry(
$entry, $entry,
$data['tags'] $data['tags']

View file

@ -57,7 +57,7 @@ class ChromeImport extends BrowserImport
'created_at' => substr($entry['date_added'], 0, 10), 'created_at' => substr($entry['date_added'], 0, 10),
]; ];
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags']; $data['tags'] = $entry['tags'];
} }

View file

@ -57,7 +57,7 @@ class FirefoxImport extends BrowserImport
'created_at' => substr($entry['dateAdded'], 0, 10), 'created_at' => substr($entry['dateAdded'], 0, 10),
]; ];
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags']; $data['tags'] = $entry['tags'];
} }

View file

@ -122,7 +122,7 @@ abstract class WallabagImport extends AbstractImport
// update entry with content (in case fetching failed, the given entry will be return) // update entry with content (in case fetching failed, the given entry will be return)
$this->fetchContent($entry, $data['url'], $data); $this->fetchContent($entry, $data['url'], $data);
if (array_key_exists('tags', $data)) { if (\array_key_exists('tags', $data)) {
$this->tagsAssigner->assignTagsToEntry( $this->tagsAssigner->assignTagsToEntry(
$entry, $entry,
$data['tags'], $data['tags'],

View file

@ -61,7 +61,7 @@ class WallabagV1Import extends WallabagImport
$data['html'] = $this->fetchingErrorMessage; $data['html'] = $this->fetchingErrorMessage;
} }
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
$data['tags'] = $entry['tags']; $data['tags'] = $entry['tags'];
} }