-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into event-hooks
- Loading branch information
Showing
20 changed files
with
439 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!--vale off--> | ||
|
||
{% mermaid %} | ||
flowchart LR | ||
|
||
A("Request") | ||
B("`Route | ||
(/mock)`") | ||
C("`Service | ||
(example_service)`") | ||
D("Target | ||
(httpbin.konghq.com)") | ||
E("Target | ||
(httpbun.com)") | ||
F(httpbin.konghq.com) | ||
G(httpbun.com) | ||
|
||
A --> B | ||
subgraph id1 ["`**KONG GATEWAY**`"] | ||
B --> C --> D & E | ||
subgraph id3 ["`**Upstream** (load balancer)`"] | ||
|
||
D & E | ||
end | ||
|
||
end | ||
|
||
subgraph id2 ["`**Upstream targets**`"] | ||
D --> F | ||
E --> G | ||
|
||
end | ||
|
||
style id2 stroke:none | ||
{% endmermaid %} | ||
|
||
<!--vale on--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
## Understanding CORS | ||
|
||
For security purposes a browser will stop requests from accessing URLs on different domains. This is done using CORS, a set of rules for web applications that make requests across origin. CORS works by looking at the HTTP `origin` header of a URL and checking it against a list of allowed headers. An `origin` header can contain the `scheme`, `hostname`, or `port` of the requesting URL. Operations that are restricted to same-origin content can be managed using CORS. | ||
|
||
When making a cross-origin request, browsers issue an `origin` request header, and servers must respond with a matching `Access-Control-Allow-Origin` (ACAO) header. If the two headers do not match, the browser will discard the response, and any application components that require that response’s data will not function properly. | ||
|
||
For example, the following request and response pairs have matching CORS headers, and will succeed: | ||
|
||
```sh | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
Origin: http://example.net | ||
|
||
HTTP/1.1 200 OK | ||
Access-Control-Allow-Origin: http://example.net | ||
``` | ||
|
||
```sh | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
Origin: http://example.net | ||
|
||
HTTP/1.1 200 OK | ||
Access-Control-Allow-Origin: * | ||
``` | ||
|
||
The requests do not have a matching CORS headers and therefore will fail: | ||
|
||
```sh | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
Origin: http://example.net | ||
|
||
HTTP/1.1 200 OK | ||
Access-Control-Allow-Origin: http://badbadcors.example | ||
``` | ||
|
||
```sh | ||
GET / HTTP/1.1 | ||
Host: example.com | ||
Origin: http://example.net | ||
|
||
HTTP/1.1 200 OK | ||
``` | ||
|
||
Missing CORS headers when CORS headers are expected results in failure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/_kong_plugins/cors/examples/allow-requests-from-specific-domain.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
title: Allow requests from a specific domain | ||
description: | | ||
Configures the CORS plugin to allow `GET` and `POST` requests from a specific domain. | ||
weight: 400 | ||
|
||
config: | ||
origins: | ||
- http://mockbin.com | ||
methods: | ||
- GET | ||
- POST |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
content_type: plugin_reference |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.