createAccount stricter limits and more #3

merged
opened by baileytownsend.dev targeting main from feature/CreateAccountStricterRateLimits
  • added rate limiter on the com.atproto.servce.createAccount end point so you can set stricter limits
  • having a /pds/pds.env is no longer a hard requirment
  • fix a bug on com.atproto.server.getSession not returning on oauth logins
  • bit more logging on errors
Changed files
+13 -8
examples
src
+2 -3
Cargo.toml
···
hex = "0.4"
jwt-compact = { version = "0.8.0", features = ["es256k"] }
scrypt = "0.11"
-
#lettre = { version = "0.11.18", default-features = false, features = ["pool", "tokio1-rustls", "smtp-transport", "hostname", "builder"] }
-
#lettre = { version = "0.11", default-features = false, features = ["builder", "webpki-roots", "rustls", "aws-lc-rs", "smtp-transport", "tokio1", "tokio1-rustls"] }
+
#Leaveing these two cause I think it is needed by the
aws-lc-rs = "1.13.0"
-
lettre = { version = "0.11", default-features = false, features = ["builder", "webpki-roots", "rustls", "aws-lc-rs", "smtp-transport", "tokio1", "tokio1-rustls"] }
rustls = { version = "0.23", default-features = false, features = ["tls12", "std", "logging", "aws_lc_rs"] }
+
lettre = { version = "0.11", default-features = false, features = ["builder", "webpki-roots", "rustls", "aws-lc-rs", "smtp-transport", "tokio1", "tokio1-rustls"] }
handlebars = { version = "6.3.2", features = ["rust-embed"] }
rust-embed = "8.7.2"
axum-template = { version = "3.0.0", features = ["handlebars"] }
+3 -3
Cargo.lock
···
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [
"libc",
-
"windows-sys 0.52.0",
+
"windows-sys 0.59.0",
]
[[package]]
···
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
dependencies = [
"cfg-if",
-
"windows-targets 0.48.5",
+
"windows-targets 0.52.6",
[[package]]
···
"errno",
"libc",
"linux-raw-sys",
-
"windows-sys 0.52.0",
+
"windows-sys 0.59.0",
[[package]]
+1
examples/Caddyfile
···
path /xrpc/com.atproto.server.getSession
path /xrpc/com.atproto.server.updateEmail
path /xrpc/com.atproto.server.createSession
+
path /xrpc/com.atproto.server.createAccount
path /@atproto/oauth-provider/~api/sign-in
}
-2
src/middleware.rs
···
use crate::helpers::json_error_response;
use axum::extract::Request;
-
use axum::http::header::AUTHORIZATION;
use axum::http::{HeaderMap, StatusCode};
use axum::middleware::Next;
use axum::response::IntoResponse;
···
.expect("Error creating an error response");
}
let token = token.expect("Already checked for error,");
-
// Not going to worry about expiration since it still goes to the PDS
req.extensions_mut()
.insert(Did(Some(token.claims().custom.sub.clone())));
}
+7
README.md
···
`GATEKEEPER_HOST` - Host for pds gatekeeper. Defaults to `127.0.0.1`
`GATEKEEPER_PORT` - Port for pds gatekeeper. Defaults to `8080`
+
+
`GATEKEEPER_CREATE_ACCOUNT_PER_SECOND` - Sets how often it takes a count off the limiter. example if you hit the rate
+
limit of 5 and set to 60, then in 60 seconds you will be able to make one more. Or in 5 minutes be able to make 5 more.
+
+
`GATEKEEPER_CREATE_ACCOUNT_BURST` - Sets how many requests can be made in a burst. In the prior example this is where
+
the 5 comes from. Example can set this to 10 to allow for 10 requests in a burst, and after 60 seconds it will drop one
+
off.