Skip to content

Commit 1f5f425

Browse files
committed
refactor: adapt database structure for openbao
Signed-off-by: Francesco Noacco <francesco.noacco@secomind.com>
1 parent 7234b63 commit 1f5f425

File tree

8 files changed

+45
-22
lines changed

8 files changed

+45
-22
lines changed

.github/workflows/astarte-end-to-end-test-workflow.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ jobs:
112112
- name: Checkout fdo e2e repo
113113
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
114114
with:
115-
repository: astarte-platform/astarte-device-fdo-rust
116-
ref: dev
115+
repository: noaccos/astarte-device-fdo-rust
116+
ref: push-mzlxtwylktkr
117117
- uses: ./.github/actions/install-deps
118118
- name: Install astartectl
119119
run: |

apps/astarte_housekeeping/lib/astarte_housekeeping/realms/queries.ex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,15 @@ defmodule Astarte.Housekeeping.Realms.Queries do
625625
defp create_ownership_vouchers_table(keyspace_name) do
626626
query = """
627627
CREATE TABLE #{keyspace_name}.ownership_vouchers (
628-
private_key blob,
629-
voucher_data blob,
630628
guid blob,
629+
voucher_data blob,
630+
output_voucher blob,
631+
replacement_guid blob,
632+
replacement_rendezvous_info blob,
633+
replacement_public_key blob,
634+
key_name varchar,
635+
key_algorithm int,
636+
user_id blob,
631637
PRIMARY KEY (guid)
632638
);
633639
"""
@@ -673,9 +679,6 @@ defmodule Astarte.Housekeeping.Realms.Queries do
673679
device_service_info map<tuple<text, text>, blob>,
674680
owner_service_info list<blob>,
675681
last_chunk_sent int,
676-
replacement_guid blob,
677-
replacement_rv_info blob,
678-
replacement_pub_key blob,
679682
replacement_hmac blob,
680683
PRIMARY KEY (guid)
681684
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE :keyspace.to2_sessions
2+
DROP (replacement_guid, replacement_rv_info, replacement_pub_key)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE :keyspace.ownership_voucher
2+
DROP private_key
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ALTER TABLE :keyspace.ownership_voucher
2+
ADD (
3+
replacement_guid blob,
4+
replacement_rendezvous_info blob,
5+
replacement_public_key blob,
6+
output_voucher blob,
7+
key_name varchar,
8+
key_algorithm int,
9+
user_id blob,
10+
);

apps/astarte_pairing/test/support/helpers/database.ex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,15 @@ defmodule Astarte.Helpers.Database do
8383

8484
@create_ownership_vouchers_table """
8585
CREATE TABLE :keyspace.ownership_vouchers (
86-
private_key blob,
87-
voucher_data blob,
8886
guid blob,
87+
voucher_data blob,
88+
output_voucher blob,
89+
replacement_guid blob,
90+
replacement_rendezvous_info blob,
91+
replacement_public_key blob,
92+
key_name varchar,
93+
key_algorithm int,
94+
user_id blob,
8995
PRIMARY KEY (guid)
9096
);
9197
"""
@@ -112,9 +118,6 @@ defmodule Astarte.Helpers.Database do
112118
device_service_info map<tuple<text, text>, blob>,
113119
owner_service_info list<blob>,
114120
last_chunk_sent int,
115-
replacement_guid blob,
116-
replacement_rv_info blob,
117-
replacement_pub_key blob,
118121
replacement_hmac blob,
119122
PRIMARY KEY (guid)
120123
)

libs/astarte_data_access/lib/astarte_data_access/fdo/db_record.ex renamed to libs/astarte_data_access/lib/astarte_data_access/fdo/ownership_voucher.ex

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,25 @@ defmodule Astarte.DataAccess.FDO.OwnershipVoucher do
2121
Ecto schema for persisting ownership voucher binary data to the database.
2222
"""
2323
use TypedEctoSchema
24+
2425
import Ecto.Changeset
26+
27+
alias Astarte.DataAccess.FDO.CBOR.Encoded, as: CBOREncoded
2528
alias Astarte.DataAccess.FDO.OwnershipVoucher
29+
alias Astarte.FDO.Core.OwnershipVoucher.RendezvousInfo
30+
alias Astarte.FDO.Core.PublicKey
2631

2732
@primary_key false
2833
typed_schema "ownership_vouchers" do
29-
field :private_key, :binary
30-
field :voucher_data, :binary
3134
field :guid, Astarte.DataAccess.UUID, primary_key: true
35+
field :voucher_data, :binary
36+
field :output_voucher, :binary
37+
field :user_id, :binary
38+
field :key_name, :string
39+
field :key_algorithm, Ecto.Enum, values: [es256: 0, es384: 1, rs256: 10, rs384: 11]
40+
field :replacement_guid, :binary
41+
field :replacement_rv_info, CBOREncoded, using: RendezvousInfo
42+
field :replacement_pub_key, CBOREncoded, using: PublicKey
3243
end
3344

3445
@doc false

libs/astarte_data_access/lib/astarte_data_access/fdo/to2_session.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ defmodule Astarte.DataAccess.FDO.TO2Session do
2424

2525
alias Astarte.DataAccess.FDO.CBOR.Encoded, as: CBOREncoded
2626
alias Astarte.FDO.Core.Hash
27-
alias Astarte.FDO.Core.OwnershipVoucher.RendezvousInfo
28-
alias Astarte.FDO.Core.PublicKey
2927
alias COSE.Keys.Symmetric
3028

3129
@ciphers [
@@ -73,12 +71,6 @@ defmodule Astarte.DataAccess.FDO.TO2Session do
7371

7472
field :owner_service_info, {:array, :binary}
7573
field :last_chunk_sent, :integer
76-
field :replacement_guid, :binary
77-
78-
field :replacement_rv_info, CBOREncoded, using: RendezvousInfo
79-
80-
field :replacement_pub_key, CBOREncoded, using: PublicKey
81-
8274
field :replacement_hmac, CBOREncoded, using: Hash
8375
end
8476
end

0 commit comments

Comments
 (0)