Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/02/18 20:19:43 (7 years ago)
Author:
jzenisek
Message:

#2839 improved permission checking of HiveService methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r15628 r15715  
    3737    private const string NOT_AUTHORIZED_USERJOB = "Current user is not authorized to access the requested job";
    3838    private const string NOT_AUTHORIZED_PROJECTRESOURCE = "Selected project is not authorized to access the requested resource";
     39    private const string USER_NOT_IDENTIFIED = "User could not be identified";
     40    private const string TASK_NOT_EXISTENT = "Queried task could not be found";
    3941
    4042    private IPersistenceManager PersistenceManager {
     
    6163      pm.UseTransaction(() => {
    6264        var task = taskDao.GetById(taskId);
    63         if (task == null) throw new SecurityException(NOT_AUTHORIZED_USERRESOURCE);
     65        if (task == null) throw new SecurityException(TASK_NOT_EXISTENT);
    6466        AuthorizeJob(pm, task.JobId, requiredPermission);
    6567      });
     
    151153    // note: administrators and project owner are NOT automatically granted
    152154    public void AuthorizeUserForProjectUse(Guid userId, Guid projectId) {
    153       if (userId == null || projectId == null) return;
     155      if(userId == null || userId == Guid.Empty) {
     156        throw new SecurityException(USER_NOT_IDENTIFIED);
     157      }
     158      if(projectId == null) return;
     159
    154160      var pm = PersistenceManager;
    155161      // collect current and group membership Ids
Note: See TracChangeset for help on using the changeset viewer.