feat(api tokens): add task attachment to api scopes
continuous-integration/drone/push Build is failing Details

This explicitly adds download and upload of task attachments. Because these are not handled with the usual CRUDables, they were not picked up automatically.

Resolves https://github.com/go-vikunja/vikunja/issues/112
This commit is contained in:
kolaente 2024-02-14 14:59:58 +01:00
parent ebe25ee2d7
commit 415c6380a5
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 16 additions and 1 deletions

View File

@ -69,7 +69,7 @@ func getRouteGroupName(path string) string {
// CollectRoutesForAPITokenUsage gets called for every added APITokenRoute and builds a list of all routes we can use for the api tokens.
func CollectRoutesForAPITokenUsage(route echo.Route) {
if !strings.Contains(route.Name, "(*WebHandler)") {
if !strings.Contains(route.Name, "(*WebHandler)") && !strings.Contains(route.Name, "Attachment") {
return
}
@ -116,6 +116,21 @@ func CollectRoutesForAPITokenUsage(route echo.Route) {
Method: route.Method,
}
}
if routeGroupName == "tasks_attachments" {
if strings.Contains(route.Name, "UploadTaskAttachment") {
apiTokenRoutes[routeGroupName].Create = &RouteDetail{
Path: route.Path,
Method: route.Method,
}
}
if strings.Contains(route.Name, "GetTaskAttachment") {
apiTokenRoutes[routeGroupName].ReadOne = &RouteDetail{
Path: route.Path,
Method: route.Method,
}
}
}
}
// GetAvailableAPIRoutesForToken returns a list of all API routes which are available for token usage.