diff options
author | Felix <me@nutomic.com> | 2020-04-18 20:54:20 +0200 |
---|---|---|
committer | Felix <me@nutomic.com> | 2020-04-18 20:54:20 +0200 |
commit | 8daf72278d6c9fdd18ad2bf8c45ea4d25c428bad (patch) | |
tree | bdc2b3ad6e44d1a1ac092f14141e3d6ffdfcc3b8 /server/src/api | |
parent | 0199b5f169d32d4ccd19751e12dcaa61a957e787 (diff) |
Add http signature to outgoing apub requests
Diffstat (limited to 'server/src/api')
-rw-r--r-- | server/src/api/community.rs | 9 | ||||
-rw-r--r-- | server/src/api/user.rs | 15 |
2 files changed, 13 insertions, 11 deletions
diff --git a/server/src/api/community.rs b/server/src/api/community.rs index 40d8afe3..30c8aa20 100644 --- a/server/src/api/community.rs +++ b/server/src/api/community.rs @@ -1,6 +1,7 @@ use super::*; use crate::apub::activities::follow_community; -use crate::apub::{gen_keypair_str, make_apub_endpoint, EndpointType}; +use crate::apub::signatures::generate_actor_keypair; +use crate::apub::{make_apub_endpoint, EndpointType}; use diesel::PgConnection; use std::str::FromStr; @@ -200,7 +201,7 @@ impl Perform<CommunityResponse> for Oper<CreateCommunity> { } // When you create a community, make sure the user becomes a moderator and a follower - let (community_public_key, community_private_key) = gen_keypair_str(); + let keypair = generate_actor_keypair(); let community_form = CommunityForm { name: data.name.to_owned(), @@ -214,8 +215,8 @@ impl Perform<CommunityResponse> for Oper<CreateCommunity> { updated: None, actor_id: make_apub_endpoint(EndpointType::Community, &data.name).to_string(), local: true, - private_key: Some(community_private_key), - public_key: Some(community_public_key), + private_key: Some(keypair.private_key), + public_key: Some(keypair.public_key), last_refreshed_at: None, published: None, }; diff --git a/server/src/api/user.rs b/server/src/api/user.rs index fbdead53..35bdd33a 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -1,5 +1,6 @@ use super::*; -use crate::apub::{gen_keypair_str, make_apub_endpoint, EndpointType}; +use crate::apub::signatures::generate_actor_keypair; +use crate::apub::{make_apub_endpoint, EndpointType}; use crate::settings::Settings; use crate::{generate_random_string, send_email}; use bcrypt::verify; @@ -251,7 +252,7 @@ impl Perform<LoginResponse> for Oper<Register> { return Err(APIError::err("admin_already_created").into()); } - let (user_public_key, user_private_key) = gen_keypair_str(); + let keypair = generate_actor_keypair(); // Register the new user let user_form = UserForm { @@ -274,8 +275,8 @@ impl Perform<LoginResponse> for Oper<Register> { actor_id: make_apub_endpoint(EndpointType::User, &data.username).to_string(), bio: None, local: true, - private_key: Some(user_private_key), - public_key: Some(user_public_key), + private_key: Some(keypair.private_key), + public_key: Some(keypair.public_key), last_refreshed_at: None, }; @@ -295,7 +296,7 @@ impl Perform<LoginResponse> for Oper<Register> { } }; - let (community_public_key, community_private_key) = gen_keypair_str(); + let keypair = generate_actor_keypair(); // Create the main community if it doesn't exist let main_community: Community = match Community::read(&conn, 2) { @@ -314,8 +315,8 @@ impl Perform<LoginResponse> for Oper<Register> { updated: None, actor_id: make_apub_endpoint(EndpointType::Community, default_community_name).to_string(), local: true, - private_key: Some(community_private_key), - public_key: Some(community_public_key), + private_key: Some(keypair.private_key), + public_key: Some(keypair.public_key), last_refreshed_at: None, published: None, }; |