Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions examples/dpop-website/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions examples/dpop-website/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ path = "src/main.rs"

[dependencies]
# ATProtocol dependencies - Update paths as needed for your setup
atproto-client = { path = "/Users/nick/development/tangled.sh/smokesignal.events/atproto-identity-rs/crates/atproto-client" }
atproto-identity = { path = "/Users/nick/development/tangled.sh/smokesignal.events/atproto-identity-rs/crates/atproto-identity" }
atproto-oauth = { path = "/Users/nick/development/tangled.sh/smokesignal.events/atproto-identity-rs/crates/atproto-oauth" }
# atproto-client = { path = "/Users/nick/development/tangled.sh/smokesignal.events/atproto-identity-rs/crates/atproto-client" }
# atproto-identity = { path = "/Users/nick/development/tangled.sh/smokesignal.events/atproto-identity-rs/crates/atproto-identity" }
# atproto-oauth = { path = "/Users/nick/development/tangled.sh/smokesignal.events/atproto-identity-rs/crates/atproto-oauth" }

atproto-oauth = { version = "0.11.3", features = ["lru", "zeroize", "hickory-dns"] }
atproto-identity = { version = "0.11.3", features = ["zeroize"] }
atproto-client = { version = "0.11.3" }

# Web framework
axum = { version = "0.8" }
Expand Down
6 changes: 4 additions & 2 deletions examples/dpop-website/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ struct OAuthState {
#[derive(Debug, Serialize)]
struct PARRequest {
client_id: String,
client_secret: String,
response_type: String,
redirect_uri: String,
scope: String,
Expand Down Expand Up @@ -481,7 +482,7 @@ async fn register_client(
response_types: vec!["code".to_string()],
grant_types: vec!["authorization_code".to_string()],
token_endpoint_auth_method: "client_secret_post".to_string(),
scope: "atproto:atproto atproto:transition:generic".to_string(),
scope: "openid email profile atproto account:email repo:* rpc:*".to_string(),
contacts: Some(vec!["admin@demo-dpop-client.example".to_string()]),
logo_uri: None,
policy_uri: Some(format!("{}/policy", config.demo_base_url)),
Expand Down Expand Up @@ -870,7 +871,7 @@ async fn login_handler(

// Step 3: Prepare OAuth parameters
let redirect_uri = format!("{}/callback", state.config.demo_base_url);
let scope = "atproto:atproto atproto:transition:generic".to_string();
let scope = "openid email profile atproto account:email repo:* rpc:*".to_string();

let oauth_state_data = OAuthState {
state: oauth_state.clone(),
Expand Down Expand Up @@ -908,6 +909,7 @@ async fn login_handler(
// Make PAR request with DPoP
let par_request = PARRequest {
client_id: client_credentials.client_id.clone(),
client_secret: client_credentials.client_secret.unwrap(),
response_type: "code".to_string(),
redirect_uri: redirect_uri.clone(),
scope: scope.clone(),
Expand Down
6 changes: 5 additions & 1 deletion src/http/handler_par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::oauth::{
pub(super) struct PushedAuthorizationRequest {
pub response_type: String,
pub client_id: String,
pub client_secret: Option<String>,
pub redirect_uri: String,
pub scope: Option<String>,
pub state: Option<String>,
Expand Down Expand Up @@ -314,7 +315,7 @@ fn extract_client_auth_from_request(
// But we'll support client_id from the form
Some(ClientAuthentication {
client_id: request.client_id.clone(),
client_secret: None,
client_secret: request.client_secret.clone(),
client_assertion: None,
client_assertion_type: None,
})
Expand Down Expand Up @@ -432,6 +433,7 @@ mod tests {
let par_request = PushedAuthorizationRequest {
response_type: "code".to_string(),
client_id: client.client_id.clone(),
client_secret: None,
redirect_uri: "https://example.com/callback".to_string(),
scope: Some("atproto".to_string()),
state: Some("test-state".to_string()),
Expand Down Expand Up @@ -516,6 +518,7 @@ mod tests {
let par_request = PushedAuthorizationRequest {
response_type: "code".to_string(),
client_id: client.client_id.clone(),
client_secret: None,
redirect_uri: "https://evil.com/callback".to_string(), // Invalid redirect URI
scope: Some("atproto".to_string()),
state: Some("test-state".to_string()),
Expand Down Expand Up @@ -598,6 +601,7 @@ mod tests {
let par_request = PushedAuthorizationRequest {
response_type: "code".to_string(),
client_id: client.client_id.clone(),
client_secret: None,
redirect_uri: "https://example.com/callback".to_string(),
scope: Some("atproto transition:email".to_string()), // Requesting more than allowed
state: Some("test-state".to_string()),
Expand Down