Skip to content

Commit

Permalink
Edit plug for authorization
Browse files Browse the repository at this point in the history
Edit plug to match new astarte feature for a shared db through multiple astarte instances

Signed-off-by: Eddy Babetto <eddy.babetto@secomind.com>
  • Loading branch information
eddbbt committed Apr 12, 2024
1 parent 415bb63 commit 33244d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/astarte_flow/auth/astarte_public_key_provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ defmodule Astarte.Flow.Auth.AstartePublicKeyProvider do
require Logger

alias Astarte.Core.Realm
alias Astarte.Core.CQLUtils
alias Astarte.Flow.Config

@impl true
@spec fetch_public_key(realm :: String.t()) ::
Expand All @@ -31,6 +33,8 @@ defmodule Astarte.Flow.Auth.AstartePublicKeyProvider do
end

defp fetch_realm_public_key(conn, realm_name) do
realm_name = CQLUtils.realm_name_to_keyspace_name(realm_name, Config.astarte_instance_id!())

statement = """
SELECT blobAsVarchar(value)
FROM :realm_name.kv_store
Expand Down
6 changes: 6 additions & 0 deletions lib/astarte_flow/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ defmodule Astarte.Flow.Config do
os_env: "CASSANDRA_NODES",
type: XandraNodes

@envdoc "The astarte instance id to generate keyspaces with"
app_env :astarte_instance_id, :astarte_flow, :astarte_instance_id,
os_env: "ASTARTE_INSTANCE_ID",
default: "",
type: :binary

@doc "Returns the default amqp connection parameters"
@type ssl_option ::
{:cacertfile, String.t()}
Expand Down
4 changes: 1 addition & 3 deletions lib/astarte_flow/flows/flow.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ defmodule Astarte.Flow.Flows.Flow do
error ->
_ =
Logger.error(
"Could not start block #{inspect(block_module)} with opts #{inspect(block_opts)}: #{
inspect(error)
}"
"Could not start block #{inspect(block_module)} with opts #{inspect(block_opts)}: #{inspect(error)}"
)

{:error, :block_start_failed}
Expand Down

0 comments on commit 33244d1

Please sign in to comment.