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

OAuth2 support for flyte-cli and SDK engine #23

Merged
merged 46 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d0715bb
WIP pkce auth flow
katrogan Oct 11, 2019
f576129
Add discovery
katrogan Oct 23, 2019
c7eba16
pass authentication metadata in gRPC calls
katrogan Oct 23, 2019
1bda5da
add credential type, misc clean-up
katrogan Oct 23, 2019
cc2517c
nits
katrogan Nov 12, 2019
2a350c7
removing a redirect follow, comments, adding a sample default discove…
Nov 13, 2019
1cb1620
checkpoint
katrogan Nov 13, 2019
2b9d178
proper sequence of events
katrogan Nov 13, 2019
1cc9999
adding config file read, sample config file, and a test that will be …
Nov 13, 2019
89dcb1e
pulling and resolving conflicts
Nov 13, 2019
1cbcf3a
let ur browser handle redirects
katrogan Nov 13, 2019
6ccb327
pull out urlencode separately, doesn't work for python3
Nov 14, 2019
58f97e9
fixing python3 import, changing keyring var names
Nov 14, 2019
986d49b
some super pythonic code for handling token refresh
katrogan Nov 15, 2019
ff842e2
use retry library
katrogan Nov 16, 2019
2928417
customizable rpc error callback fn
katrogan Nov 22, 2019
e50df71
configurable refresh handlers
katrogan Nov 25, 2019
41c6c2b
expose set_access_token
katrogan Nov 25, 2019
fd1083e
remove refresh_metadata()
katrogan Nov 26, 2019
33e1586
pyflyte component of auth (#52)
wild-endeavor Nov 26, 2019
e380b7e
update the character range for code verifier to include - _ . ~
Nov 26, 2019
1ecf29f
adding test for set token
Nov 26, 2019
aeb6529
unit test for basic auth handler
Nov 26, 2019
b27ae35
add preliminary auth and credentials tests
katrogan Nov 26, 2019
96416fd
Merge branch 'pkce-auth' of github.com:lyft/flytekit into pkce-auth
katrogan Nov 26, 2019
d2ddf4a
add discovery client tests
katrogan Nov 26, 2019
18180e9
fix test for updated regex
katrogan Nov 26, 2019
83c91e1
change str to decode because python2
Nov 26, 2019
77ce838
no auth mode, rm comment
katrogan Nov 27, 2019
bd7324e
nevermind
katrogan Nov 27, 2019
7004c59
one more revert
katrogan Nov 27, 2019
244d032
change handling around default home directory config file loading so …
Nov 27, 2019
48f74fe
Merge branch 'pkce-auth' of github.com:lyft/flytekit into pkce-auth
Nov 27, 2019
067a604
address review comments
katrogan Dec 4, 2019
23a14c8
nits
katrogan Dec 4, 2019
a52ba07
Env var (from pkce-auth pr) option 2 (#64)
wild-endeavor Dec 5, 2019
7f54611
remove no longer necessary location backup for credentials secret
Dec 5, 2019
dcd7d34
merge master and resolve conflict
Dec 5, 2019
053e03e
use the real auth exception class
Dec 5, 2019
0dc3186
get_discovery_endpoint changes
Dec 6, 2019
946a058
cleanup keyring code
katrogan Dec 6, 2019
a940a0c
Merge branch 'pkce-auth' of github.com:lyft/flytekit into pkce-auth
katrogan Dec 6, 2019
d200b55
add expiration handling
katrogan Dec 6, 2019
feb403e
bump flytekit version
katrogan Dec 6, 2019
fc56ce6
no need to force twice, now that it's been added to the base client
Dec 6, 2019
bd9bbb6
use non-beta release
katrogan Dec 6, 2019
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
57 changes: 30 additions & 27 deletions flytekit/clients/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RawSynchronousFlyteClient(object):
be explicit as opposed to inferred from the environment or a configuration file.
"""

def __init__(self, url, insecure=False, credentials=None, options=None):
def __init__(self, url, insecure=False, credentials=None, options=None, metadata=None):
"""
Initializes a gRPC channel to the given Flyte Admin service.

Expand All @@ -35,6 +35,8 @@ def __init__(self, url, insecure=False, credentials=None, options=None):
:param Text credentials: [Optional] If provided, a secure channel will be opened with the Flyte Admin Service.
:param dict[Text, Text] options: [Optional] A dict of key-value string pairs for configuring the gRPC core
runtime.
:param list[(Text,Text)] metadata: [Optional] metadata pairs to be transmitted to the
service-side of the RPC.
"""
self._channel = None

Expand All @@ -48,6 +50,7 @@ def __init__(self, url, insecure=False, credentials=None, options=None):
options=list((options or {}).items())
)
self._stub = _admin_service.AdminServiceStub(self._channel)
self._metadata = metadata

####################################################################################################################
#
Expand All @@ -74,7 +77,7 @@ def create_task(self, task_create_request):
task is already registered.
:raises grpc.RpcError:
"""
return self._stub.CreateTask(task_create_request)
return self._stub.CreateTask(task_create_request, metadata=self._metadata)

@_handle_rpc_error
def list_task_ids_paginated(self, identifier_list_request):
Expand All @@ -100,7 +103,7 @@ def list_task_ids_paginated(self, identifier_list_request):
:rtype: flyteidl.admin.common_pb2.NamedEntityIdentifierList
:raises: TODO
"""
return self._stub.ListTaskIds(identifier_list_request)
return self._stub.ListTaskIds(identifier_list_request, metadata=self._metadata)

@_handle_rpc_error
def list_tasks_paginated(self, resource_list_request):
Expand All @@ -122,7 +125,7 @@ def list_tasks_paginated(self, resource_list_request):
:rtype: flyteidl.admin.task_pb2.TaskList
:raises: TODO
"""
return self._stub.ListTasks(resource_list_request)
return self._stub.ListTasks(resource_list_request, metadata=self._metadata)

@_handle_rpc_error
def get_task(self, get_object_request):
Expand All @@ -133,7 +136,7 @@ def get_task(self, get_object_request):
:rtype: flyteidl.admin.task_pb2.Task
:raises: TODO
"""
return self._stub.GetTask(get_object_request)
return self._stub.GetTask(get_object_request, metadata=self._metadata)

####################################################################################################################
#
Expand All @@ -160,7 +163,7 @@ def create_workflow(self, workflow_create_request):
identical workflow is already registered.
:raises grpc.RpcError:
"""
return self._stub.CreateWorkflow(workflow_create_request)
return self._stub.CreateWorkflow(workflow_create_request, metadata=self._metadata)

@_handle_rpc_error
def list_workflow_ids_paginated(self, identifier_list_request):
Expand All @@ -186,7 +189,7 @@ def list_workflow_ids_paginated(self, identifier_list_request):
:rtype: flyteidl.admin.common_pb2.NamedEntityIdentifierList
:raises: TODO
"""
return self._stub.ListWorkflowIds(identifier_list_request)
return self._stub.ListWorkflowIds(identifier_list_request, metadata=self._metadata)

@_handle_rpc_error
def list_workflows_paginated(self, resource_list_request):
Expand All @@ -208,7 +211,7 @@ def list_workflows_paginated(self, resource_list_request):
:rtype: flyteidl.admin.workflow_pb2.WorkflowList
:raises: TODO
"""
return self._stub.ListWorkflows(resource_list_request)
return self._stub.ListWorkflows(resource_list_request, metadata=self._metadata)

@_handle_rpc_error
def get_workflow(self, get_object_request):
Expand All @@ -219,7 +222,7 @@ def get_workflow(self, get_object_request):
:rtype: flyteidl.admin.workflow_pb2.Workflow
:raises: TODO
"""
return self._stub.GetWorkflow(get_object_request)
return self._stub.GetWorkflow(get_object_request, metadata=self._metadata)

####################################################################################################################
#
Expand Down Expand Up @@ -247,7 +250,7 @@ def create_launch_plan(self, launch_plan_create_request):
the identical launch plan is already registered.
:raises grpc.RpcError:
"""
return self._stub.CreateLaunchPlan(launch_plan_create_request)
return self._stub.CreateLaunchPlan(launch_plan_create_request, metadata=self._metadata)

# TODO: List endpoints when they come in

Expand All @@ -259,7 +262,7 @@ def get_launch_plan(self, object_get_request):
:param flyteidl.admin.common_pb2.ObjectGetRequest object_get_request:
:rtype: flyteidl.admin.launch_plan_pb2.LaunchPlan
"""
return self._stub.GetLaunchPlan(object_get_request)
return self._stub.GetLaunchPlan(object_get_request, metadata=self._metadata)

@_handle_rpc_error
def get_active_launch_plan(self, active_launch_plan_request):
Expand All @@ -269,7 +272,7 @@ def get_active_launch_plan(self, active_launch_plan_request):
:param flyteidl.admin.common_pb2.ActiveLaunchPlanRequest active_launch_plan_request:
:rtype: flyteidl.admin.launch_plan_pb2.LaunchPlan
"""
return self._stub.GetActiveLaunchPlan(active_launch_plan_request)
return self._stub.GetActiveLaunchPlan(active_launch_plan_request, metadata=self._metadata)

@_handle_rpc_error
def update_launch_plan(self, update_request):
Expand All @@ -280,7 +283,7 @@ def update_launch_plan(self, update_request):
:param flyteidl.admin.launch_plan_pb2.LaunchPlanUpdateRequest update_request:
:rtype: flyteidl.admin.launch_plan_pb2.LaunchPlanUpdateResponse
"""
return self._stub.UpdateLaunchPlan(update_request)
return self._stub.UpdateLaunchPlan(update_request, metadata=self._metadata)

@_handle_rpc_error
def list_launch_plan_ids_paginated(self, identifier_list_request):
Expand All @@ -290,7 +293,7 @@ def list_launch_plan_ids_paginated(self, identifier_list_request):
:param: flyteidl.admin.common_pb2.NamedEntityIdentifierListRequest identifier_list_request:
:rtype: flyteidl.admin.common_pb2.NamedEntityIdentifierList
"""
return self._stub.ListLaunchPlanIds(identifier_list_request)
return self._stub.ListLaunchPlanIds(identifier_list_request, metadata=self._metadata)

@_handle_rpc_error
def list_launch_plans_paginated(self, resource_list_request):
Expand All @@ -300,7 +303,7 @@ def list_launch_plans_paginated(self, resource_list_request):
:param: flyteidl.admin.common_pb2.ResourceListRequest resource_list_request:
:rtype: flyteidl.admin.launch_plan_pb2.LaunchPlanList
"""
return self._stub.ListLaunchPlans(resource_list_request)
return self._stub.ListLaunchPlans(resource_list_request, metadata=self._metadata)

@_handle_rpc_error
def list_active_launch_plans_paginated(self, active_launch_plan_list_request):
Expand All @@ -310,7 +313,7 @@ def list_active_launch_plans_paginated(self, active_launch_plan_list_request):
:param: flyteidl.admin.common_pb2.ActiveLaunchPlanListRequest active_launch_plan_list_request:
:rtype: flyteidl.admin.launch_plan_pb2.LaunchPlanList
"""
return self._stub.ListActiveLaunchPlans(active_launch_plan_list_request)
return self._stub.ListActiveLaunchPlans(active_launch_plan_list_request, metadata=self._metadata)

####################################################################################################################
#
Expand All @@ -325,7 +328,7 @@ def create_execution(self, create_execution_request):
:param flyteidl.admin.execution_pb2.ExecutionCreateRequest create_execution_request:
:rtype: flyteidl.admin.execution_pb2.ExecutionCreateResponse
"""
return self._stub.CreateExecution(create_execution_request)
return self._stub.CreateExecution(create_execution_request, metadata=self._metadata)

@_handle_rpc_error
def get_execution(self, get_object_request):
Expand All @@ -335,7 +338,7 @@ def get_execution(self, get_object_request):
:param flyteidl.admin.execution_pb2.WorkflowExecutionGetRequest get_object_request:
:rtype: flyteidl.admin.execution_pb2.Execution
"""
return self._stub.GetExecution(get_object_request)
return self._stub.GetExecution(get_object_request, metadata=self._metadata)

@_handle_rpc_error
def get_execution_data(self, get_execution_data_request):
Expand All @@ -355,15 +358,15 @@ def list_executions_paginated(self, resource_list_request):
:param flyteidl.admin.common_pb2.ResourceListRequest resource_list_request:
:rtype: flyteidl.admin.execution_pb2.ExecutionList
"""
return self._stub.ListExecutions(resource_list_request)
return self._stub.ListExecutions(resource_list_request, metadata=self._metadata)

@_handle_rpc_error
def terminate_execution(self, terminate_execution_request):
"""
:param flyteidl.admin.execution_pb2.TerminateExecutionRequest terminate_execution_request:
:rtype: flyteidl.admin.execution_pb2.TerminateExecutionResponse
"""
return self._stub.TerminateExecution(terminate_execution_request)
return self._stub.TerminateExecution(terminate_execution_request, metadata=self._metadata)

@_handle_rpc_error
def relaunch_execution(self, relaunch_execution_request):
Expand All @@ -385,7 +388,7 @@ def get_node_execution(self, node_execution_request):
:param flyteidl.admin.node_execution_pb2.NodeExecutionGetRequest node_execution_request:
:rtype: flyteidl.admin.node_execution_pb2.NodeExecution
"""
return self._stub.GetNodeExecution(node_execution_request)
return self._stub.GetNodeExecution(node_execution_request, metadata=self._metadata)

@_handle_rpc_error
def get_node_execution_data(self, get_node_execution_data_request):
Expand All @@ -403,15 +406,15 @@ def list_node_executions_paginated(self, node_execution_list_request):
:param flyteidl.admin.node_execution_pb2.NodeExecutionListRequest node_execution_list_request:
:rtype: flyteidl.admin.node_execution_pb2.NodeExecutionList
"""
return self._stub.ListNodeExecutions(node_execution_list_request)
return self._stub.ListNodeExecutions(node_execution_list_request, metadata=self._metadata)

@_handle_rpc_error
def list_node_executions_for_task_paginated(self, node_execution_for_task_list_request):
"""
:param flyteidl.admin.node_execution_pb2.NodeExecutionListRequest node_execution_for_task_list_request:
:rtype: flyteidl.admin.node_execution_pb2.NodeExecutionList
"""
return self._stub.ListNodeExecutionsForTask(node_execution_for_task_list_request)
return self._stub.ListNodeExecutionsForTask(node_execution_for_task_list_request, metadata=self._metadata)

####################################################################################################################
#
Expand All @@ -425,7 +428,7 @@ def get_task_execution(self, task_execution_request):
:param flyteidl.admin.task_execution_pb2.TaskExecutionGetRequest task_execution_request:
:rtype: flyteidl.admin.task_execution_pb2.TaskExecution
"""
return self._stub.GetTaskExecution(task_execution_request)
return self._stub.GetTaskExecution(task_execution_request, metadata=self._metadata)

@_handle_rpc_error
def get_task_execution_data(self, get_task_execution_data_request):
Expand All @@ -443,7 +446,7 @@ def list_task_executions_paginated(self, task_execution_list_request):
:param flyteidl.admin.task_execution_pb2.TaskExecutionListRequest task_execution_list_request:
:rtype: flyteidl.admin.task_execution_pb2.TaskExecutionList
"""
return self._stub.ListTaskExecutions(task_execution_list_request)
return self._stub.ListTaskExecutions(task_execution_list_request, metadata=self._metadata)

####################################################################################################################
#
Expand All @@ -458,7 +461,7 @@ def list_projects(self, project_list_request):
:param flyteidl.admin.project_pb2.ProjectListRequest project_list_request:
:rtype: flyteidl.admin.project_pb2.Projects
"""
return self._stub.ListProjects(project_list_request)
return self._stub.ListProjects(project_list_request, metadata=self._metadata)

@_handle_rpc_error
def register_project(self, project_register_request):
Expand All @@ -467,7 +470,7 @@ def register_project(self, project_register_request):
:param flyteidl.admin.project_pb2.ProjectRegisterRequest project_register_request:
:rtype: flyteidl.admin.project_pb2.ProjectRegisterResponse
"""
return self._stub.RegisterProject(project_register_request)
return self._stub.RegisterProject(project_register_request, metadata=self._metadata)

####################################################################################################################
#
Expand Down
Empty file.
Loading