Skip to content

Commit df3cd69

Browse files
committed
2025 Rust starter kit upgrades
Starter kit content changes: * Changed 'wasm32-wasi' target to 'wasm32-wasip1' (requires Rust 1.78 or later and Fastly CLI 11.0 or later) * Changed rust-toolchain.toml to install 'stable' toolchain instead of '1.83.0' * Moved term.color=always from scripts.build in fastly.toml to .cargo/config.toml * Updated Rust edition from 2018 to 2021 * Changed Rust 'release' profile to use LTO * Removed unnecessary parameters from scripts.build in fastly.toml Other changes: * Switched to using a reusable workflow for CI
1 parent 04cf8da commit df3cd69

File tree

5 files changed

+37
-61
lines changed

5 files changed

+37
-61
lines changed

.cargo/config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[target.wasm32-wasi]
2-
rustflags = ["-C", "debuginfo=2"]
3-
41
[build]
5-
target = "wasm32-wasi"
2+
target = "wasm32-wasip1"
3+
4+
[term]
5+
color = "always"

.github/workflows/test.yml

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,14 @@
1-
on: pull_request
21
name: Test
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'Cargo.toml'
7+
- 'rust-toolchain.toml'
8+
- '.cargo/config.toml'
9+
- '.github/workflows/test.yml'
10+
- 'src/**'
11+
312
jobs:
413
test:
5-
strategy:
6-
matrix:
7-
rust-toolchain: [1.83.0]
8-
platform: [ubuntu-latest]
9-
runs-on: ${{ matrix.platform }}
10-
environment: test
11-
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
14-
- name: Install Rust
15-
uses: dtolnay/[email protected]
16-
with:
17-
toolchain: ${{ matrix.rust-toolchain }}
18-
targets: wasm32-wasi
19-
components: clippy, rustfmt
20-
- name: Install audit
21-
run: cargo install cargo-audit
22-
shell: bash
23-
- name: Cache cargo registry
24-
uses: actions/cache@v3
25-
with:
26-
path: ~/.cargo/registry
27-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
28-
- name: Cache cargo index
29-
uses: actions/cache@v3
30-
with:
31-
path: ~/.cargo/git
32-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
33-
- name: Cache cargo build
34-
uses: actions/cache@v3
35-
with:
36-
path: target
37-
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
38-
- name: Store secrets
39-
run: |
40-
echo "${{ secrets.CLIENT_ID }}" > .secrets.client_id
41-
echo "${{ secrets.CLIENT_SECRET }}" > .secrets.client_secret
42-
dd if=/dev/random bs=32 count=1 | base64 > .secret.nonce_secret
43-
- name: Check binaries and format
44-
run: RUSTFLAGS="--deny warnings" cargo check --bins --target wasm32-wasi && cargo fmt -- --check
45-
- name: Run clippy
46-
run: cargo clippy
47-
- name: Run audit
48-
run: cargo audit
49-
- name: Run build
50-
run: cargo build
14+
uses: fastly/devex-reusable-workflows/.github/workflows/compute-starter-kit-rust-v1.yml@main

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
name = "compute-rust-auth"
33
version = "0.4.0"
44
authors = []
5-
edition = "2018"
5+
edition = "2021"
6+
# Remove this line if you want to be able to publish this crate on crates.io.
7+
# Otherwise, `publish = false` prevents an accidental `cargo publish` from revealing private source.
8+
publish = false
69

710
[profile.release]
8-
debug = true
11+
debug = 1
12+
codegen-units = 1
13+
lto = "fat"
914

1015
[dependencies]
1116
fastly = "0.11.2"

fastly.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
authors = ["<[email protected]>"]
1+
# This file describes a Fastly Compute package. To learn more visit:
2+
# https://www.fastly.com/documentation/reference/compute/fastly-toml/
3+
24
name = "Auth at edge with OAuth 2.0"
35
description = "Connect to an identity provider such as Google using OAuth 2.0 and validate authentication status at the Edge, to authorize access to your edge or origin hosted applications."
6+
authors = ["<[email protected]>"]
47
language = "rust"
58
manifest_version = 3
69

10+
[scripts]
11+
build = "cargo build --profile release"
12+
713
[setup]
814

915
[setup.backends]
@@ -20,7 +26,7 @@ manifest_version = 3
2026

2127
[setup.secret_stores.oauth_secrets]
2228
description = "Store for authentication secrets"
23-
29+
2430
[setup.secret_stores.oauth_secrets.entries]
2531

2632
[setup.secret_stores.oauth_secrets.entries.client_id]
@@ -29,7 +35,7 @@ manifest_version = 3
2935
[setup.secret_stores.oauth_secrets.entries.nonce_secret]
3036
description = "A random secret to verify the OpenID nonce used to mitigate replay attacks."
3137

32-
# Optional client secret for certain IdPs' token endpoint.
38+
# Optional client secret for certain IdPs' token endpoint.
3339
# WARNING: Including this parameter produces NON-NORMATIVE OAuth 2.0 token requests.
3440
# Comment out if not required.
3541
[setup.secret_stores.oauth_secrets.entries.client_secret]
@@ -45,7 +51,7 @@ manifest_version = 3
4551
[setup.config_stores.oauth_config.items.openid_configuration]
4652
description = "OpenID Connect (OIDC) discovery document containing OAuth 2.0 endpoints. This is usually obtained from https://YOUR_AUTH_SERVER/.well-known/openid-configuration"
4753
input_type = "string"
48-
54+
4955
[setup.config_stores.oauth_config.items.jwks]
5056
description = "JSON Web Key Set (JWKS) containing the public keys used to verify the JWT signature. You can find this at the jwks_uri endpoint in the OIDC discovery document."
5157
input_type = "string"
@@ -73,7 +79,7 @@ manifest_version = 3
7379
key = "nonce_secret"
7480
file = ".secret.nonce_secret"
7581

76-
# Optional client secret for certain IdPs' token endpoint.
82+
# Optional client secret for certain IdPs' token endpoint.
7783
# WARNING: Including this parameter produces NON-NORMATIVE OAuth 2.0 token requests.
7884
# Comment out if not required.
7985
[[local_server.secret_stores.oauth_secrets]]
@@ -85,7 +91,7 @@ manifest_version = 3
8591
[local_server.config_stores.oauth_config]
8692
format = "inline-toml"
8793

88-
[local_server.config_stores.oauth_config.contents]
94+
[local_server.config_stores.oauth_config.contents]
8995
openid_configuration = "{\"issuer\":\"https://accounts.google.com\",\"authorization_endpoint\":\"https://accounts.google.com/o/oauth2/v2/auth\",\"device_authorization_endpoint\":\"https://oauth2.googleapis.com/device/code\",\"token_endpoint\":\"https://oauth2.googleapis.com/token\",\"userinfo_endpoint\":\"https://openidconnect.googleapis.com/v1/userinfo\",\"revocation_endpoint\":\"https://oauth2.googleapis.com/revoke\",\"jwks_uri\":\"https://www.googleapis.com/oauth2/v3/certs\",\"response_types_supported\":[\"code\",\"token\",\"id_token\",\"code token\",\"code id_token\",\"token id_token\",\"code token id_token\",\"none\"],\"subject_types_supported\":[\"public\"],\"id_token_signing_alg_values_supported\":[\"RS256\"],\"scopes_supported\":[\"openid\",\"email\",\"profile\"],\"token_endpoint_auth_methods_supported\":[\"client_secret_post\",\"client_secret_basic\"],\"claims_supported\":[\"aud\",\"email\",\"email_verified\",\"exp\",\"family_name\",\"given_name\",\"iat\",\"iss\",\"locale\",\"name\",\"picture\",\"sub\"],\"code_challenge_methods_supported\":[\"plain\",\"S256\"],\"grant_types_supported\":[\"authorization_code\",\"refresh_token\",\"urn:ietf:params:oauth:grant-type:device_code\",\"urn:ietf:params:oauth:grant-type:jwt-bearer\"]}"
9096
jwks = "{\"keys\":[{\"e\":\"AQAB\",\"kty\":\"RSA\",\"n\":\"4bAT6C6EeX8Dspje3FrAXw-nnhNk04e1RmNa4kjc0CHf6Pk7ryARlwA-6YilyPABqQfYHx60s8oSnxvUVprFfQ2-Q8aAZO7bPKSxnoGlcKERL2oLNA4Msvc89N9Y5ycThZUplf_QC19e6jyYXN6Nz-UnJSCLrtQY8tVhhVRs61j4A2N_p-enAi-r704Qi1-v-DKV4eVRkClKViploo8NyjUaT9L4vbBssPCjyimJzsWnEe1fED5c4LnHeArYzA_FEn3JJotqDIz9t2VnvZNTMhizHEX4VnORlEWMEfR8n4CEHQx7PcQUOmfqyw08gWeXQl1-uTjtIGaE-sRIv9u_vQ\",\"alg\":\"RS256\",\"kid\":\"2af90e87be140c20038898a6efa11283dab6031d\",\"use\":\"sig\"},{\"n\":\"nzGsrziOYrMVYMpvUZOwkKNiPWcOPTYRYlDSdRW4UpAHdWPbPlyqaaphYhoMB5DXrVxI3bdvm7DOlo-sHNnulmAFQa-7TsQMxrZCvVdAbyXGID9DZYEqf8mkCV1Ohv7WY5lDUqlybIk1OSHdK7-1et0QS8nn-5LojGg8FK4ssLf3mV1APpujl27D1bDhyRb1MGumXYElwlUms7F9p9OcSp5pTevXCLmXs9MJJk4o9E1zzPpQ9Ko0lH9l_UqFpA7vwQhnw0nbh73rXOX2TUDCUqL4ThKU5Z9Pd-eZCEOatKe0mJTpQ00XGACBME_6ojCdfNIJr84Y_IpGKvkAEksn9w\",\"kty\":\"RSA\",\"alg\":\"RS256\",\"e\":\"AQAB\",\"kid\":\"87bbe0815b064e6d449cac999f0e50e72a3e4374\",\"use\":\"sig\"}]}"
9197
callback_path = "/callback"

rust-toolchain.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[toolchain]
2-
channel = "1.83.0"
3-
targets = [ "wasm32-wasi" ]
2+
channel = "stable"
3+
targets = [ "wasm32-wasip1" ]
4+
profile = "default"

0 commit comments

Comments
 (0)