mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
add user role Download; limit access check to scenario in file middleware #52
This commit is contained in:
parent
2f6f942749
commit
f3d6353f86
2 changed files with 19 additions and 3 deletions
|
@ -112,6 +112,19 @@ var Roles = RoleActions{
|
|||
ModelFile: _r__,
|
||||
ModelResult: none,
|
||||
},
|
||||
"Download": {
|
||||
ModelScenario: none,
|
||||
ModelComponentConfiguration: none,
|
||||
ModelDashboard: none,
|
||||
ModelWidget: none,
|
||||
ModelInfrastructureComponent: none,
|
||||
ModelInfrastructureComponentAction: none,
|
||||
ModelUser: none,
|
||||
ModelUsers: none,
|
||||
ModelSignal: none,
|
||||
ModelFile: _r__,
|
||||
ModelResult: none,
|
||||
},
|
||||
}
|
||||
|
||||
func ValidateRole(c *gin.Context, model ModelName, action CRUD) error {
|
||||
|
|
|
@ -49,9 +49,12 @@ func CheckPermissions(c *gin.Context, operation database.CRUD) (bool, File) {
|
|||
return false, f
|
||||
}
|
||||
|
||||
ok, _ := scenario.CheckPermissions(c, operation, "body", int(f.ScenarioID))
|
||||
if !ok {
|
||||
return false, f
|
||||
if operation != database.Read {
|
||||
// check access to scenario only if operation is not Read (=download) of file
|
||||
ok, _ := scenario.CheckPermissions(c, operation, "body", int(f.ScenarioID))
|
||||
if !ok {
|
||||
return false, f
|
||||
}
|
||||
}
|
||||
|
||||
return true, f
|
||||
|
|
Loading…
Add table
Reference in a new issue