Update openidconnect-rs (#54)

And add integration test
This commit is contained in:
Simon Bihel 2023-04-17 13:16:39 +01:00 committed by GitHub
parent d59c4db602
commit d4ce5c1616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 606 additions and 76 deletions

View File

@ -4,6 +4,7 @@ on: push
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"
jobs:
build:
@ -15,18 +16,26 @@ jobs:
- cargo_target: "wasm32-unknown-unknown"
steps:
- name: Clone repo
uses: actions/checkout@master
uses: actions/checkout@v3
- name: Add targets
run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Docker Compose
run: docker-compose -f test/docker-compose.yml up -d redis
- name: Build
env:
CARGO_BUILD_TARGET: ${{ matrix.cargo_target }}
run: cargo build --verbose
run: cargo build
- name: Clippy
env:
CARGO_BUILD_TARGET: ${{ matrix.cargo_target }}
run: RUSTFLAGS="-Dwarnings" cargo clippy
run: cargo clippy
- name: Fmt
env:
CARGO_BUILD_TARGET: ${{ matrix.cargo_target }}
run: cargo fmt -- --check
- name: Test
if: matrix.cargo_target == 'x86_64-unknown-linux-gnu'
run: cargo test

493
Cargo.lock generated
View File

@ -2,6 +2,17 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aes"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241"
dependencies = [
"cfg-if 1.0.0",
"cipher",
"cpufeatures",
]
[[package]]
name = "aho-corasick"
version = "0.7.20"
@ -132,6 +143,28 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce"
[[package]]
name = "base58"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83"
[[package]]
name = "base58check"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee2fe4c9a0c84515f136aaae2466744a721af6d63339c18689d9e995d74d99b"
dependencies = [
"base58",
"sha2 0.8.2",
]
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.13.1"
@ -168,6 +201,12 @@ dependencies = [
"redis",
]
[[package]]
name = "bech32"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1"
[[package]]
name = "bincode"
version = "1.3.3"
@ -183,6 +222,16 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitvec"
version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c"
dependencies = [
"either",
"radium 0.3.0",
]
[[package]]
name = "bitvec"
version = "1.0.1"
@ -190,20 +239,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty",
"radium",
"radium 0.7.0",
"tap",
"wyz",
]
[[package]]
name = "blake2"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
dependencies = [
"digest 0.10.6",
]
[[package]]
name = "block-buffer"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array 0.12.4",
]
[[package]]
name = "block-buffer"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
dependencies = [
"generic-array",
"generic-array 0.14.6",
]
[[package]]
name = "block-padding"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
dependencies = [
"byte-tools",
]
[[package]]
name = "bs58"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
[[package]]
name = "bumpalo"
version = "3.11.1"
@ -216,6 +301,12 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c"
[[package]]
name = "byte-tools"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "byteorder"
version = "1.4.3"
@ -287,6 +378,16 @@ dependencies = [
"phf_codegen",
]
[[package]]
name = "cipher"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common",
"inout",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@ -297,6 +398,63 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "coins-bip32"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "634c509653de24b439672164bbf56f5f582a2ab0e313d3b0f6af0b7345cf2560"
dependencies = [
"bincode",
"bs58",
"coins-core",
"digest 0.10.6",
"getrandom",
"hmac",
"k256",
"lazy_static",
"serde",
"sha2 0.10.6",
"thiserror",
]
[[package]]
name = "coins-bip39"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a11892bcac83b4c6e95ab84b5b06c76d9d70ad73548dd07418269c5c7977171"
dependencies = [
"bitvec 0.17.4",
"coins-bip32",
"getrandom",
"hex",
"hmac",
"pbkdf2",
"rand",
"sha2 0.10.6",
"thiserror",
]
[[package]]
name = "coins-core"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c94090a6663f224feae66ab01e41a2555a8296ee07b5f20dab8888bdefc9f617"
dependencies = [
"base58check",
"base64 0.12.3",
"bech32",
"blake2",
"digest 0.10.6",
"generic-array 0.14.6",
"hex",
"ripemd",
"serde",
"serde_derive",
"sha2 0.10.6",
"sha3",
"thiserror",
]
[[package]]
name = "combine"
version = "4.6.6"
@ -327,6 +485,15 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b"
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cookie"
version = "0.16.2"
@ -364,7 +531,7 @@ version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef"
dependencies = [
"generic-array",
"generic-array 0.14.6",
"rand_core",
"subtle",
"zeroize",
@ -376,10 +543,19 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"generic-array 0.14.6",
"typenum",
]
[[package]]
name = "ctr"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
dependencies = [
"cipher",
]
[[package]]
name = "cxx"
version = "1.0.85"
@ -424,6 +600,41 @@ dependencies = [
"syn",
]
[[package]]
name = "darling"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "der"
version = "0.6.1"
@ -446,13 +657,22 @@ dependencies = [
"syn",
]
[[package]]
name = "digest"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array 0.12.4",
]
[[package]]
name = "digest"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
dependencies = [
"block-buffer",
"block-buffer 0.10.3",
"const-oid",
"crypto-common",
"subtle",
@ -491,9 +711,9 @@ dependencies = [
"base16ct",
"crypto-bigint",
"der",
"digest",
"digest 0.10.6",
"ff",
"generic-array",
"generic-array 0.14.6",
"group",
"hkdf",
"pem-rfc7468",
@ -547,6 +767,28 @@ dependencies = [
"libc",
]
[[package]]
name = "eth-keystore"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab"
dependencies = [
"aes",
"ctr",
"digest 0.10.6",
"hex",
"hmac",
"pbkdf2",
"rand",
"scrypt",
"serde",
"serde_json",
"sha2 0.10.6",
"sha3",
"thiserror",
"uuid",
]
[[package]]
name = "ethabi"
version = "18.0.0"
@ -604,18 +846,21 @@ dependencies = [
"arrayvec",
"bytes",
"chrono",
"convert_case",
"elliptic-curve",
"ethabi",
"generic-array",
"generic-array 0.14.6",
"hex",
"k256",
"open-fastrlp",
"proc-macro2",
"rand",
"rlp",
"rlp-derive",
"serde",
"serde_json",
"strum",
"syn",
"thiserror",
"tiny-keccak",
"unicode-xid",
@ -629,7 +874,7 @@ checksum = "a1a9e0597aa6b2fdc810ff58bc95e4eeaa2c219b3e615ed025106ecb027407d8"
dependencies = [
"async-trait",
"auto_impl",
"base64",
"base64 0.13.1",
"ethers-core",
"futures-channel",
"futures-core",
@ -658,6 +903,30 @@ dependencies = [
"ws_stream_wasm",
]
[[package]]
name = "ethers-signers"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f41ced186867f64773db2e55ffdd92959e094072a1d09a5e5e831d443204f98"
dependencies = [
"async-trait",
"coins-bip32",
"coins-bip39",
"elliptic-curve",
"eth-keystore",
"ethers-core",
"hex",
"rand",
"sha2 0.10.6",
"thiserror",
]
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "ff"
version = "0.12.1"
@ -819,6 +1088,15 @@ dependencies = [
"byteorder",
]
[[package]]
name = "generic-array"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
dependencies = [
"typenum",
]
[[package]]
name = "generic-array"
version = "0.14.6"
@ -893,7 +1171,7 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584"
dependencies = [
"base64",
"base64 0.13.1",
"bitflags",
"bytes",
"headers-core",
@ -957,7 +1235,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
dependencies = [
"digest",
"digest 0.10.6",
]
[[package]]
@ -1067,6 +1345,12 @@ dependencies = [
"cxx-build",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.3.0"
@ -1131,6 +1415,15 @@ version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb"
[[package]]
name = "inout"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
dependencies = [
"generic-array 0.14.6",
]
[[package]]
name = "instant"
version = "0.1.12"
@ -1214,7 +1507,7 @@ dependencies = [
"cfg-if 1.0.0",
"ecdsa",
"elliptic-curve",
"sha2",
"sha2 0.10.6",
"sha3",
]
@ -1347,17 +1640,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "num-bigint"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-bigint-dig"
version = "0.8.2"
@ -1422,7 +1704,7 @@ version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eeaf26a72311c087f8c5ba617c96fac67a5c04f430e716ac8d8ab2de62e23368"
dependencies = [
"base64",
"base64 0.13.1",
"chrono",
"getrandom",
"http",
@ -1431,7 +1713,7 @@ dependencies = [
"serde",
"serde_json",
"serde_path_to_error",
"sha2",
"sha2 0.10.6",
"thiserror",
"url",
]
@ -1442,6 +1724,12 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]]
name = "opaque-debug"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "open-fastrlp"
version = "0.1.4"
@ -1469,17 +1757,17 @@ dependencies = [
[[package]]
name = "openidconnect"
version = "2.4.1"
source = "git+https://github.com/sbihel/openidconnect-rs?branch=replace-ring#a1c38841e3dfb571d4fe5daece8005d2c3b73a8e"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91f944611b8e7e8e4bb7e3c95a98f2b8d1aba56cfa6af00f31d9b0f7829d8431"
dependencies = [
"base64",
"base64 0.13.1",
"chrono",
"dyn-clone",
"hmac",
"http",
"itertools",
"log",
"num-bigint",
"oauth2",
"p256",
"p384",
@ -1490,7 +1778,9 @@ dependencies = [
"serde_derive",
"serde_json",
"serde_path_to_error",
"sha2",
"serde_plain",
"serde_with",
"sha2 0.10.6",
"subtle",
"thiserror",
"url",
@ -1519,7 +1809,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594"
dependencies = [
"ecdsa",
"elliptic-curve",
"sha2",
"sha2 0.10.6",
]
[[package]]
@ -1530,7 +1820,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa"
dependencies = [
"ecdsa",
"elliptic-curve",
"sha2",
"sha2 0.10.6",
]
[[package]]
@ -1540,7 +1830,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a"
dependencies = [
"arrayvec",
"bitvec",
"bitvec 1.0.1",
"byte-slice-cast",
"impl-trait-for-tuples",
"parity-scale-codec-derive",
@ -1616,6 +1906,29 @@ dependencies = [
"regex",
]
[[package]]
name = "password-hash"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
dependencies = [
"base64ct",
"rand_core",
"subtle",
]
[[package]]
name = "pbkdf2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
dependencies = [
"digest 0.10.6",
"hmac",
"password-hash",
"sha2 0.10.6",
]
[[package]]
name = "pear"
version = "0.2.3"
@ -1843,6 +2156,12 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac"
[[package]]
name = "radium"
version = "0.7.0"
@ -1939,7 +2258,7 @@ version = "0.11.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c"
dependencies = [
"base64",
"base64 0.13.1",
"bytes",
"encoding_rs",
"futures-core",
@ -1998,6 +2317,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "ripemd"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f"
dependencies = [
"digest 0.10.6",
]
[[package]]
name = "rlp"
version = "0.5.2"
@ -2026,7 +2354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "094052d5470cbcef561cb848a7209968c9f12dfa6d668f4bca048ac5de51099c"
dependencies = [
"byteorder",
"digest",
"digest 0.10.6",
"num-bigint-dig",
"num-integer",
"num-iter",
@ -2087,7 +2415,7 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55"
dependencies = [
"base64",
"base64 0.13.1",
]
[[package]]
@ -2102,6 +2430,15 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
[[package]]
name = "salsa20"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
dependencies = [
"cipher",
]
[[package]]
name = "scale-info"
version = "2.3.1"
@ -2138,6 +2475,18 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2"
[[package]]
name = "scrypt"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d"
dependencies = [
"hmac",
"pbkdf2",
"salsa20",
"sha2 0.10.6",
]
[[package]]
name = "sct"
version = "0.7.0"
@ -2156,7 +2505,7 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928"
dependencies = [
"base16ct",
"der",
"generic-array",
"generic-array 0.14.6",
"pkcs8",
"subtle",
"zeroize",
@ -2224,6 +2573,15 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_plain"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6018081315db179d0ce57b1fe4b62a12a0028c9cf9bbef868c9cf477b3c34ae"
dependencies = [
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@ -2236,6 +2594,28 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_with"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff"
dependencies = [
"serde",
"serde_with_macros",
]
[[package]]
name = "serde_with_macros"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "sha-1"
version = "0.10.1"
@ -2244,7 +2624,7 @@ checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c"
dependencies = [
"cfg-if 1.0.0",
"cpufeatures",
"digest",
"digest 0.10.6",
]
[[package]]
@ -2255,7 +2635,19 @@ checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
dependencies = [
"cfg-if 1.0.0",
"cpufeatures",
"digest",
"digest 0.10.6",
]
[[package]]
name = "sha2"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
dependencies = [
"block-buffer 0.7.3",
"digest 0.8.1",
"fake-simd",
"opaque-debug",
]
[[package]]
@ -2266,7 +2658,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
dependencies = [
"cfg-if 1.0.0",
"cpufeatures",
"digest",
"digest 0.10.6",
]
[[package]]
@ -2275,7 +2667,7 @@ version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9"
dependencies = [
"digest",
"digest 0.10.6",
"keccak",
]
@ -2303,7 +2695,7 @@ version = "1.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c"
dependencies = [
"digest",
"digest 0.10.6",
"rand_core",
]
@ -2344,6 +2736,7 @@ dependencies = [
"env_logger",
"ethers-core",
"ethers-providers",
"ethers-signers",
"figment",
"getrandom",
"headers",
@ -2357,7 +2750,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
"sha2",
"sha2 0.10.6",
"siwe",
"test-log",
"thiserror",
@ -2420,6 +2813,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strum"
version = "0.24.1"
@ -2804,7 +3203,7 @@ version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0"
dependencies = [
"base64",
"base64 0.13.1",
"byteorder",
"bytes",
"http",
@ -2876,6 +3275,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
version = "0.1.10"

View File

@ -15,12 +15,12 @@ anyhow = "1.0.53"
headers = "0.3.6"
hex = "0.4.3"
iri-string = { version = "0.6", features = ["serde"] }
# openidconnect = "2.1.2"
openidconnect = { git = "https://github.com/sbihel/openidconnect-rs", branch = "replace-ring", default-features = false, features = ["reqwest", "rustls-tls"] }
openidconnect = "3.0.0"
rand = "0.8.4"
rsa = { version = "0.7.0" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.78"
serde_urlencoded = "0.7.0"
siwe = "0.5.0"
thiserror = "1.0.30"
tracing = "0.1.30"
@ -36,7 +36,6 @@ lazy_static = "1.4"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
axum = { version = "0.4.3", features = ["headers"] }
# axum-debug = "0.3.2"
chrono = "0.4.19"
figment = { version = "0.10.6", features = ["toml", "env"] }
tokio = { version = "1.14.0", features = ["full"] }
@ -46,14 +45,10 @@ bb8-redis = "0.10.1"
uuid = { version = "0.8", features = ["serde", "v4"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
# cached = { version = "0.26", default-features = false }
chrono = { version = "0.4.19", features = ["wasmbind"] }
console_error_panic_hook = { version = "0.1" }
# console_log = "0.2"
getrandom = { version = "0.2", features = ["js"] }
# log = "0.4"
matchit = "0.4.2"
serde_urlencoded = "0.7.0"
uuid = { version = "0.8", features = ["serde", "v4", "wasm-bindgen"] }
wee_alloc = { version = "0.4" }
worker = "0.0.12"
@ -67,13 +62,7 @@ lto = true
env_logger = "0.10.0"
test-log = "0.2.11"
tokio = { version = "1.14.0", features = ["macros", "rt"] }
# [target.'cfg(target_arch = "wasm32")'.profile.release]
# opt-level = "z"
# [target.'cfg(target_arch = "wasm32")'.profile.debug]
# opt-level = "z"
# lto = false
ethers-signers = "1.0.2"
[package.metadata.wasm-pack.profile.profiling]
wasm-opt = ['-g', '-O']

View File

@ -9,7 +9,6 @@ use axum::{
routing::{delete, get, get_service, post},
Json, Router,
};
use bb8_redis::{bb8, RedisConnectionManager};
use figment::{
providers::{Env, Format, Serialized, Toml},
Figment,
@ -247,10 +246,9 @@ pub async fn main() {
tracing_subscriber::fmt::init();
let manager = RedisConnectionManager::new(config.redis_url.clone()).unwrap();
let pool = bb8::Pool::builder().build(manager.clone()).await.unwrap();
let redis_client = RedisClient { pool };
let redis_client = RedisClient::new(&config.redis_url)
.await
.expect("Could not build Redis client");
for (id, entry) in &config.default_clients.clone() {
let entry: ClientEntry =

View File

@ -1,12 +1,29 @@
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use bb8_redis::{bb8::Pool, redis::AsyncCommands, RedisConnectionManager};
use bb8_redis::{
bb8::{self, Pool},
redis::AsyncCommands,
RedisConnectionManager,
};
use url::Url;
use super::*;
#[derive(Clone)]
pub struct RedisClient {
pub pool: Pool<RedisConnectionManager>,
pool: Pool<RedisConnectionManager>,
}
impl RedisClient {
pub async fn new(url: &Url) -> Result<Self> {
let manager = RedisConnectionManager::new(url.clone())
.context("Could not build Redis connection manager")?;
let pool = bb8::Pool::builder()
.build(manager.clone())
.await
.context("Coud not build Redis pool")?;
Ok(Self { pool })
}
}
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]

View File

@ -630,8 +630,12 @@ pub async fn sign_in(
.map_err(|e| anyhow!("Failed message verification: {}", e))?;
let domain = params.redirect_uri.url();
if *domain != Url::from_str(siwe_cookie.message.resources.get(0).unwrap().as_ref()).unwrap() {
return Err(anyhow!("Conflicting domains in message and redirect").into());
if let Some(r) = siwe_cookie.message.resources.get(0) {
if *domain != Url::from_str(r.as_ref()).unwrap() {
return Err(anyhow!("Conflicting domains in message and redirect").into());
}
} else {
return Err(anyhow!("Missing resource in SIWE message").into());
}
let code_entry = CodeEntry {
@ -828,9 +832,34 @@ pub async fn userinfo(
#[cfg(test)]
mod tests {
use crate::config::Config;
use super::*;
use ethers_signers::{LocalWallet, Signer};
use headers::{HeaderMap, HeaderMapExt, HeaderValue};
use rand::rngs::OsRng;
use test_log::test;
async fn default_config() -> (Config, RedisClient) {
let config = Config::default();
let db_client = RedisClient::new(&config.redis_url).await.unwrap();
db_client
.set_client(
"client".into(),
ClientEntry {
secret: "secret".into(),
metadata: CoreClientMetadata::new(
vec![RedirectUrl::new("https://example.com".into()).unwrap()],
EmptyAdditionalClientMetadata {},
),
access_token: None,
},
)
.await
.unwrap();
(config, db_client)
}
#[test(tokio::test)]
async fn test_claims() {
let res = resolve_claims(
@ -850,4 +879,82 @@ mod tests {
Some("https://ipfs.io/ipfs/QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif")
);
}
#[derive(Deserialize)]
struct AuthorizeQueryParams {
nonce: String,
}
#[derive(Deserialize)]
struct SignInQueryParams {
code: String,
}
#[tokio::test]
async fn e2e_flow() {
let (_config, db_client) = default_config().await;
let wallet = "dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7"
.parse::<LocalWallet>()
.unwrap();
let base_url = Url::parse("https://example.com").unwrap();
let params = AuthorizeParams {
client_id: "client".into(),
redirect_uri: RedirectUrl::from_url(base_url.clone()),
scope: Scope::new("openid".to_string()),
response_type: Some(CoreResponseType::IdToken),
state: Some("state".into()),
nonce: None,
prompt: None,
request_uri: None,
request: None,
};
let (redirect_url, cookie) = authorize(params, &db_client).await.unwrap();
let authorize_params: AuthorizeQueryParams =
serde_urlencoded::from_str(redirect_url.split("/?").collect::<Vec<&str>>()[1]).unwrap();
let params: SignInParams = serde_urlencoded::from_str(&redirect_url).unwrap();
let message = Web3ModalMessage {
domain: "example.com".into(),
address: wallet.address(),
statement: "statement".to_string(),
uri: base_url.to_string(),
version: "1".into(),
chain_id: 1,
nonce: authorize_params.nonce,
issued_at: "2023-04-17T11:01:24.862Z".into(),
expiration_time: None,
not_before: None,
request_id: None,
resources: vec!["https://example.com".try_into().unwrap()],
};
let signature = wallet
.sign_message(message.to_eip4361_message().unwrap().to_string())
.await
.unwrap();
let signature = format!("0x{signature}");
let siwe_cookie = serde_json::to_string(&SiweCookie { message, signature }).unwrap();
let mut headers = HeaderMap::new();
headers.insert(
"cookie",
HeaderValue::from_str(&format!("{cookie}; {SIWE_COOKIE_KEY}={siwe_cookie}")).unwrap(),
);
let cookie = headers.typed_get::<headers::Cookie>().unwrap();
let redirect_url = sign_in(&base_url, params, cookie, &db_client)
.await
.unwrap();
let signin_params: SignInQueryParams =
serde_urlencoded::from_str(redirect_url.query().unwrap()).unwrap();
let _ = userinfo(
base_url,
None,
RsaPrivateKey::new(&mut OsRng, 1024).unwrap(),
None,
UserInfoPayload {
access_token: Some(signin_params.code),
},
&db_client,
)
.await
.unwrap();
}
}

View File

@ -31,15 +31,15 @@ macro_rules! json_bad_request {
impl From<CustomError> for Result<Response> {
fn from(error: CustomError) -> Self {
match error {
CustomError::BadRequest(_) => Response::error(&error.to_string(), 400),
CustomError::BadRequest(_) => Response::error(error.to_string(), 400),
CustomError::BadRequestRegister(e) => {
Response::from_json(&e).map(|r| r.with_status(400))
}
CustomError::BadRequestToken(e) => Response::from_json(&e).map(|r| r.with_status(400)),
CustomError::Unauthorized(_) => Response::error(&error.to_string(), 401),
CustomError::NotFound => Response::error(&error.to_string(), 404),
CustomError::Unauthorized(_) => Response::error(error.to_string(), 401),
CustomError::NotFound => Response::error(error.to_string(), 404),
CustomError::Redirect(uri) => Response::redirect(uri.parse().unwrap()),
CustomError::Other(_) => Response::error(&error.to_string(), 500),
CustomError::Other(_) => Response::error(error.to_string(), 500),
}
}
}

View File

@ -24,6 +24,11 @@ services:
KEYCLOAK_ADMIN_PASSWORD: admin
redis:
image: redis:6-alpine
image: redis
healthcheck:
test: ["CMD", "redis-cli","ping"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "6379:6379"