Skip to content

Commit 65dc442

Browse files
committed
feat(pairing) add list_keys endpoint
Signed-off-by: Eddy Babetto <eddy.babetto@secomind.com>
1 parent a179784 commit 65dc442

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# This file is part of Astarte.
3+
#
4+
# Copyright 2026 SECO Mind Srl
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
defmodule Astarte.PairingWeb.OwnerKeyController do
20+
use Astarte.PairingWeb, :controller
21+
22+
alias Astarte.Pairing.FDO.OpenBao
23+
alias Astarte.Pairing.FDO.OpenBao.Core
24+
25+
require Logger
26+
27+
action_fallback Astarte.PairingWeb.FallbackController
28+
29+
def list_keys(
30+
conn,
31+
%{
32+
"realm_name" => realm_name,
33+
"key_algorithm"=> key_algorithm
34+
}
35+
) do
36+
{:ok, namespace} = OpenBao.create_namespace(realm_name, key_algorithm)
37+
38+
with {:ok, keys} <- Core.list_keys(namespace) do
39+
send_resp(conn, 200, keys)
40+
end
41+
end
42+
end

apps/astarte_pairing/lib/astarte_pairing_web/router.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ defmodule Astarte.PairingWeb.Router do
8383
pipe_through :fdo_feature_gate
8484
pipe_through :agent_api
8585
post "/", OwnershipVoucherController, :create
86+
post "/list_keys", OwnershipVoucherController, :create
8687
end
8788

8889
scope "/agent" do
@@ -104,6 +105,14 @@ defmodule Astarte.PairingWeb.Router do
104105
end
105106
end
106107

108+
scope "/fdo" do
109+
pipe_through :fdo_feature_gate
110+
111+
pipe_through :agent_api
112+
113+
get "/list_keys", OwnerKeyController, :list_keys
114+
end
115+
107116
scope "/version", Astarte.PairingWeb do
108117
get "/", VersionController, :show
109118
end

0 commit comments

Comments
 (0)