Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename private-network-access feature #320

Merged
merged 5 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 23 additions & 35 deletions .github/workflows/ci-post-merge.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: CI (post-merge)

on:
push:
branches: [master]
push: { branches: [master] }

permissions:
contents: read # to fetch code (actions/checkout)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_test_linux_nightly:
Expand All @@ -27,39 +33,26 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install ${{ matrix.version }}
uses: actions-rs/toolchain@v1
- name: Install Rust (${{ matrix.version }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.version }}-${{ matrix.target.triple }}
profile: minimal
override: true
toolchain: ${{ matrix.version }}

- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2.1.0
- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-hack }

- name: check minimal
uses: actions-rs/cargo@v1
with: { command: ci-min }
run: cargo ci-min

- name: check minimal + examples
uses: actions-rs/cargo@v1
with: { command: ci-check-min-examples }
run: cargo ci-check-min-examples

- name: check default
uses: actions-rs/cargo@v1
with: { command: ci-check }
run: cargo ci-check

- name: tests
uses: actions-rs/cargo@v1
timeout-minutes: 40
with: { command: ci-test }
run: cargo ci-test

- name: Clear the cargo caches
run: |
Expand All @@ -86,18 +79,13 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install ${{ matrix.version }}
run: |
rustup install ${{ matrix.version }}-${{ matrix.target.triple }}
rustup override set ${{ matrix.version }}-${{ matrix.target.triple }}

- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Install Rust (${{ matrix.version }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.version }}

- name: Generate Cargo.lock
run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2.1.0
- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-hack }

- name: check minimal
run: cargo ci-min
Expand Down
84 changes: 28 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: CI

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [master]
pull_request: {}
push: { branches: [master] }

permissions:
contents: read # to fetch code (actions/checkout)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_test_linux:
Expand Down Expand Up @@ -35,33 +40,18 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install ${{ matrix.version }}
run: |
rustup install ${{ matrix.version }}-${{ matrix.target.triple }}
rustup override set ${{ matrix.version }}-${{ matrix.target.triple }}

- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Install Rust (${{ matrix.version }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.version }}

- name: workaround MSRV issues
if: matrix.version != 'stable'
run: |
cargo install cargo-edit --version=0.8.0
cargo add env_logger@0.9 --dev -p=actix-cors
cargo add env_logger@0.9 --dev -p=actix-identity
cargo add env_logger@0.9 --dev -p=actix-redis
cargo add env_logger@0.9 --dev -p=actix-session
cargo add env_logger@0.9 --dev -p=actix-settings

- name: Generate Cargo.lock
run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2.1.0
- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-hack }

- name: workaround MSRV issues
if: matrix.version != 'stable'
run: |
cargo update -p=time --precise=0.3.13
cargo update -p=time:0.3.20 --precise=0.3.16

- name: check minimal
run: cargo ci-min
Expand Down Expand Up @@ -102,33 +92,21 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install ${{ matrix.version }}
run: |
rustup install ${{ matrix.version }}-${{ matrix.target.triple }}
rustup override set ${{ matrix.version }}-${{ matrix.target.triple }}
- name: Install Rust (${{ matrix.version }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.version }}

- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-hack }

- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-hack }

- name: workaround MSRV issues
if: matrix.version != 'stable'
run: |
cargo install cargo-edit --version=0.8.0
cargo add env_logger@0.9 --dev -p=actix-cors
cargo add env_logger@0.9 --dev -p=actix-identity
cargo add env_logger@0.9 --dev -p=actix-redis
cargo add env_logger@0.9 --dev -p=actix-session
cargo add env_logger@0.9 --dev -p=actix-settings

- name: Generate Cargo.lock
run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2.1.0

- name: workaround MSRV issues
if: matrix.version != 'stable'
run: |
cargo update -p=time --precise=0.3.13
cargo update -p=time:0.3.20 --precise=0.3.16

- name: check minimal
run: cargo ci-min
Expand All @@ -155,14 +133,8 @@ jobs:
- uses: actions/checkout@v3

- name: Install Rust (nightly)
run: |
rustup install nightly
rustup override set nightly

- name: Generate Cargo.lock
run: cargo generate-lockfile
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2.1.0
uses: actions-rust-lang/setup-rust-toolchain@v1
with: { toolchain: nightly }

- name: doc tests
timeout-minutes: 40
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
name: Coverage

on:
push:
branches: [master]
push: { branches: [master] }

permissions:
contents: read # to fetch code (actions/checkout)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
coverage:
Expand Down
52 changes: 40 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
name: Lint

on:
pull_request:
types: [opened, synchronize, reopened]
on: [pull_request]

permissions:
contents: read # to fetch code (actions/checkout)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust
run: |
rustup override set nightly
rustup update nightly
rustup component add rustfmt
- name: Install Rust (nightly)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt

- name: Check with rustfmt
run: cargo fmt --all -- --check

Expand All @@ -24,9 +30,31 @@ jobs:
- uses: actions/checkout@v3

- name: Install Rust
run: |
rustup override set stable
rustup update stable
rustup component add rustfmt
uses: actions-rust-lang/setup-rust-toolchain@v1
with: { components: clippy }

- name: Check with Clippy
run: cargo clippy --workspace --tests --all-features

public-api-diff:
runs-on: ubuntu-latest
steps:
- name: checkout ${{ github.base_ref }}
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}

- name: checkout ${{ github.head_ref }}
uses: actions/checkout@v3

- uses: actions-rust-lang/setup-rust-toolchain@v1
with: { toolchain: nightly }

- uses: taiki-e/cache-cargo-install-action@v1
with: { tool: cargo-public-api }

- name: generate API diff
run: |
for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do
cargo public-api --manifest-path "$f" --all-features diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }}
done
10 changes: 8 additions & 2 deletions .github/workflows/upload-doc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: Upload Documentation

on:
push:
branches: [master]
push: { branches: [master] }

permissions:
contents: read # to fetch code (actions/checkout)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions actix-cors/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased - 2022-xx-xx

- Rename `Cors::{allow_private_network_access => allow_local_network_access}()` and its unstable flag (`draft-private-network-access` => `draft-local-network-access`).
- Minimum supported Rust version (MSRV) is now 1.60.

## 0.6.4 - 2022-10-28
Expand Down
2 changes: 1 addition & 1 deletion actix-cors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
all-features = true

[features]
draft-private-network-access = []
draft-local-network-access = []

[dependencies]
actix-utils = "3"
Expand Down
24 changes: 12 additions & 12 deletions actix-cors/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl Cors {
preflight: true,
send_wildcard: false,
supports_credentials: true,
#[cfg(feature = "draft-private-network-access")]
allow_private_network_access: false,
#[cfg(feature = "draft-local-network-access")]
allow_local_network_access: false,
vary_header: true,
block_on_origin_mismatch: true,
};
Expand Down Expand Up @@ -422,19 +422,19 @@ impl Cors {

/// Allow private network access.
///
/// If true, injects the `Access-Control-Allow-Private-Network: true` header in responses if the
/// request contained the `Access-Control-Request-Private-Network: true` header.
/// If true, injects the `Access-Control-Allow-Local-Network: true` header in responses if the
/// request contained the `Access-Control-Request-Local-Network: true` header.
///
/// For more information on this behavior, see the draft [Private Network Access] spec.
/// For more information on this behavior, see the draft [Local Network Access] spec.
///
/// Defaults to `false`.
///
/// [Private Network Access]: https://wicg.github.io/private-network-access
#[cfg(feature = "draft-private-network-access")]
#[cfg_attr(docsrs, doc(cfg(feature = "draft-private-network-access")))]
pub fn allow_private_network_access(mut self) -> Cors {
/// [Private Network Access]: https://wicg.github.io/local-network-access
#[cfg(feature = "draft-local-network-access")]
#[cfg_attr(docsrs, doc(cfg(feature = "draft-local-network-access")))]
pub fn allow_local_network_access(mut self) -> Cors {
if let Some(cors) = cors(&mut self.inner, &self.error) {
cors.allow_private_network_access = true;
cors.allow_local_network_access = true;
}

self
Expand Down Expand Up @@ -514,8 +514,8 @@ impl Default for Cors {
preflight: true,
send_wildcard: false,
supports_credentials: false,
#[cfg(feature = "draft-private-network-access")]
allow_private_network_access: false,
#[cfg(feature = "draft-local-network-access")]
allow_local_network_access: false,
vary_header: true,
block_on_origin_mismatch: true,
};
Expand Down
Loading