fixed authentication_callback and getting the user w/ burnettk
This commit is contained in:
parent
594a32b676
commit
2b01d2fe76
|
@ -1,11 +1,12 @@
|
||||||
openapi: "3.0.2"
|
openapi: "3.0.2"
|
||||||
info:
|
info:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
title: Workflow Microservice
|
title: spiffworkflow-backend
|
||||||
license:
|
license:
|
||||||
name: MIT
|
name: MIT
|
||||||
servers:
|
servers:
|
||||||
- url: http://localhost:5000/v1.0
|
- url: http://localhost:5000/v1.0
|
||||||
|
# this is handled in flask now
|
||||||
security: []
|
security: []
|
||||||
# - jwt: ["secret"]
|
# - jwt: ["secret"]
|
||||||
# - oAuth2AuthCode:
|
# - oAuth2AuthCode:
|
||||||
|
|
|
@ -828,7 +828,7 @@ def authentication_callback(
|
||||||
auth_method: str,
|
auth_method: str,
|
||||||
) -> werkzeug.wrappers.Response:
|
) -> werkzeug.wrappers.Response:
|
||||||
"""Authentication_callback."""
|
"""Authentication_callback."""
|
||||||
verify_token(request.args.get("token"))
|
verify_token(request.args.get("token"), force_run=True)
|
||||||
response = request.args["response"]
|
response = request.args["response"]
|
||||||
SecretService().update_secret(
|
SecretService().update_secret(
|
||||||
f"{service}/{auth_method}", response, g.user.id, create_if_not_exists=True
|
f"{service}/{auth_method}", response, g.user.id, create_if_not_exists=True
|
||||||
|
@ -885,7 +885,6 @@ def process_instance_report_show(
|
||||||
# @process_api_blueprint.route("/v1.0/tasks", methods=["GET"])
|
# @process_api_blueprint.route("/v1.0/tasks", methods=["GET"])
|
||||||
def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Response:
|
def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Response:
|
||||||
"""Task_list_my_tasks."""
|
"""Task_list_my_tasks."""
|
||||||
print("WE LIST")
|
|
||||||
principal = find_principal_or_raise()
|
principal = find_principal_or_raise()
|
||||||
|
|
||||||
active_tasks = (
|
active_tasks = (
|
||||||
|
|
|
@ -29,7 +29,7 @@ from spiffworkflow_backend.services.user_service import UserService
|
||||||
|
|
||||||
# authorization_exclusion_list = ['status']
|
# authorization_exclusion_list = ['status']
|
||||||
def verify_token(
|
def verify_token(
|
||||||
token: Optional[str] = None,
|
token: Optional[str] = None, force_run: Optional[bool] = False
|
||||||
) -> Optional[Dict[str, Optional[Union[str, int]]]]:
|
) -> Optional[Dict[str, Optional[Union[str, int]]]]:
|
||||||
"""Verify the token for the user (if provided).
|
"""Verify the token for the user (if provided).
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ def verify_token(
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
token: Optional[str]
|
token: Optional[str]
|
||||||
|
force_run: Optional[bool]
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
token: str
|
token: str
|
||||||
|
@ -45,7 +46,7 @@ def verify_token(
|
||||||
ApiError: If not on production and token is not valid, returns an 'invalid_token' 403 error.
|
ApiError: If not on production and token is not valid, returns an 'invalid_token' 403 error.
|
||||||
If on production and user is not authenticated, returns a 'no_user' 403 error.
|
If on production and user is not authenticated, returns a 'no_user' 403 error.
|
||||||
"""
|
"""
|
||||||
if AuthorizationService.should_disable_auth_for_request():
|
if not force_run and AuthorizationService.should_disable_auth_for_request():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not token and "Authorization" in request.headers:
|
if not token and "Authorization" in request.headers:
|
||||||
|
|
|
@ -202,7 +202,7 @@ class AuthorizationService:
|
||||||
@classmethod
|
@classmethod
|
||||||
def should_disable_auth_for_request(cls) -> bool:
|
def should_disable_auth_for_request(cls) -> bool:
|
||||||
"""Should_disable_auth_for_request."""
|
"""Should_disable_auth_for_request."""
|
||||||
authentication_exclusion_list = ["status"]
|
authentication_exclusion_list = ["status", "authentication_callback"]
|
||||||
if request.method == "OPTIONS":
|
if request.method == "OPTIONS":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ class TestProcessApi(BaseTest):
|
||||||
assert len(task_events) == 1
|
assert len(task_events) == 1
|
||||||
task_event = task_events[0]
|
task_event = task_events[0]
|
||||||
assert task_event.user_id == with_super_admin_user.id
|
assert task_event.user_id == with_super_admin_user.id
|
||||||
# TODO: When with_super_admin_user tasks work, we need to add some more assertions for action, task_state, etc.
|
# TODO: When user tasks work, we need to add some more assertions for action, task_state, etc.
|
||||||
|
|
||||||
def test_task_show(
|
def test_task_show(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in New Issue