Merge pull request #2 from actix/master

0124
This commit is contained in:
zzy 2020-01-24 09:59:44 +08:00 committed by GitHub
commit 1835de747c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 112 additions and 18 deletions

32
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,32 @@
Your issue may already be reported!
Please search on the [Actix Web issue tracker](https://github.com/actix/actix-web/issues) before creating one.
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Rust Version (I.e, output of `rustc -V`):
* Actix Web Version:

42
.github/workflows/bench.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: Benchmark (Linux)
on: [push, pull_request]
jobs:
check_benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-${{ hashFiles('**/Cargo.lock') }}
- name: Check benchmark
uses: actions-rs/cargo@v1
with:
command: bench

View File

@ -27,7 +27,7 @@ jobs:
- name: Generate Cargo.lock - name: Generate Cargo.lock
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: update command: generate-lockfile
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v1 uses: actions/cache@v1
with: with:

View File

@ -30,7 +30,7 @@ jobs:
- name: Generate Cargo.lock - name: Generate Cargo.lock
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: update command: generate-lockfile
- name: Cache cargo registry - name: Cache cargo registry
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
@ -46,18 +46,15 @@ jobs:
with: with:
path: target path: target
key: ${{ matrix.version }}-x86_64-pc-windows-msvc-cargo-build-${{ hashFiles('**/Cargo.lock') }} key: ${{ matrix.version }}-x86_64-pc-windows-msvc-cargo-build-${{ hashFiles('**/Cargo.lock') }}
- name: Cache vcpkg package
uses: actions/cache@v1
id: cache-vcpkg
with:
path: C:\vcpkg
key: windows_x64-${{ matrix.version }}-vcpkg
- name: Install OpenSSL - name: Install OpenSSL
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: | run: |
vcpkg integrate install vcpkg integrate install
vcpkg install openssl:x64-windows vcpkg install openssl:x64-windows
Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll
Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll
Get-ChildItem C:\vcpkg\installed\x64-windows\bin
Get-ChildItem C:\vcpkg\installed\x64-windows\lib
- name: check build - name: check build
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1

View File

@ -1,3 +1,9 @@
## Unreleased
* Setting a cookie's SameSite property, explicitly, to `SameSite::None` will now
result in `SameSite=None` being sent with the response Set-Cookie header.
To create a cookie without a SameSite attribute, remove any calls setting same_site.
## 2.0.0 ## 2.0.0
* `HttpServer::start()` renamed to `HttpServer::run()`. It also possible to * `HttpServer::start()` renamed to `HttpServer::run()`. It also possible to

View File

@ -1,5 +1,11 @@
# Changes # Changes
# [Unreleased]
### Fixed
* Allow `SameSite=None` cookies to be sent in a response.
## [1.0.1] - 2019-12-20 ## [1.0.1] - 2019-12-20
### Fixed ### Fixed

View File

@ -10,18 +10,26 @@ use std::fmt;
/// attribute is "Strict", then the cookie is never sent in cross-site requests. /// attribute is "Strict", then the cookie is never sent in cross-site requests.
/// If the `SameSite` attribute is "Lax", the cookie is only sent in cross-site /// If the `SameSite` attribute is "Lax", the cookie is only sent in cross-site
/// requests with "safe" HTTP methods, i.e, `GET`, `HEAD`, `OPTIONS`, `TRACE`. /// requests with "safe" HTTP methods, i.e, `GET`, `HEAD`, `OPTIONS`, `TRACE`.
/// If the `SameSite` attribute is not present (made explicit via the /// If the `SameSite` attribute is not present then the cookie will be sent as
/// `SameSite::None` variant), then the cookie will be sent as normal. /// normal. In some browsers, this will implicitly handle the cookie as if "Lax"
/// and in others, "None". It's best to explicitly set the `SameSite` attribute
/// to avoid inconsistent behavior.
///
/// **Note:** Depending on browser, the `Secure` attribute may be required for
/// `SameSite` "None" cookies to be accepted.
/// ///
/// **Note:** This cookie attribute is an HTTP draft! Its meaning and definition /// **Note:** This cookie attribute is an HTTP draft! Its meaning and definition
/// are subject to change. /// are subject to change.
///
/// More info about these draft changes can be found in the draft spec:
/// - https://tools.ietf.org/html/draft-west-cookie-incrementalism-00
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SameSite { pub enum SameSite {
/// The "Strict" `SameSite` attribute. /// The "Strict" `SameSite` attribute.
Strict, Strict,
/// The "Lax" `SameSite` attribute. /// The "Lax" `SameSite` attribute.
Lax, Lax,
/// No `SameSite` attribute. /// The "None" `SameSite` attribute.
None, None,
} }
@ -92,7 +100,7 @@ impl fmt::Display for SameSite {
match *self { match *self {
SameSite::Strict => write!(f, "Strict"), SameSite::Strict => write!(f, "Strict"),
SameSite::Lax => write!(f, "Lax"), SameSite::Lax => write!(f, "Lax"),
SameSite::None => Ok(()), SameSite::None => write!(f, "None"),
} }
} }
} }

View File

@ -746,10 +746,8 @@ impl<'c> Cookie<'c> {
} }
if let Some(same_site) = self.same_site() { if let Some(same_site) = self.same_site() {
if !same_site.is_none() {
write!(f, "; SameSite={}", same_site)?; write!(f, "; SameSite={}", same_site)?;
} }
}
if let Some(path) = self.path() { if let Some(path) = self.path() {
write!(f, "; Path={}", path)?; write!(f, "; Path={}", path)?;
@ -1037,7 +1035,7 @@ mod tests {
let cookie = Cookie::build("foo", "bar") let cookie = Cookie::build("foo", "bar")
.same_site(SameSite::None) .same_site(SameSite::None)
.finish(); .finish();
assert_eq!(&cookie.to_string(), "foo=bar"); assert_eq!(&cookie.to_string(), "foo=bar; SameSite=None");
} }
#[test] #[test]

5
codecov.yml Normal file
View File

@ -0,0 +1,5 @@
ignore: # ignore codecoverage on following paths
- "**/tests"
- "test-server"
- "**/benches"
- "**/examples"