don't
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

rename crate oauth to auth

Signed-off-by: tjh <did:plc:65gha4t3avpfpzmvpbwovss7>

+46 -46
+18 -18
Cargo.lock
··· 141 141 ] 142 142 143 143 [[package]] 144 + name = "auth" 145 + version = "0.0.0" 146 + dependencies = [ 147 + "atproto", 148 + "aws-lc-rs", 149 + "data-encoding", 150 + "identity", 151 + "multibase", 152 + "serde", 153 + "serde_json", 154 + "ssh-key", 155 + "thiserror", 156 + "url", 157 + ] 158 + 159 + [[package]] 144 160 name = "autocfg" 145 161 version = "1.5.0" 146 162 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 573 557 dependencies = [ 574 558 "anyhow", 575 559 "atproto", 560 + "auth", 576 561 "axum", 577 562 "clap", 578 563 "data-encoding", 579 564 "directories", 580 565 "identity", 581 - "oauth", 582 566 "owo-colors", 583 567 "rand 0.9.2", 584 568 "reqwest", ··· 2718 2702 "anyhow", 2719 2703 "async-trait", 2720 2704 "atproto", 2705 + "auth", 2721 2706 "axum", 2722 2707 "axum-extra", 2723 2708 "bytes", ··· 2731 2714 "identity", 2732 2715 "jetstream", 2733 2716 "lexicon", 2734 - "oauth", 2735 2717 "rayon", 2736 2718 "reqwest", 2737 2719 "rustc-hash", ··· 3084 3068 dependencies = [ 3085 3069 "autocfg", 3086 3070 "libm", 3087 - ] 3088 - 3089 - [[package]] 3090 - name = "oauth" 3091 - version = "0.0.0" 3092 - dependencies = [ 3093 - "atproto", 3094 - "aws-lc-rs", 3095 - "data-encoding", 3096 - "identity", 3097 - "multibase", 3098 - "serde", 3099 - "serde_json", 3100 - "ssh-key", 3101 - "thiserror", 3102 - "url", 3103 3071 ] 3104 3072 3105 3073 [[package]]
+2 -2
Cargo.toml
··· 2 2 resolver = "3" 3 3 members = [ 4 4 "crates/atproto", 5 + "crates/auth", 5 6 "crates/credential_helper", 6 7 "crates/identity", 7 8 "crates/jetstream", 8 9 "crates/knot", 9 10 "crates/lexicon", 10 - "crates/oauth", 11 11 "crates/serve_git", 12 12 "crates/xrpc" 13 13 ] ··· 23 23 24 24 [workspace.dependencies] 25 25 atproto = { path = "crates/atproto" } 26 + auth = { path = "crates/auth" } 26 27 identity = { path = "crates/identity" } 27 28 jetstream = { path = "crates/jetstream" } 28 29 lexicon = { path = "crates/lexicon" } 29 - oauth = { path = "crates/oauth" } 30 30 serve_git = { path = "crates/serve_git"} 31 31 xrpc = { path = "crates/xrpc" } 32 32
+1 -1
crates/credential_helper/Cargo.toml
··· 9 9 10 10 [dependencies] 11 11 atproto.workspace = true 12 + auth.workspace = true 12 13 identity.workspace = true 13 - oauth.workspace = true 14 14 15 15 anyhow.workspace = true 16 16 axum.workspace = true
+2 -2
crates/credential_helper/src/commands/git_credential.rs
··· 1 1 use anyhow::Context as _; 2 + use auth::jwt::{Algorithm, Curve, Header}; 2 3 use data_encoding::{BASE32HEX_NOPAD, BASE64URL_NOPAD}; 3 - use oauth::jwt::{Algorithm, Curve, Header}; 4 4 use owo_colors::{OwoColorize, Stream::Stderr}; 5 5 use ssh_agent_client_rs::{Client, Identity}; 6 6 use ssh_key::public::{EcdsaPublicKey, KeyData}; ··· 145 145 let jti: [u8; 16] = rand::random(); 146 146 let jti: Box<str> = BASE32HEX_NOPAD.encode(&jti).to_ascii_lowercase().into(); 147 147 148 - let claims = oauth::jwt::Claims { 148 + let claims = auth::jwt::Claims { 149 149 iss, 150 150 aud, 151 151 iat,
+1 -1
crates/knot/Cargo.toml
··· 10 10 11 11 [dependencies] 12 12 atproto.workspace = true 13 + auth.workspace = true 13 14 identity.workspace = true 14 15 jetstream.workspace = true 15 16 lexicon.workspace = true 16 - oauth.workspace = true 17 17 serve_git.workspace = true 18 18 xrpc.workspace = true 19 19
+3 -3
crates/knot/src/model.rs
··· 51 51 } 52 52 } 53 53 54 - impl AuthorizationClaimsStore<oauth::jwt::Claims> for Knot { 54 + impl AuthorizationClaimsStore<auth::jwt::Claims> for Knot { 55 55 #[inline] 56 - fn get_unexpired_claims(&self, jti: &str, now: i64) -> Option<oauth::jwt::Claims> { 56 + fn get_unexpired_claims(&self, jti: &str, now: i64) -> Option<auth::jwt::Claims> { 57 57 self.inner.get_unexpired_claims(jti, now) 58 58 } 59 59 60 60 #[inline] 61 - fn store_claims(&self, claims: oauth::jwt::Claims) { 61 + fn store_claims(&self, claims: auth::jwt::Claims) { 62 62 self.inner.store_claims(claims); 63 63 } 64 64 }
+10 -10
crates/knot/src/model/knot_state.rs
··· 6 6 }; 7 7 8 8 use atproto::did::Did; 9 + use auth::{jwt, public_key}; 9 10 use bytes::Bytes; 10 11 use identity::{HttpClient, Resolver}; 11 12 use jetstream::JetstreamClient; 12 13 use lexicon::com::atproto::repo::list_records; 13 - use oauth::public_key::PublicKey; 14 14 use rayon::{ThreadPool, ThreadPoolBuilder}; 15 15 use time::OffsetDateTime; 16 16 use tokio_stream::StreamExt as _; ··· 49 49 pool: ThreadPool, 50 50 51 51 /// Stores JWT claims to prevent re-use. 52 - jwt_claims: Mutex<HashMap<Box<str>, oauth::jwt::Claims>>, 52 + jwt_claims: Mutex<HashMap<Box<str>, jwt::Claims>>, 53 53 54 54 /// Resolved repository path lookup cache. 55 55 /// ··· 135 135 } 136 136 137 137 /// Acquire a lock on the jwt claims store. 138 - pub fn jwt_claims(&self) -> MutexGuard<'_, HashMap<Box<str>, oauth::jwt::Claims>> { 138 + pub fn jwt_claims(&self) -> MutexGuard<'_, HashMap<Box<str>, jwt::Claims>> { 139 139 self.jwt_claims.lock().unwrap_or_else(|mut poisoned| { 140 140 tracing::warn!("jwt claims store poisoned"); 141 141 // @QUESTION Maybe we should abort() here. ··· 150 150 /// 151 151 /// If the knot has no public keys stored, they will be fetched from the PDS associated with 152 152 /// the DID. 153 - pub async fn public_keys(&self, did: &Did) -> Vec<PublicKey> { 153 + pub async fn public_keys(&self, did: &Did) -> Vec<public_key::PublicKey> { 154 154 let keys: Vec<_> = self 155 155 .store 156 156 .public_keys_for_did(did) ··· 161 161 .unwrap_or_default() 162 162 .into_iter() 163 163 .filter_map(|pk| { 164 - PublicKey::from_openssh(&pk.key) 164 + public_key::PublicKey::from_openssh(&pk.key) 165 165 .inspect_err(|error| { 166 166 tracing::error!(?error, ?pk, "failed to parse public key from db") 167 167 }) ··· 178 178 } 179 179 } 180 180 181 - pub async fn fetch_public_keys(&self, did: &Did) -> anyhow::Result<Vec<PublicKey>> { 181 + pub async fn fetch_public_keys(&self, did: &Did) -> anyhow::Result<Vec<public_key::PublicKey>> { 182 182 use lexicon::sh::tangled::PublicKey as LexiconPublicKey; 183 183 use url::Url; 184 184 ··· 218 218 Ok(public_keys 219 219 .records() 220 220 .filter_map(|rec| { 221 - PublicKey::from_openssh(&rec.value.key) 221 + public_key::PublicKey::from_openssh(&rec.value.key) 222 222 .inspect_err(|e| { 223 223 tracing::error!(?e, ?did, "failed to parse public key from collection") 224 224 }) ··· 424 424 } 425 425 } 426 426 427 - impl AuthorizationClaimsStore<oauth::jwt::Claims> for KnotState { 427 + impl AuthorizationClaimsStore<auth::jwt::Claims> for KnotState { 428 428 #[inline] 429 - fn get_unexpired_claims(&self, jti: &str, now: i64) -> Option<oauth::jwt::Claims> { 429 + fn get_unexpired_claims(&self, jti: &str, now: i64) -> Option<auth::jwt::Claims> { 430 430 let mut store = self.jwt_claims(); 431 431 let claims = store.get(jti).cloned(); 432 432 ··· 440 440 } 441 441 442 442 #[inline] 443 - fn store_claims(&self, claims: oauth::jwt::Claims) { 443 + fn store_claims(&self, claims: auth::jwt::Claims) { 444 444 self.jwt_claims().insert(claims.jti.clone(), claims); 445 445 } 446 446 }
+4 -4
crates/knot/src/public/git/authorization.rs
··· 1 + use auth::{ 2 + jwt::{Claims, Token, decode}, 3 + public_key::PublicKey, 4 + }; 1 5 use axum::{ 2 6 extract::{FromRef, FromRequestParts}, 3 7 http::{header::AUTHORIZATION, request::Parts}, 4 8 }; 5 9 use identity::Resolver; 6 - use oauth::{ 7 - jwt::{Claims, Token, decode}, 8 - public_key::PublicKey, 9 - }; 10 10 use time::OffsetDateTime; 11 11 12 12 use crate::{
+4 -4
crates/knot/src/services/authorization.rs
··· 1 1 use core::fmt; 2 2 3 + use auth::{ 4 + jwt::{Claims, Token, decode}, 5 + public_key::PublicKey, 6 + }; 3 7 use axum::{ 4 8 extract::{FromRef, FromRequestParts}, 5 9 http::{ ··· 12 8 }, 13 9 }; 14 10 use identity::Resolver; 15 - use oauth::{ 16 - jwt::{Claims, Token, decode}, 17 - public_key::PublicKey, 18 - }; 19 11 use time::OffsetDateTime; 20 12 21 13 use crate::{
+1 -1
crates/oauth/Cargo.toml crates/auth/Cargo.toml
··· 1 1 [package] 2 - name = "oauth" 2 + name = "auth" 3 3 version.workspace = true 4 4 authors.workspace = true 5 5 repository.workspace = true
crates/oauth/src/jwt.rs crates/auth/src/jwt.rs
crates/oauth/src/lib.rs crates/auth/src/lib.rs
crates/oauth/src/public_key.rs crates/auth/src/public_key.rs
crates/oauth/src/resources.rs crates/auth/src/resources.rs
crates/oauth/src/support_set.rs crates/auth/src/support_set.rs
crates/oauth/src/types.rs crates/auth/src/types.rs
crates/oauth/src/validated_url.rs crates/auth/src/validated_url.rs