Skip to content

Commit

Permalink
Release v2.0.1 and document it
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Schaefermeyer committed Jan 26, 2020
1 parent ac31fdc commit a21f3ea
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
28 changes: 19 additions & 9 deletions CHANGELOG.md
@@ -1,28 +1,38 @@
# Changelog

## v.2.0.0
## v2.0.1
* Enhancements
* Passing a function with arity 2 as `origin` will pass the `conn` to the
function, allowing configuration based on conn (thanks @billionlaughs).
* You can now pass regexes as part of the list of origins (thanks @gabrielpra1).
* Fixes
* Fixes an issue where the request was missing the
`access-control-request-headers` (thanks @zhhz for the initial report and
@mfeckie for the fix).

## v2.0.0

* Enhancements
* Instead of sending `"null"` we don't set the headers at all if the origin doesn't match, as suggested by the [CORS draft 7.2](https://w3c.github.io/webappsec-cors-for-developers/#avoid-returning-access-control-allow-origin-null). Thanks to @YuLeven for initiating the discussion and @slashmili for fixing it. Since we change the return values I consider this a breaking change and released a new major version.
* You can now set the option `send_preflight_response?` to `false` (it's `true` by default) to stop `CorsPlug` sending a response to the preflight request. That way the correct headers are set but it's up to you to respond to the request downstream.

## v.1.5.2
## v1.5.2

* Fixes
* Relax version requirements

## v.1.5.1
## v1.5.1

* Fixes
* Send proper return value if `Access-Control-Request-Headers` is not present.
(thanks @shivamMg)

## v.1.5.0
## v1.5.0

* Enhancements
* Allow configuration of origin via function (thanks @mauricioszabo).

## v.1.4.0
## v1.4.0

* Enhancements
* Allows both `*` as well as specific domains in the `origins` config, returns
Expand All @@ -35,19 +45,19 @@
New major release because of the `vary` header changes, I don't expect this
to break anything.

## v.1.3.0
## v1.3.0

* Enhancements
* Allows configuration via app config (see [README.md](README.md), thanks
@TokiTori).

## v.1.2.1
## v1.2.1

* Fixes
* Match for exact origin only (thanks @somlor and @JordanAdams).
* Add Vary to response header (thanks @linjunpop).

## v.1.2.0
## v1.2.0

* Fixes
* Remove cowboy dependency. Plug should be server-agnostic and this plug does
Expand Down Expand Up @@ -112,6 +122,6 @@ this is a new major).
* Improve readme (thanks @leighhalliday, @patricksrobertson)
* Simplify travis.yml (thanks @lowks)

## v.0.1.2
## v0.1.2

* Release plug dependency
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright 2014 Michael Schaefermeyer
Copyright 2020 Michael Schaefermeyer

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
17 changes: 15 additions & 2 deletions README.md
Expand Up @@ -79,6 +79,8 @@ You can configure allowed origins using one of the following methods:

### Using a list

**Lists can now be comprised of strings, regexes or a mix of both:**

```elixir
plug CORSPlug, origin: ["http://example1.com", "http://example2.com", ~r/https?.*example\d?\.com$/]
```
Expand All @@ -89,6 +91,7 @@ plug CORSPlug, origin: ["http://example1.com", "http://example2.com", ~r/https?.
plug CORSPlug, origin: ~r/https?.*example\d?\.com$/
```


### Using the config.exs file

```elixir
Expand All @@ -98,7 +101,7 @@ config :cors_plug,
methods: ["GET", "POST"]
```

### Using a `function/0` that returns the allowed origin as a string
### Using a `function/0` or `function/1` that returns the allowed origin as a string

**Caveat: Anonymous functions are not possible as they can't be quoted.**

Expand All @@ -110,6 +113,16 @@ def my_fun do
end
```

```elixir
plug CORSPlug, origin: &MyModule.my_fun/1

def my_fun(conn) do
# Do something with conn

["http://example.com"]
end
```

### send_preflight_response?

There may be times when you would like to retain control over the response sent to OPTIONS requests. If you
Expand All @@ -136,7 +149,7 @@ the string `null` is returned when no configured origin matched the request.**

## License

Copyright 2017 Michael Schaefermeyer
Copyright 2020 Michael Schaefermeyer

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -4,7 +4,7 @@ defmodule CorsPlug.Mixfile do
def project do
[
app: :cors_plug,
version: "2.0.0",
version: "2.0.1",
elixir: "~> 1.3",
deps: deps(),
package: package(),
Expand Down

0 comments on commit a21f3ea

Please sign in to comment.