Skip to content

Commit e9dc35b

Browse files
author
Derek Jones
committed
initial commit
0 parents  commit e9dc35b

File tree

9 files changed

+264
-0
lines changed

9 files changed

+264
-0
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[*.{php,js,css,json,xml,json}]
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[*.md]
14+
indent_style = space
15+
indent_size = 4
16+
trim_trailing_whitespace = false
17+
18+
[*.{rst,rb,yml},package.json]
19+
indent_style = space
20+
indent_size = 2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
vendor

.travis.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
- 5.6
8+
- 7.0
9+
- 7.1
10+
11+
install:
12+
- composer install
13+
14+
script:
15+
- cross_origin_headers/vendor/bin/parallel-lint --exclude cross_origin_headers/vendor .
16+
17+
before_deploy:
18+
- composer install --no-dev
19+
- zip -r 'Cross-Origin Headers' cross_origin_headers
20+
21+
deploy:
22+
provider: releases
23+
api_key:
24+
secure: EOjv+D4YETI60ba+VHx2N2nJ5euSUNXb3Lu2rhO8dy2U6hV9T9nSg7O/ujUJBLjR9mPYPgVgjt4dvhfmpYjqU7QBpMaslcQGnIonwBtUSVwiIv/9Gemto/Uqb1hL3Vd/WBGdMzqNOq49Ds0VJeRnq+BdWmGWRind9mSyMIV6HUKRj2H1gNAh37eqdNkHsVeIXd/cHhMtAeXo2iYtuzrHx1m8NuM0CAnZCBfzTKbiu2DDjVXjc56rbZ2/YgcO9KjEh4bk2gq4pv95qsDzoMaiGprQELbSDo/y33IKT1IvgVa9odl4WxFuhyc298HZn05RKAyFrrAW8cOHpQ6NfXVOSGA0KEqeXfJi0x7r4DzDyEs7SgLk3n+oUGk2zb0rbVmr7h9HUS/BDo6SBLD1fPiz5L/u4klHoYmzu6DjkvAsdmSGj6eFcpmU1ciDT30fQj+6/2NxbNn/8JJoYzXgVnCgBzSGlvdYUzigvUU5TiBAN7bDqplbrTJpb3CLEcrR3fdNiJ8sW4aT6vrWPYcJqFjYnT/th5NqNK9z1EW5guojD4ysDdSp2WMzjdVupRbVr9mT3uC/v5uHsbS8SGGQ0RQMNGzJroVebMZ9nVuq8iEFjn7TxvoUDaUmw8ElvmxmJmZ3RlPPvneddcKJqgPgJWnAtgQza/2hfGVDuv1B+wr+PqI=
25+
file: "Cross-Origin Headers.zip"
26+
skip_cleanup: true
27+
on:
28+
php: 7.1
29+
tags: true
30+
condition: $TRAVIS_PULL_REQUEST = false

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cross_origin_headers/README.md

composer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"require": {},
3+
"config": {
4+
"vendor-dir": "cross_origin_headers/vendor"
5+
},
6+
"require-dev": {
7+
"jakub-onderka/php-parallel-lint": "^0.9.2"
8+
}
9+
}

composer.lock

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cross_origin_headers/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Cross-Origin Headers
2+
3+
Adds an `Access-Control-Allow-Origin` header to any request made to a template that includes this tag.
4+
5+
## Requirements
6+
7+
- ExpressionEngine 3
8+
9+
## Installation
10+
11+
1. Download the [latest release](https://github.com/EllisLab/Cross-Origin-Headers/releases/latest).
12+
2. Copy the `cross_origin_headers` folder to your `system/user/addons` folder (you can ignore the rest of this repository's files).
13+
3. In your ExpressionEngine control panel, visit the Add-On Manager and click Install next to "Cross-Origin Headers".
14+
15+
## Usage
16+
17+
### `{exp:cross_origin_headers}`
18+
19+
#### Example Usage
20+
21+
The Cross-Origin Headers plugin is a single tag that you can put anywhere in your template. It might be best to put it near the top, or at least in your template comments so it's clear to anyone reading your template for the first time what's going on.
22+
23+
```
24+
{exp:cross_origin_headers}
25+
```
26+
27+
#### Parameters
28+
29+
##### domain= (default: `*`)
30+
31+
A specific domain to allow cross-origin access. The default `*` will allow the request to come from any source, essentially making this a public resource.
32+
33+
```
34+
{exp:cross_origin_headers domain='http://example.com'}
35+
```
36+
37+
Due to a practical restriction in implementation of the [Access-Control-Allow-Origin standard](https://www.w3.org/TR/cors/#access-control-allow-origin-response-header), you can only specify a single origin. Therefore this plugin works when you want a fully public resource, or restricted to a single origin. If you need endpoints to be available from multiple domains, but not be public, then you will need to handle that in your server configuration. See the article [Cross-Origin Resource Sharing](https://expressionengine.com/learn/cross-origin-resource-sharing-cors) for potential options.
38+
39+
**Note:** You must specify the protocol (`http://`, `https://`) with the domain, as each are treated as separate origins.
40+
41+
## Change Log
42+
43+
### 1.0.0
44+
45+
- Initial release. Boom!
46+
47+
## Additional Files
48+
49+
You may be wondering what the rest of the files in this package are for. They are solely for development, so if you are forking the GitHub repo, they can be helpful. If you are just using the add-on in your ExpressionEngine installation, you can ignore all of these files.
50+
51+
- **.editorconfig**: [EditorConfig](http://editorconfig.org) helps developers maintain consistent coding styles across files and text editors.
52+
- **.gitignore:** [.gitignore](https://git-scm.com/docs/gitignore) lets you specify files in your working environment that you do not want under source control.
53+
- **.travis.yml:** A [Travis CI](https://travis-ci.org) configuration file for continuous integration (automated testing, releases, etc.).
54+
- **.composer.json:** A [Composer project setup file](https://getcomposer.org/doc/01-basic-usage.md) that manages development dependencies.
55+
- **.composer.lock:** A [list of dependency versions](https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file) that Composer has locked to this project.
56+
57+
## License
58+
59+
Copyright (C) 2016 EllisLab, Inc.
60+
61+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
62+
63+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
64+
65+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ELLISLAB, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66+
67+
Except as contained in this notice, the name of EllisLab, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from EllisLab, Inc.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return array(
4+
'author' => 'EllisLab',
5+
'author_url' => 'https://ellislab.com/',
6+
'name' => 'Cross-Origin Headers',
7+
'description' => 'Outputs headers in a template to enable CORS (cross-origin resource sharing).',
8+
'version' => '1.0.0',
9+
'namespace' => 'User\Addons\CrossOriginHeaders',
10+
'settings_exist' => FALSE
11+
);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
3+
/*
4+
Copyright (C) 2016 EllisLab, Inc.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
ELLISLAB, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
Except as contained in this notice, the name of EllisLab, Inc. shall not be
24+
used in advertising or otherwise to promote the sale, use or other dealings
25+
in this Software without prior written authorization from EllisLab, Inc.
26+
*/
27+
28+
/**
29+
* Cross-Origin Headers Class
30+
*
31+
* @package ExpressionEngine
32+
* @category Plugin
33+
* @author EllisLab
34+
* @copyright Copyright (c) 2016, EllisLab, Inc.
35+
* @link https://github.com/EllisLab/Cross-Origin-Headers
36+
*/
37+
class Cross_origin_headers {
38+
39+
/*
40+
* @var string The plugin return data
41+
*/
42+
public $return_data;
43+
44+
/**
45+
* Constructor
46+
*
47+
* @access public
48+
* @return void
49+
*/
50+
public function __construct()
51+
{
52+
$domain = (ee()->TMPL->fetch_param('domain', '*'));
53+
ee()->output->set_header("Access-Control-Allow-Origin: ${domain}");
54+
}
55+
}
56+
// END CLASS
57+
58+
// EOF

0 commit comments

Comments
 (0)