From d5e6bec3e919c4b2955670b58b3d44eebebd063f Mon Sep 17 00:00:00 2001 From: danielalvsaaker Date: Wed, 14 Sep 2022 10:54:37 +0200 Subject: [PATCH] Move OAuth scopes into separate crate --- Cargo.lock | 320 ++++++++++----------- Cargo.toml | 1 + crates/tf-auth/Cargo.toml | 1 + crates/tf-auth/src/primitives/registrar.rs | 2 +- crates/tf-auth/src/primitives/scopes.rs | 77 +---- crates/tf-graphql/Cargo.toml | 2 +- crates/tf-graphql/src/guard.rs | 3 +- crates/tf-graphql/src/mutation/activity.rs | 2 +- crates/tf-graphql/src/mutation/gear.rs | 2 +- crates/tf-graphql/src/mutation/user.rs | 2 +- crates/tf-graphql/src/query/activity.rs | 2 +- crates/tf-graphql/src/query/gear.rs | 2 +- crates/tf-graphql/src/query/mod.rs | 2 +- crates/tf-graphql/src/query/user.rs | 2 +- crates/tf-scopes/Cargo.toml | 8 + crates/tf-scopes/src/lib.rs | 76 +++++ 16 files changed, 242 insertions(+), 262 deletions(-) create mode 100644 crates/tf-scopes/Cargo.toml create mode 100644 crates/tf-scopes/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 94acc8a..b428450 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,12 +27,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "ahash" version = "0.7.6" @@ -46,42 +40,42 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] [[package]] name = "alloc-no-stdlib" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "alloc-stdlib" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" dependencies = [ "alloc-no-stdlib", ] [[package]] name = "android_system_properties" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] [[package]] name = "anyhow" -version = "1.0.62" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" +checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" [[package]] name = "arc-bytes" @@ -180,15 +174,16 @@ dependencies = [ [[package]] name = "async-graphql" -version = "4.0.10" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0f570077882d069295e01719d65dc623551629738cf178f66bbdb244be4b0cd" +checksum = "b7b4acd72d35f568664599c2cde503228b29910ca36656b653984c31c5a28cd6" dependencies = [ "async-graphql-derive", "async-graphql-parser", "async-graphql-value", "async-stream", "async-trait", + "base64 0.13.0", "bytes", "chrono", "fnv", @@ -210,9 +205,9 @@ dependencies = [ [[package]] name = "async-graphql-axum" -version = "4.0.10" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca1c69eac0d6006b5f452efc6675435ad2c692c092c5ad31b7119bed2024b52" +checksum = "e570fac7f38f293b491b028bb330f8cc2be9810187953ac2b9a814a5b0ddb805" dependencies = [ "async-graphql", "async-trait", @@ -228,9 +223,9 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "4.0.10" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcea28b07ab74109662df27b008fb97251340dcadd0e2fe589ebca5bd2b6f443" +checksum = "9cead3c5f127c89b0abb2434c250409b9fe75763ee72583d4a90a412a927c8a8" dependencies = [ "Inflector", "async-graphql-parser", @@ -244,23 +239,21 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "4.0.10" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be05e1d1c34f479c424c4986c5e67fc33c2e92624012d63876439ed6cce0de12" +checksum = "9a2e30051a98bcecc8baab3f7a8b12e8e49b365afa81b598ad5dffa49d343f51" dependencies = [ "async-graphql-value", "pest", - "pest_generator", - "proc-macro2", "serde", "serde_json", ] [[package]] name = "async-graphql-value" -version = "4.0.10" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9c973faf966c7e834a028ac6e0d1022d71f71296e88dae18030fa25eb461818" +checksum = "47c8c0d67fe10c7c49c6dcc9072b7a5c6c07af3b72b6e67cfb30ee070e2e940c" dependencies = [ "bytes", "indexmap", @@ -270,9 +263,9 @@ dependencies = [ [[package]] name = "async-io" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab006897723d9352f63e2b13047177c3982d8d79709d713ce7747a8f19fd1b0" +checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" dependencies = [ "autocfg", "concurrent-queue", @@ -373,9 +366,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de18bc5f2e9df8f52da03856bf40e29b747de5a84e43aefff90e3dc4a21529b" +checksum = "c9e3356844c4d6a6d6467b8da2cffb4a2820be256f50a3a386c9d152bab31043" dependencies = [ "async-trait", "axum-core", @@ -408,9 +401,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4f44a0e6200e9d11a1cdc989e4b358f6e3d354fbf48478f345a17f4e43f8635" +checksum = "d9f0c0a60006f2a293d82d571f635042a72edf927539b7685bd62d361963839b" dependencies = [ "async-trait", "bytes", @@ -418,6 +411,8 @@ dependencies = [ "http", "http-body", "mime", + "tower-layer", + "tower-service", ] [[package]] @@ -485,9 +480,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "base64ct" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdca834647821e0b13d9539a8634eb62d3501b6b6c2cec1722786ee6671b851" +checksum = "ea2b2456fd614d856680dcd9fcc660a51a820fa09daef2e49772b56a193c8474" [[package]] name = "bincode" @@ -550,9 +545,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] @@ -731,9 +726,9 @@ dependencies = [ "hmac 0.12.1", "percent-encoding", "rand", - "sha2 0.10.2", + "sha2 0.10.5", "subtle", - "time 0.3.13", + "time 0.3.14", "version_check", ] @@ -745,9 +740,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc948ebb96241bb40ab73effeb80d9f93afaad49359d159a5e61be51619fe813" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] @@ -886,15 +881,6 @@ dependencies = [ "syn", ] -[[package]] -name = "deflate" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f" -dependencies = [ - "adler32", -] - [[package]] name = "digest" version = "0.9.0" @@ -910,7 +896,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "block-buffer 0.10.2", + "block-buffer 0.10.3", "crypto-common", "subtle", ] @@ -956,9 +942,9 @@ dependencies = [ [[package]] name = "fitparser" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30ab3c99257cbecab37c5bb6041bcf1c6dbe23381912d94a16d60c599314cec" +checksum = "3d36a90a02146cdb0c593dc6ae0a240f172f274fe4307dc26f351329f900dca3" dependencies = [ "calamine", "chrono", @@ -1010,11 +996,10 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" dependencies = [ - "matches", "percent-encoding", ] @@ -1026,9 +1011,9 @@ checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" [[package]] name = "futures" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab30e97ab6aacfe635fad58f22c2bb06c8b685f7421eb1e064a729e2a5f481fa" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" dependencies = [ "futures-channel", "futures-core", @@ -1041,9 +1026,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bfc52cbddcfd745bf1740338492bb0bd83d76c67b445f91c5fb29fae29ecaa1" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" dependencies = [ "futures-core", "futures-sink", @@ -1051,15 +1036,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" [[package]] name = "futures-executor" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d11aa21b5b587a64682c0094c2bdd4df0076c5324961a40cc3abd7f37930528" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" dependencies = [ "futures-core", "futures-task", @@ -1068,9 +1053,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a66fc6d035a26a3ae255a6d2bca35eda63ae4c5512bef54449113f7a1228e5" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" [[package]] name = "futures-lite" @@ -1089,9 +1074,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0db9cce532b0eae2ccf2766ab246f114b56b9cf6d445e00c2549fbc100ca045d" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" dependencies = [ "proc-macro2", "quote", @@ -1100,21 +1085,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0bae1fe9752cf7fd9b0064c674ae63f97b37bc714d745cbde0afb7ec4e6765" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" [[package]] name = "futures-task" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" [[package]] name = "futures-util" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ "futures-channel", "futures-core", @@ -1174,9 +1159,9 @@ dependencies = [ [[package]] name = "headers" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cff78e5788be1e0ab65b04d306b2ed5092c815ec97ec70f4ebd5aee158aa55d" +checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" dependencies = [ "base64 0.13.0", "bitflags", @@ -1185,7 +1170,7 @@ dependencies = [ "http", "httpdate", "mime", - "sha-1", + "sha1", ] [[package]] @@ -1255,9 +1240,9 @@ checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" [[package]] name = "httparse" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -1296,13 +1281,14 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.46" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501" +checksum = "237a0714f28b1ee39ccec0770ccb544eb02c9ef2c82bb096230eefcffa6468b0" dependencies = [ "android_system_properties", "core-foundation-sys", "js-sys", + "once_cell", "wasm-bindgen", "winapi", ] @@ -1315,11 +1301,10 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] @@ -1373,9 +1358,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.59" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] @@ -1394,9 +1379,9 @@ checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] name = "lock_api" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390" dependencies = [ "autocfg", "scopeguard", @@ -1422,9 +1407,9 @@ dependencies = [ [[package]] name = "lz4_flex" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c038063f7a78126c539d666a0323a2032de5e7366012cd14a6eafc5ba290bbd6" +checksum = "1a8cbbb2831780bc3b9c15a41f5b49222ef756b6730a95f3decfdd15903eb5a3" dependencies = [ "twox-hash", ] @@ -1438,12 +1423,6 @@ dependencies = [ "libc", ] -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - [[package]] name = "matchit" version = "0.5.0" @@ -1489,9 +1468,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", ] @@ -1510,9 +1489,9 @@ dependencies = [ [[package]] name = "moka" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89c33e91526792a0260425073c3db0b472cdca2cc6fcaa666dd6e65450462a" +checksum = "dd8256cf9fa396576521e5e94affadb95818ec48f5dbedca36714387688aea29" dependencies = [ "async-io", "async-lock", @@ -1678,9 +1657,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" [[package]] name = "opaque-debug" @@ -1704,7 +1683,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.2", + "sha2 0.10.5", "subtle", "url", ] @@ -1774,50 +1753,26 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0560d531d1febc25a3c9398a62a71256c0178f2e3443baedd9ad4bb8c9deb4" +checksum = "cb779fcf4bb850fbbb0edc96ff6cf34fd90c4b1a112ce042653280d9a7364048" dependencies = [ "thiserror", "ucd-trie", ] -[[package]] -name = "pest_generator" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5803d8284a629cc999094ecd630f55e91b561a1d1ba75e233b00ae13b91a69ad" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pest_meta" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1538eb784f07615c6d9a8ab061089c6c54a344c5b4301db51990ca1c241e8c04" -dependencies = [ - "once_cell", - "pest", - "sha-1", -] - [[package]] name = "pin-project" version = "1.0.12" @@ -1852,13 +1807,13 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "png" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba" +checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c" dependencies = [ "bitflags", "crc32fast", - "deflate", + "flate2", "miniz_oxide", ] @@ -1980,9 +1935,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "10.5.0" +version = "10.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aa2540135b6a94f74c7bc90ad4b794f822026a894f3d7bcd185c100d13d4ad6" +checksum = "a6823ea29436221176fe662da99998ad3b4db2c7f31e7b6f5fe43adccd6320bb" dependencies = [ "bitflags", ] @@ -2225,6 +2180,17 @@ dependencies = [ "digest 0.10.3", ] +[[package]] +name = "sha1" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006769ba83e921b3085caa8334186b00cf92b4cb1a6cf4632fbccc8eff5c7549" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.3", +] + [[package]] name = "sha2" version = "0.9.9" @@ -2240,9 +2206,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.2" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -2281,9 +2247,9 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -2389,6 +2355,7 @@ dependencies = [ "serde_urlencoded", "tf-database", "tf-models", + "tf-scopes", "thiserror", "tokio", ] @@ -2416,9 +2383,9 @@ dependencies = [ "oxide-auth", "rayon", "serde", - "tf-auth", "tf-database", "tf-models", + "tf-scopes", "tokio", ] @@ -2444,6 +2411,10 @@ dependencies = [ "uom", ] +[[package]] +name = "tf-scopes" +version = "0.1.0" + [[package]] name = "tf-viewer" version = "0.1.1" @@ -2474,18 +2445,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" dependencies = [ "proc-macro2", "quote", @@ -2504,9 +2475,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db76ff9fa4b1458b3c7f077f3ff9887394058460d21e634355b273aaf11eea45" +checksum = "3c3f9a28b618c3a6b9251b6908e9c99e04b9e5c02e6581ccbb67d59c34ef7f9b" dependencies = [ "itoa", "libc", @@ -2551,9 +2522,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.20.1" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" +checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" dependencies = [ "autocfg", "bytes", @@ -2593,9 +2564,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" dependencies = [ "bytes", "futures-core", @@ -2699,9 +2670,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe1b3800b35f9b936c28dc59dbda91b195371269396784d931fe2a5a2be3d2f" +checksum = "f1ee9bd9239c339d714d657fac840c6d2a4f9c45f4f9ec7b0975113458be78db" [[package]] name = "try-lock" @@ -2746,9 +2717,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "unicase" @@ -2767,9 +2738,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unicode-normalization" @@ -2800,13 +2771,12 @@ dependencies = [ [[package]] name = "url" -version = "2.2.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", "idna", - "matches", "percent-encoding", "serde", ] @@ -2873,9 +2843,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -2883,9 +2853,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", "log", @@ -2898,9 +2868,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2908,9 +2878,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", @@ -2921,15 +2891,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.82" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "web-sys" -version = "0.3.59" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 3c30d71..ac834b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "crates/tf-graphql", "crates/tf-models", "crates/tf-parse", + "crates/tf-scopes", ] [dependencies] diff --git a/crates/tf-auth/Cargo.toml b/crates/tf-auth/Cargo.toml index 9ac1ba8..ec81581 100644 --- a/crates/tf-auth/Cargo.toml +++ b/crates/tf-auth/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +tf-scopes = { path = "../tf-scopes" } askama = { version = "0.11", features = ["with-axum"] } askama_axum = "0.1" diff --git a/crates/tf-auth/src/primitives/registrar.rs b/crates/tf-auth/src/primitives/registrar.rs index 590d758..0017fee 100644 --- a/crates/tf-auth/src/primitives/registrar.rs +++ b/crates/tf-auth/src/primitives/registrar.rs @@ -76,7 +76,7 @@ impl Registrar for Database { .and_then(|scope| { scope .iter() - .filter(|scope| super::scopes::SCOPES.contains(scope)) + .filter(|scope| tf_scopes::SCOPES.contains(scope)) .collect::>() .join(" ") .parse() diff --git a/crates/tf-auth/src/primitives/scopes.rs b/crates/tf-auth/src/primitives/scopes.rs index 86a7b5f..a01ee7f 100644 --- a/crates/tf-auth/src/primitives/scopes.rs +++ b/crates/tf-auth/src/primitives/scopes.rs @@ -1,79 +1,4 @@ -pub const SCOPES: &[&str] = &[ - Activity::READ, - Activity::WRITE, - Gear::READ, - Gear::WRITE, - User::READ, - User::WRITE, -]; - -pub trait Resource { - const READ: &'static str; - const WRITE: &'static str; -} - -pub struct Activity; -pub struct Gear; -pub struct User; - -impl Resource for Activity { - const READ: &'static str = "activity:read"; - const WRITE: &'static str = "activity:write"; -} - -impl Resource for Gear { - const READ: &'static str = "gear:read"; - const WRITE: &'static str = "gear:write"; -} - -impl Resource for User { - const READ: &'static str = "user:read"; - const WRITE: &'static str = "user:write"; -} - -enum Scopes { - ActivityRead, - ActivityWrite, - GearRead, - GearWrite, - UserRead, - UserWrite, -} - -impl std::str::FromStr for Scopes { - type Err = (); - - fn from_str(s: &str) -> Result { - Ok(match s { - Activity::READ => Self::ActivityRead, - Activity::WRITE => Self::ActivityWrite, - Gear::READ => Self::GearRead, - Gear::WRITE => Self::GearWrite, - User::READ => Self::UserRead, - User::WRITE => Self::UserWrite, - _ => return Err(()), - }) - } -} - -pub struct Read(pub S); -pub struct Write(pub S); - -pub trait Scope { - const SCOPE: &'static str; -} - -impl Scope for () { - const SCOPE: &'static str = ""; -} - -impl Scope for Read { - const SCOPE: &'static str = S::READ; -} - -impl Scope for Write { - const SCOPE: &'static str = S::WRITE; -} +pub use tf_scopes::*; pub struct Grant { pub grant: oxide_auth::primitives::grant::Grant, diff --git a/crates/tf-graphql/Cargo.toml b/crates/tf-graphql/Cargo.toml index a005243..8ba4e45 100644 --- a/crates/tf-graphql/Cargo.toml +++ b/crates/tf-graphql/Cargo.toml @@ -8,7 +8,7 @@ include = ["src/**/*", "LICENSE", "README.md"] async-graphql = { version = "4.0", default-features = false } tf-models = { path = "../tf-models", features = ["graphql"] } tf-database = { path = "../tf-database" } -tf-auth = { path = "../tf-auth" } +tf-scopes = { path = "../tf-scopes" } oxide-auth = "0.5" serde = "1" diff --git a/crates/tf-graphql/src/guard.rs b/crates/tf-graphql/src/guard.rs index 0675dd8..013fff1 100644 --- a/crates/tf-graphql/src/guard.rs +++ b/crates/tf-graphql/src/guard.rs @@ -1,6 +1,5 @@ use async_graphql::{async_trait, Context, Error, ErrorExtensions, Guard, Result}; use oxide_auth::primitives::{grant::Grant, scope::Scope}; -use tf_auth::scopes; pub struct OAuthGuard { scope: Scope, @@ -9,7 +8,7 @@ pub struct OAuthGuard { impl OAuthGuard { pub fn new(_scope: S) -> Self where - S: scopes::Scope, + S: tf_scopes::Scope, { Self { scope: S::SCOPE.parse().unwrap(), diff --git a/crates/tf-graphql/src/mutation/activity.rs b/crates/tf-graphql/src/mutation/activity.rs index 0859914..9bbc0b6 100644 --- a/crates/tf-graphql/src/mutation/activity.rs +++ b/crates/tf-graphql/src/mutation/activity.rs @@ -1,5 +1,4 @@ use crate::{guard::OAuthGuard, query}; -use tf_auth::scopes::{self, Write}; use tf_database::{error::Error, Database}; use tf_models::{ activity::{Lap, Record, Session}, @@ -8,6 +7,7 @@ use tf_models::{ user::User, ActivityId, GearId, UserId, }; +use tf_scopes::{self as scopes, Write}; use async_graphql::{Context, Object, Result, SimpleObject}; diff --git a/crates/tf-graphql/src/mutation/gear.rs b/crates/tf-graphql/src/mutation/gear.rs index 67745bd..419dde9 100644 --- a/crates/tf-graphql/src/mutation/gear.rs +++ b/crates/tf-graphql/src/mutation/gear.rs @@ -1,5 +1,4 @@ use crate::{guard::OAuthGuard, query}; -use tf_auth::scopes::{self, Write}; use tf_database::Database; use tf_models::{ gear::Gear, @@ -7,6 +6,7 @@ use tf_models::{ user::User, GearId, UserId, }; +use tf_scopes::{self as scopes, Write}; use async_graphql::{Context, Object, Result, SimpleObject}; diff --git a/crates/tf-graphql/src/mutation/user.rs b/crates/tf-graphql/src/mutation/user.rs index 4c106c9..cc931b6 100644 --- a/crates/tf-graphql/src/mutation/user.rs +++ b/crates/tf-graphql/src/mutation/user.rs @@ -1,13 +1,13 @@ use crate::{guard::OAuthGuard, query}; use async_graphql::{Context, Object, Result, SimpleObject}; use oxide_auth::primitives::grant::Grant; -use tf_auth::scopes::{self, Write}; use tf_database::{error::Error, resource::index::DefaultGear, Database}; use tf_models::{ query::{GearQuery, UserQuery}, user::User, GearId, UserId, }; +use tf_scopes::{self as scopes, Write}; #[derive(Default)] pub struct UserRoot; diff --git a/crates/tf-graphql/src/query/activity.rs b/crates/tf-graphql/src/query/activity.rs index 036fdb3..0007bd1 100644 --- a/crates/tf-graphql/src/query/activity.rs +++ b/crates/tf-graphql/src/query/activity.rs @@ -1,7 +1,6 @@ use async_graphql::{Context, Object, Result}; use super::{GearRoot, OAuthGuard, UserRoot}; -use tf_auth::scopes::{self, Read}; use tf_database::{query::ActivityQuery, Database}; use tf_models::{ activity::{Lap, Record, Session}, @@ -9,6 +8,7 @@ use tf_models::{ user::User, ActivityId, }; +use tf_scopes::{self as scopes, Read}; mod record; use record::RecordRoot; diff --git a/crates/tf-graphql/src/query/gear.rs b/crates/tf-graphql/src/query/gear.rs index ab4e018..38b48c8 100644 --- a/crates/tf-graphql/src/query/gear.rs +++ b/crates/tf-graphql/src/query/gear.rs @@ -2,13 +2,13 @@ use async_graphql::{Context, Object, Result}; use super::{ActivityRoot, OAuthGuard, UserRoot}; use crate::connection::{Connection, PageInfo}; -use tf_auth::scopes::{self, Read}; use tf_database::{ query::{GearQuery, UserQuery}, resource::index::DefaultGear, Database, }; use tf_models::{activity::Session, gear::Gear, user::User, GearId}; +use tf_scopes::{self as scopes, Read}; pub struct GearRoot { pub query: GearQuery, diff --git a/crates/tf-graphql/src/query/mod.rs b/crates/tf-graphql/src/query/mod.rs index 3f9ef03..16a50a3 100644 --- a/crates/tf-graphql/src/query/mod.rs +++ b/crates/tf-graphql/src/query/mod.rs @@ -2,9 +2,9 @@ use super::{ connection::{Connection, PageInfo}, guard::OAuthGuard, }; -use tf_auth::scopes::{self, Read}; use tf_database::{error::Error, Database}; use tf_models::{query::UserQuery, user::User, UserId}; +use tf_scopes::{self as scopes, Read}; use async_graphql::{Context, Object, Result}; diff --git a/crates/tf-graphql/src/query/user.rs b/crates/tf-graphql/src/query/user.rs index 8ad1865..294149c 100644 --- a/crates/tf-graphql/src/query/user.rs +++ b/crates/tf-graphql/src/query/user.rs @@ -1,7 +1,6 @@ use super::{ActivityRoot, GearRoot, OAuthGuard}; use crate::connection::{Connection, PageInfo}; use async_graphql::{Context, Object, Result}; -use tf_auth::scopes::{self, Read}; use tf_database::{ error::Error, query::{ActivityQuery, GearQuery, UserQuery}, @@ -9,6 +8,7 @@ use tf_database::{ Database, }; use tf_models::{activity::Session, gear::Gear, user::User, ActivityId, GearId, UserId}; +use tf_scopes::{self as scopes, Read}; pub struct UserRoot { pub query: UserQuery, diff --git a/crates/tf-scopes/Cargo.toml b/crates/tf-scopes/Cargo.toml new file mode 100644 index 0000000..21cc97c --- /dev/null +++ b/crates/tf-scopes/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "tf-scopes" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/crates/tf-scopes/src/lib.rs b/crates/tf-scopes/src/lib.rs new file mode 100644 index 0000000..b13dbee --- /dev/null +++ b/crates/tf-scopes/src/lib.rs @@ -0,0 +1,76 @@ +pub const SCOPES: &[&str] = &[ + Activity::READ, + Activity::WRITE, + Gear::READ, + Gear::WRITE, + User::READ, + User::WRITE, +]; + +pub trait Resource { + const READ: &'static str; + const WRITE: &'static str; +} + +pub struct Activity; +pub struct Gear; +pub struct User; + +impl Resource for Activity { + const READ: &'static str = "activity:read"; + const WRITE: &'static str = "activity:write"; +} + +impl Resource for Gear { + const READ: &'static str = "gear:read"; + const WRITE: &'static str = "gear:write"; +} + +impl Resource for User { + const READ: &'static str = "user:read"; + const WRITE: &'static str = "user:write"; +} + +enum Scopes { + ActivityRead, + ActivityWrite, + GearRead, + GearWrite, + UserRead, + UserWrite, +} + +impl std::str::FromStr for Scopes { + type Err = (); + + fn from_str(s: &str) -> Result { + Ok(match s { + Activity::READ => Self::ActivityRead, + Activity::WRITE => Self::ActivityWrite, + Gear::READ => Self::GearRead, + Gear::WRITE => Self::GearWrite, + User::READ => Self::UserRead, + User::WRITE => Self::UserWrite, + _ => return Err(()), + }) + } +} + +pub struct Read(pub S); +pub struct Write(pub S); + +pub trait Scope { + const SCOPE: &'static str; +} + +impl Scope for () { + const SCOPE: &'static str = ""; +} + +impl Scope for Read { + const SCOPE: &'static str = S::READ; +} + +impl Scope for Write { + const SCOPE: &'static str = S::WRITE; +}