Parcourir la source

Added barebones server impl.

Kestrel il y a 1 an
Parent
commit
9aadc3b7cb
8 fichiers modifiés avec 448 ajouts et 97 suppressions
  1. 330 82
      Cargo.lock
  2. 5 3
      Cargo.toml
  3. 3 6
      src/cert.rs
  4. 64 5
      src/cli.rs
  5. 2 0
      src/main.rs
  6. 39 1
      src/schema.rs
  7. 5 0
      src/server.rs
  8. 0 0
      src/user.rs

+ 330 - 82
Cargo.lock

@@ -80,8 +80,8 @@ version = "1.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319"
 dependencies = [
- "concurrent-queue",
- "event-listener",
+ "concurrent-queue 1.2.2",
+ "event-listener 2.5.2",
  "futures-core",
 ]
 
@@ -97,18 +97,30 @@ dependencies = [
 
 [[package]]
 name = "async-executor"
-version = "1.4.1"
+version = "1.5.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965"
+checksum = "2c1da3ae8dabd9c00f453a329dfe1fb28da3c0a72e2478cdcd93171740c20499"
 dependencies = [
+ "async-lock",
  "async-task",
- "concurrent-queue",
- "fastrand",
+ "concurrent-queue 2.3.0",
+ "fastrand 2.0.1",
  "futures-lite",
- "once_cell",
  "slab",
 ]
 
+[[package]]
+name = "async-fs"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06"
+dependencies = [
+ "async-lock",
+ "autocfg",
+ "blocking",
+ "futures-lite",
+]
+
 [[package]]
 name = "async-global-executor"
 version = "2.0.4"
@@ -143,30 +155,31 @@ dependencies = [
 
 [[package]]
 name = "async-io"
-version = "1.6.0"
+version = "1.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b"
+checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"
 dependencies = [
- "concurrent-queue",
+ "async-lock",
+ "autocfg",
+ "cfg-if 1.0.0",
+ "concurrent-queue 2.3.0",
  "futures-lite",
- "libc",
  "log",
- "once_cell",
  "parking",
  "polling",
+ "rustix 0.37.25",
  "slab",
  "socket2",
  "waker-fn",
- "winapi",
 ]
 
 [[package]]
 name = "async-lock"
-version = "2.5.0"
+version = "2.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6"
+checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"
 dependencies = [
- "event-listener",
+ "event-listener 2.5.2",
 ]
 
 [[package]]
@@ -175,24 +188,35 @@ version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e"
 dependencies = [
- "event-listener",
+ "event-listener 2.5.2",
+]
+
+[[package]]
+name = "async-net"
+version = "1.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0434b1ed18ce1cf5769b8ac540e33f01fa9471058b5e89da9e06f3c882a8c12f"
+dependencies = [
+ "async-io",
+ "blocking",
+ "futures-lite",
 ]
 
 [[package]]
 name = "async-process"
-version = "1.4.0"
+version = "1.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf2c06e30a24e8c78a3987d07f0930edf76ef35e027e7bdb063fccafdad1f60c"
+checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88"
 dependencies = [
  "async-io",
+ "async-lock",
+ "async-signal",
  "blocking",
  "cfg-if 1.0.0",
- "event-listener",
+ "event-listener 3.0.0",
  "futures-lite",
- "libc",
- "once_cell",
- "signal-hook",
- "winapi",
+ "rustix 0.38.19",
+ "windows-sys",
 ]
 
 [[package]]
@@ -216,6 +240,24 @@ dependencies = [
  "sha2 0.9.9",
 ]
 
+[[package]]
+name = "async-signal"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2a5415b7abcdc9cd7d63d6badba5288b2ca017e3fbd4173b8f405449f1a2399"
+dependencies = [
+ "async-io",
+ "async-lock",
+ "atomic-waker",
+ "cfg-if 1.0.0",
+ "futures-core",
+ "futures-io",
+ "rustix 0.38.19",
+ "signal-hook-registry",
+ "slab",
+ "windows-sys",
+]
+
 [[package]]
 name = "async-sse"
 version = "4.1.0"
@@ -252,7 +294,7 @@ dependencies = [
  "memchr",
  "num_cpus",
  "once_cell",
- "pin-project-lite 0.2.9",
+ "pin-project-lite 0.2.13",
  "pin-utils",
  "slab",
  "wasm-bindgen-futures",
@@ -277,9 +319,9 @@ dependencies = [
 
 [[package]]
 name = "atomic-waker"
-version = "1.0.0"
+version = "1.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
 
 [[package]]
 name = "atty"
@@ -287,7 +329,7 @@ version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
  "winapi",
 ]
@@ -331,6 +373,12 @@ version = "1.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
+[[package]]
+name = "bitflags"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
+
 [[package]]
 name = "blake3"
 version = "0.3.8"
@@ -366,16 +414,18 @@ dependencies = [
 
 [[package]]
 name = "blocking"
-version = "1.2.0"
+version = "1.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc"
+checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a"
 dependencies = [
  "async-channel",
+ "async-lock",
  "async-task",
- "atomic-waker",
- "fastrand",
+ "fastrand 2.0.1",
+ "futures-io",
  "futures-lite",
- "once_cell",
+ "piper",
+ "tracing",
 ]
 
 [[package]]
@@ -438,7 +488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "85a35a599b11c089a7f49105658d089b8f2cf0882993c17daf6de15285c2c35d"
 dependencies = [
  "atty",
- "bitflags",
+ "bitflags 1.3.2",
  "clap_derive",
  "clap_lex",
  "indexmap",
@@ -479,6 +529,15 @@ dependencies = [
  "cache-padded",
 ]
 
+[[package]]
+name = "concurrent-queue"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400"
+dependencies = [
+ "crossbeam-utils",
+]
+
 [[package]]
 name = "const_fn"
 version = "0.4.9"
@@ -531,12 +590,11 @@ checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba"
 
 [[package]]
 name = "crossbeam-utils"
-version = "0.8.8"
+version = "0.8.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
 dependencies = [
  "cfg-if 1.0.0",
- "lazy_static",
 ]
 
 [[package]]
@@ -632,12 +690,33 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "errno"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
+dependencies = [
+ "libc",
+ "windows-sys",
+]
+
 [[package]]
 name = "event-listener"
 version = "2.5.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
 
+[[package]]
+name = "event-listener"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325"
+dependencies = [
+ "concurrent-queue 2.3.0",
+ "parking",
+ "pin-project-lite 0.2.13",
+]
+
 [[package]]
 name = "fastrand"
 version = "1.7.0"
@@ -647,6 +726,12 @@ dependencies = [
  "instant",
 ]
 
+[[package]]
+name = "fastrand"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
+
 [[package]]
 name = "femme"
 version = "2.2.0"
@@ -684,15 +769,15 @@ dependencies = [
 
 [[package]]
 name = "futures-core"
-version = "0.3.21"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
+checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
 
 [[package]]
 name = "futures-io"
-version = "0.3.21"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
+checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
 
 [[package]]
 name = "futures-lite"
@@ -700,12 +785,12 @@ version = "1.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
 dependencies = [
- "fastrand",
+ "fastrand 1.7.0",
  "futures-core",
  "futures-io",
  "memchr",
  "parking",
- "pin-project-lite 0.2.9",
+ "pin-project-lite 0.2.13",
  "waker-fn",
 ]
 
@@ -735,7 +820,7 @@ dependencies = [
  "futures-core",
  "futures-macro",
  "futures-task",
- "pin-project-lite 0.2.9",
+ "pin-project-lite 0.2.13",
  "pin-utils",
  "slab",
 ]
@@ -815,6 +900,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
+
 [[package]]
 name = "hkdf"
 version = "0.10.0"
@@ -871,7 +962,7 @@ dependencies = [
  "cookie",
  "futures-lite",
  "infer",
- "pin-project-lite 0.2.9",
+ "pin-project-lite 0.2.13",
  "rand 0.7.3",
  "serde",
  "serde_json",
@@ -922,6 +1013,17 @@ dependencies = [
  "cfg-if 1.0.0",
 ]
 
+[[package]]
+name = "io-lifetimes"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
+dependencies = [
+ "hermit-abi 0.3.3",
+ "libc",
+ "windows-sys",
+]
+
 [[package]]
 name = "itoa"
 version = "1.0.1"
@@ -954,9 +1056,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.125"
+version = "0.2.149"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
+checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
 
 [[package]]
 name = "log"
@@ -983,7 +1097,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
 [[package]]
 name = "microrm"
-version = "0.3.7"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77e1852d8fdff46f6cc49503db265184449e42e0722cd9ceb9776ffc8894308f"
 dependencies = [
  "base64 0.13.0",
  "lazy_static",
@@ -998,7 +1114,9 @@ dependencies = [
 
 [[package]]
 name = "microrm-macros"
-version = "0.2.4"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dba04dd721306ec7e301be005366b2e1b7f8562fc0396f914861d890923357fc"
 dependencies = [
  "convert_case",
  "proc-macro2",
@@ -1031,7 +1149,7 @@ version = "1.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
 ]
 
@@ -1093,9 +1211,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"
 
 [[package]]
 name = "pin-project-lite"
-version = "0.2.9"
+version = "0.2.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
+checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
 
 [[package]]
 name = "pin-utils"
@@ -1103,6 +1221,17 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
 
+[[package]]
+name = "piper"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4"
+dependencies = [
+ "atomic-waker",
+ "fastrand 2.0.1",
+ "futures-io",
+]
+
 [[package]]
 name = "pkg-config"
 version = "0.3.25"
@@ -1288,6 +1417,33 @@ dependencies = [
  "semver",
 ]
 
+[[package]]
+name = "rustix"
+version = "0.37.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035"
+dependencies = [
+ "bitflags 1.3.2",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys 0.3.8",
+ "windows-sys",
+]
+
+[[package]]
+name = "rustix"
+version = "0.38.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed"
+dependencies = [
+ "bitflags 2.4.0",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.4.10",
+ "windows-sys",
+]
+
 [[package]]
 name = "ryu"
 version = "1.0.9"
@@ -1420,16 +1576,6 @@ dependencies = [
  "digest 0.10.3",
 ]
 
-[[package]]
-name = "signal-hook"
-version = "0.3.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d"
-dependencies = [
- "libc",
- "signal-hook-registry",
-]
-
 [[package]]
 name = "signal-hook-registry"
 version = "1.4.0"
@@ -1445,14 +1591,34 @@ version = "1.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "38aabbeafa6f6dead8cebf246fe9fae1f9215c8d29b3a69f93bd62a9e4a3dcd6"
 dependencies = [
- "event-listener",
+ "event-listener 2.5.2",
 ]
 
 [[package]]
 name = "slab"
-version = "0.4.6"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
+checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "smol"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13f2b548cd8447f8de0fdf1c592929f70f4fc7039a05e47404b0d096ec6987a1"
+dependencies = [
+ "async-channel",
+ "async-executor",
+ "async-fs",
+ "async-io",
+ "async-lock",
+ "async-net",
+ "async-process",
+ "blocking",
+ "futures-lite",
+]
 
 [[package]]
 name = "socket2"
@@ -1642,7 +1808,7 @@ dependencies = [
  "http-types",
  "kv-log-macro",
  "log",
- "pin-project-lite 0.2.9",
+ "pin-project-lite 0.2.13",
  "route-recognizer",
  "serde",
  "serde_json",
@@ -1712,12 +1878,44 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
 
+[[package]]
+name = "tracing"
+version = "0.1.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9"
+dependencies = [
+ "pin-project-lite 0.2.13",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
+
 [[package]]
 name = "typenum"
 version = "1.15.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
 
+[[package]]
+name = "uauth2"
+version = "0.1.0"
+dependencies = [
+ "base64 0.13.0",
+ "clap",
+ "microrm",
+ "ring",
+ "serde",
+ "serde_bytes",
+ "serde_json",
+ "sha2 0.10.2",
+ "smol",
+ "tide",
+]
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.8"
@@ -1788,22 +1986,6 @@ version = "0.9.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
 
-[[package]]
-name = "vogt"
-version = "0.1.0"
-dependencies = [
- "async-std",
- "base64 0.13.0",
- "clap",
- "microrm",
- "ring",
- "serde",
- "serde_bytes",
- "serde_json",
- "sha2 0.10.2",
- "tide",
-]
-
 [[package]]
 name = "waker-fn"
 version = "1.1.0"
@@ -1939,3 +2121,69 @@ name = "winapi-x86_64-pc-windows-gnu"
 version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

+ 5 - 3
Cargo.toml

@@ -1,5 +1,5 @@
 [package]
-name = "vogt"
+name = "uauth2"
 version = "0.1.0"
 edition = "2021"
 
@@ -7,7 +7,9 @@ edition = "2021"
 
 [dependencies]
 # Core dependencies
-async-std = "1.11.0"
+# async-std = "1.11.0"
+smol = "1.3"
+
 ring = { version = "0.16.20", features = ["std"] }
 serde = { version =  "1.0", features = ["derive"] }
 serde_bytes = { version = "0.11.6" }
@@ -16,7 +18,7 @@ sha2 = { version = "0.10.2" }
 base64 = { version = "0.13.0" }
 
 # Data storage dependencies
-microrm = { version = "0.3", path = "../microrm/microrm" }
+microrm = { version = "0.3.9" }
 
 # Public API dependencies
 tide = { version = "0.16.0" }

+ 3 - 6
src/cert.rs

@@ -1,16 +1,13 @@
-use std::collections::HashMap;
 use ring::signature::Ed25519KeyPair;
 use sha2::Digest;
 use crate::schema;
 use microrm::prelude::*;
 
-pub struct CertStore {
-    keys: HashMap<String, Ed25519KeyPair>,
-}
+pub struct CertStore { }
 
 impl CertStore {
     pub fn new() -> Self {
-        Self { keys: HashMap::new() }
+        Self { }
     }
 
     fn realm_id(&self, qi: &microrm::QueryInterface, realm_name: &str) -> Option<schema::RealmID> {
@@ -52,7 +49,7 @@ pub fn inspect(db: &microrm::DB, realm_name: &str) {
     let realm = realm.unwrap();
 
     println!("Retrieving keys for {} realm...", realm_name);
-    let keys = qi.get().by(schema::Key::Realm, &realm.id()).all().expect("couldn't load keys"); // microrm::query::get_all_by(db, schema::KeyColumns::Realm, realm.id()).expect("Can get keys");
+    let keys = qi.get().by(schema::Key::Realm, &realm.id()).all().expect("couldn't load keys");
     for key in keys {
         println!("- [{:20}]", key.key_id);
     }

+ 64 - 5
src/cli.rs

@@ -18,12 +18,14 @@ struct RootArgs {
 enum Command {
     Init,
     Cert(CertArgs),
-    Server(ServerArgs)
+    Group(GroupArgs),
+    Server(ServerArgs),
+    Token(TokenArgs),
+    User(UserArgs),
 }
 
 impl RootArgs {
     async fn run(&self) {
-
         if let Command::Init = self.command {
             return self.init().await;
         }
@@ -39,7 +41,10 @@ impl RootArgs {
         match &self.command {
             Command::Init => unreachable!(),
             Command::Cert(v) => v.run(&self, &storage).await,
+            Command::Group(v) => v.run(&self, &storage).await,
             Command::Server(v) => v.run(&self, &storage).await,
+            Command::Token(v) => v.run(&self, &storage).await,
+            Command::User(v) => v.run(&self, &storage).await,
         }
     }
 
@@ -87,13 +92,66 @@ impl CertArgs {
     }
 }
 
+#[derive(Debug,Subcommand)]
+enum GroupCommand {
+}
+
+#[derive(Debug, Parser)]
+struct GroupArgs {
+    #[clap(subcommand)]
+    command: GroupCommand
+}
+
+impl GroupArgs {
+    async fn run(&self, root: &RootArgs, si: &microrm::DB) {
+    }
+}
+
+
 #[derive(Debug, Parser)]
 struct ServerArgs {
-    
+    port: Option<u16>,
 }
 
 impl ServerArgs {
-    async fn run(&self, root: &RootArgs, _si: &microrm::DB) {
+    async fn run(&self, root: &RootArgs, db: &microrm::DB) {
+        crate::server::launch(db, self.port.unwrap_or(2000)).await
+    }
+}
+
+#[derive(Debug, Subcommand)]
+enum TokenCommand {
+    GenerateAuth { username: String, scopes: String },
+    GenerateRefresh { username: String, scopes: String },
+    Inspect { token: String },
+}
+
+#[derive(Debug, Parser)]
+struct TokenArgs {
+    #[clap(subcommand)]
+    command: TokenCommand,
+}
+
+impl TokenArgs {
+    async fn run(&self, root: &RootArgs, _db: &microrm::DB) {
+        
+    }
+}
+
+#[derive(Debug, Subcommand)]
+enum UserCommand {
+    Create { username: String },
+    List { filter: Option<String> },
+}
+
+#[derive(Debug, Parser)]
+struct UserArgs {
+    #[clap(subcommand)]
+    command: UserCommand,
+}
+
+impl UserArgs {
+    async fn run(&self, root: &RootArgs, _db: &microrm::DB) {
         
     }
 }
@@ -101,5 +159,6 @@ impl ServerArgs {
 pub fn invoked() {
     let args = RootArgs::parse();
 
-    async_std::task::block_on(args.run());
+    smol::block_on(args.run());
+    // async_std::task::block_on(args.run());
 }

+ 2 - 0
src/main.rs

@@ -3,6 +3,8 @@ pub use microrm::DB;
 mod schema;
 mod cli;
 mod cert;
+mod user;
+mod server;
 
 fn main() {
     cli::invoked();

+ 39 - 1
src/schema.rs

@@ -1,11 +1,13 @@
 use serde::{Serialize,Deserialize};
 pub use microrm::{Entity, Schema};
 
+/// Top-level partitioning object
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Realm {
     pub shortname: String
 }
 
+/// Cryptographic signing key
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Key {
     pub realm: RealmID,
@@ -14,12 +16,14 @@ pub struct Key {
     pub keydata: Vec<u8>
 }
 
+/// End-user representation object
 #[derive(Entity,Serialize,Deserialize)]
 pub struct User {
     pub realm: RealmID,
     pub username: String,
 }
 
+/// End-user authentication
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Password {
     pub user: UserID,
@@ -27,12 +31,21 @@ pub struct Password {
     pub hash: String
 }
 
+/// User semantic grouping
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Group {
     pub realm: RealmID,
     pub shortname: String,
 }
 
+/// User membership in group
+#[derive(Entity,Serialize,Deserialize)]
+pub struct GroupMembership {
+    pub group: GroupID,
+    pub user: UserID,
+}
+
+/// OAuth2 client representation
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Client {
     pub realm: RealmID,
@@ -40,19 +53,41 @@ pub struct Client {
     pub secret: String,
 }
 
+/// Requested group of permissions
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Scope {
     pub realm: RealmID,
     pub shortname: String,
 }
 
+/// Specific atomic permission
 #[derive(Entity,Serialize,Deserialize)]
 pub struct Role {
     pub realm: RealmID,
-    pub group: GroupID,
     pub shortname: String,
 }
 
+/// Role membership in scope
+#[derive(Entity,Serialize,Deserialize)]
+pub struct ScopeRoles {
+    pub scope: ScopeID,
+    pub role: RoleID,
+}
+
+/// Assigned permissions in group
+#[derive(Entity,Serialize,Deserialize)]
+pub struct GroupRoles {
+    pub scope: ScopeID,
+    pub role: RoleID,
+}
+
+
+#[derive(Entity,Serialize,Deserialize)]
+pub struct RevokedTokens {
+    pub user: UserID,
+    pub nonce: String,
+}
+
 pub fn schema() -> Schema {
     Schema::new()
         .add::<Realm>()
@@ -60,7 +95,10 @@ pub fn schema() -> Schema {
         .add::<User>()
         .add::<Password>()
         .add::<Group>()
+        .add::<GroupMembership>()
         .add::<Client>()
         .add::<Scope>()
         .add::<Role>()
+        .add::<ScopeRoles>()
+        .add::<GroupRoles>()
 }

+ 5 - 0
src/server.rs

@@ -0,0 +1,5 @@
+pub async fn launch(db: &microrm::DB, port: u16) {
+    let mut srv = tide::new();
+
+    srv.listen(("127.0.0.1", port)).await.expect("couldn't bind to port");
+}

+ 0 - 0
src/user.rs