Add auth to State#10
Conversation
bdebinska
left a comment
There was a problem hiding this comment.
I'm not entirely convinced this is necessary. Why does "auth" have to be a top level key? Can't it be part of the action itself?
| max_retries: max_retries, | ||
| decode_body: decode_body | ||
| ) | ||
| |> Req.update( |
There was a problem hiding this comment.
Good catch, but it's older code and not super-relevant for this PR, so I'd prefer handling it separately if that's okay
|
Another comment from my side: This branch and PR should be linked to the ticket |
It's so that the services themselves (e.g. Batch Service) can generate and set the auth key outside a single action/step (a step shouldn't be involved in the auth of the calling services). |
Bad formulation on my side sorry. I meant more that it seems that having a separate "auth" action/step, instead of having it in the state directly seems more fitting to me. |
Hm, maybe.. My line of thinking was always that the current workflows shouldn't be affected/touched, so I put everything on the services. We could discuss this other way as well |
|
Hi all 👋 I'd like to throw a different suggestion into the ring: Make authentication a callback-based operation (optional of course). This brings flexibility while keeping complexity out of workflow engine. While I haven't fully thought this through, I could image it looking like this: defmodule MyApp.WorkflowEngine do
use WorkflowEngine, …
def authenticate(:http, target, auth_context) do
{:ok, {:bearer, "foobar"}}
end
def authenticate(_action_type, _target, _auth_context), do: {:ok, nil}
endwhere %{
state: %WorkflowEngine.State{},
action: %{}, # action JSON being executed
workflow: %{} # whole workflow JSON definition or identifier?
}Information about the acting entity would be placed into a new key in the workflow engine's state when calling The return format would depend on the action type, for HTTP you could initially support To make it easy to use, WorkflowEngine should add/generate a |
Heyy, thanks for the suggestion! I like the idea overall, I'll try and see if I can cook something up around it |
mpneuried
left a comment
There was a problem hiding this comment.
Code wise it looks good.
Only some small doc extensions would be nice.
I partially agree with BDE, on the other side we now put effort in it and it's covered by tests. So I'm fine with it.
No description provided.