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

Add oauth with role on workflow endpoints #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions api/Controllers/Models/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class Role
private const string ReadOnlyRole = "Role.ReadOnly";
private const string UserRole = "Role.User";
private const string AdminRole = "Role.Admin";
private const string WorkflowStatusWriteRole = "WorkflowStatus.Write";

/// <summary>
/// The user must be an admin
Expand All @@ -25,4 +26,9 @@ public class Role
public const string Any = $"{ReadOnlyRole}, {UserRole}, {Admin}";

public const string InspectionDataRead = "InspectionData.Read";

/// <summary>
/// Role required to update workflow statuses
/// </summary>
public const string WorkflowStatusWrite = WorkflowStatusWriteRole;
}
4 changes: 2 additions & 2 deletions api/Controllers/WorkflowsControlller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class WorkflowsController(IInspectionDataService inspectionDataService) :
/// Updates status of inspection data to started
/// </summary>
[HttpPut]
[AllowAnonymous] // TODO: Implement role for notifying and machine-to-machine oauth
[Authorize(Roles = Role.WorkflowStatusWrite)]
[Route("notify-workflow-started")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
Expand All @@ -45,7 +45,7 @@ public async Task<ActionResult<InspectionDataResponse>> WorkflowStarted([FromBod
/// Updates status of inspection data to exit with success or failure
/// </summary>
[HttpPut]
[AllowAnonymous] // TODO: Implement role for notifying and machine-to-machine oauth
[Authorize(Roles = Role.WorkflowStatusWrite)]
[Route("notify-workflow-exited")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
Expand Down
Loading