mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-21 22:27:10 +00:00
make sure we correctly match key objects
This commit is contained in:
parent
bd64d07082
commit
d330c57cda
|
@ -2,6 +2,7 @@ defmodule Pleroma.User.SigningKey do
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
require Pleroma.Constants
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
|
||||||
|
@ -185,7 +186,6 @@ defmodule Pleroma.User.SigningKey do
|
||||||
"""
|
"""
|
||||||
def fetch_remote_key(key_id) do
|
def fetch_remote_key(key_id) do
|
||||||
Logger.debug("Fetching remote key: #{key_id}")
|
Logger.debug("Fetching remote key: #{key_id}")
|
||||||
# we should probably sign this, just in case
|
|
||||||
resp = Pleroma.Object.Fetcher.fetch_and_contain_remote_object_from_id(key_id)
|
resp = Pleroma.Object.Fetcher.fetch_and_contain_remote_object_from_id(key_id)
|
||||||
|
|
||||||
case resp do
|
case resp do
|
||||||
|
@ -228,7 +228,20 @@ defmodule Pleroma.User.SigningKey do
|
||||||
|
|
||||||
defp handle_signature_response({:ok, body}) do
|
defp handle_signature_response({:ok, body}) do
|
||||||
case body do
|
case body do
|
||||||
%{"id" => _user_id, "publicKey" => _public_key} ->
|
%{
|
||||||
|
"type" => "CryptographicKey",
|
||||||
|
"publicKeyPem" => public_key_pem,
|
||||||
|
"owner" => ap_id
|
||||||
|
} ->
|
||||||
|
{:ok, ap_id, public_key_pem}
|
||||||
|
|
||||||
|
# for when we get a subset of the user object
|
||||||
|
%{
|
||||||
|
"id" => _user_id,
|
||||||
|
"publicKey" => _public_key,
|
||||||
|
"type" => actor_type
|
||||||
|
}
|
||||||
|
when actor_type in Pleroma.Constants.actor_types() ->
|
||||||
extract_key_details(body)
|
extract_key_details(body)
|
||||||
|
|
||||||
%{"error" => error} ->
|
%{"error" => error} ->
|
||||||
|
|
|
@ -23,7 +23,7 @@ defmodule Pleroma.Repo.Migrations.MoveSigningKeys do
|
||||||
key = %User.SigningKey{
|
key = %User.SigningKey{
|
||||||
user_id: user_id,
|
user_id: user_id,
|
||||||
public_key: public_key,
|
public_key: public_key,
|
||||||
key_id: "#{ap_id}#main-key",
|
key_id: "#{ap_id}#main-key",
|
||||||
private_key: private_key
|
private_key: private_key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue