Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass dapr api token #598

Merged
merged 5 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dapr/clients/grpc/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def intercept_unary_unary(
Returns:
A response object after invoking the continuation callable
"""

# Pre-process or intercept call
new_call_details = self._intercept_call(client_call_details)
# Call continuation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
from dapr.ext.workflow.workflow_state import WorkflowState
from dapr.ext.workflow.workflow_context import Workflow
from dapr.ext.workflow.util import getAddress
from dapr.clients.http.client import DAPR_API_TOKEN_HEADER
from dapr.conf import settings


T = TypeVar('T')
TInput = TypeVar('TInput')
Expand All @@ -39,7 +42,10 @@ class DaprWorkflowClient:
"""
def __init__(self, host: Optional[str] = None, port: Optional[str] = None):
address = getAddress(host, port)
self.__obj = client.TaskHubGrpcClient(host_address=address)
metadata = tuple()
if settings.DAPR_API_TOKEN:
metadata = ((DAPR_API_TOKEN_HEADER, settings.DAPR_API_TOKEN),)
self.__obj = client.TaskHubGrpcClient(host_address=address, metadata=metadata)

def schedule_new_workflow(self,
workflow: Workflow, *,
Expand Down
8 changes: 7 additions & 1 deletion ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from dapr.ext.workflow.dapr_workflow_context import DaprWorkflowContext
from dapr.ext.workflow.workflow_activity_context import Activity, WorkflowActivityContext
from dapr.ext.workflow.util import getAddress
from dapr.clients.http.client import DAPR_API_TOKEN_HEADER
from dapr.conf import settings

T = TypeVar('T')
TInput = TypeVar('TInput')
Expand All @@ -32,8 +34,12 @@ class WorkflowRuntime:
"""

def __init__(self, host: Optional[str] = None, port: Optional[str] = None):
metadata = tuple()
if settings.DAPR_API_TOKEN:
metadata = ((DAPR_API_TOKEN_HEADER, settings.DAPR_API_TOKEN),)
address = getAddress(host, port)
self.__worker = worker.TaskHubGrpcWorker(host_address=address)

self.__worker = worker.TaskHubGrpcWorker(host_address=address, metadata=metadata)

def register_workflow(self, fn: Workflow):
def orchestrationWrapper(ctx: task.OrchestrationContext, inp: Optional[TInput] = None):
Expand Down
2 changes: 1 addition & 1 deletion ext/dapr-ext-workflow/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages = find_namespace:
include_package_data = True
install_requires =
dapr-dev >= 1.11.0rc1.dev
durabletask >= 0.1.0a2
durabletask >= 0.1.0a3

[options.packages.find]
include =
Expand Down