Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BlobApi
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
apis
BlobApi
Commits
807a0794
Commit
807a0794
authored
2 years ago
by
Petar Hristov
Browse files
Options
Downloads
Patches
Plain Diff
Fix
parent
d1a76444
No related branches found
No related tags found
1 merge request
!80
New: Added Guest Role
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Blob/Controllers/BlobController.cs
+16
-24
16 additions, 24 deletions
src/Blob/Controllers/BlobController.cs
with
16 additions
and
24 deletions
src/Blob/Controllers/BlobController.cs
+
16
−
24
View file @
807a0794
...
...
@@ -120,11 +120,14 @@ namespace Coscine.Api.Blob.Controllers
{
return
checkResourceId
;
}
var
checkUser
=
CheckUser
(
user
,
resource
);
if
(
checkUser
!=
null
)
// Rights Matrix (https://git.rwth-aachen.de/coscine/docs/private/internal-wiki/-/blob/master/coscine/Definition%20of%20rights%20Matrix.md)
// - Resource: View Resource (RCV, Metadatamanager)
if
(
user
is
null
||
!
_resourceModel
.
HasAccess
(
user
,
resource
,
UserRoles
.
Owner
,
UserRoles
.
Member
,
UserRoles
.
Guest
))
{
return
checkUser
;
return
Forbid
(
"User does not have permission to download files from the resource."
)
;
}
try
{
var
resourceTypeDefinition
=
ResourceTypeFactory
.
Instance
.
GetResourceType
(
resource
);
...
...
@@ -204,10 +207,12 @@ namespace Coscine.Api.Blob.Controllers
{
return
checkResourceId
;
}
var
checkUser
=
CheckUser
(
user
,
resource
);
if
(
checkUser
!=
null
)
// Rights Matrix (https://git.rwth-aachen.de/coscine/docs/private/internal-wiki/-/blob/master/coscine/Definition%20of%20rights%20Matrix.md)
// - Resource: Change Resource (RCV, Metadatamanager)
if
(
user
is
null
||
!
_resourceModel
.
HasAccess
(
user
,
resource
,
UserRoles
.
Owner
,
UserRoles
.
Member
))
{
return
checkUser
;
return
Forbid
(
"User does not have permission to upload files in the resource."
)
;
}
if
(
resource
.
Archived
==
"1"
)
...
...
@@ -306,10 +311,12 @@ namespace Coscine.Api.Blob.Controllers
{
return
checkResourceId
;
}
var
checkUser
=
CheckUser
(
user
,
resource
);
if
(
checkUser
!=
null
)
// Rights Matrix (https://git.rwth-aachen.de/coscine/docs/private/internal-wiki/-/blob/master/coscine/Definition%20of%20rights%20Matrix.md)
// - Resource: Change Resource (RCV, Metadatamanager)
if
(
user
is
null
||
!
_resourceModel
.
HasAccess
(
user
,
resource
,
UserRoles
.
Owner
,
UserRoles
.
Member
))
{
return
checkUser
;
return
Forbid
(
"User does not have permission to delete from the resource."
)
;
}
if
(
resource
.
Archived
==
"1"
)
...
...
@@ -395,21 +402,6 @@ namespace Coscine.Api.Blob.Controllers
return
null
;
}
/// <summary>
/// Checks if the user has access to the resource
/// </summary>
/// <param name="user">user</param>
/// <param name="resource">resource</param>
/// <returns>status code 403 if the user has no access</returns>
public
IActionResult
CheckUser
(
User
user
,
Resource
resource
)
{
if
(
user
==
null
||
!
_resourceModel
.
HasAccess
(
user
,
resource
,
UserRoles
.
Owner
,
UserRoles
.
Member
))
{
return
Forbid
(
"User does not have permission to the resource."
);
}
return
null
;
}
/// <summary>
/// Writes an analytics log entry
/// </summary>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment