Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/25/09 13:56:49 (15 years ago)
Author:
mbecirov
Message:

#586: Fixed authorization when no policy scope is defined.

Location:
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Authorization
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Authorization/HivePermissionManager.cs

    r2093 r2100  
    4141    /// <param name="entityID">Entity ID can be some resource or emtpy.</param>
    4242    public void Authorize(string policyName, Guid sessionID, Guid entityID) {
     43      #region Use authorization method with scopes
    4344      //check if this policy has a permission with 'ANY' scope defined
    4445      Permission p = policyCollection[policyName].GetPermissionByContext("Any");
    45      
    4646      //check if user has 'xxx.Any' permission
    4747      if (p != null)
     
    5959      //check if this policy has a permission with 'OWNER' scope defined
    6060      p = policyCollection[policyName].GetPermissionByContext("User");
     61     
    6162      //check if user has 'xxx.Owner' permission
    6263      if (p != null)
    6364        if (CheckPermission(sessionID, p.Id, jobManager.GetJobById(entityID).Obj.UserId)) return;
    64 
     65      #endregion
     66      #region Use authorization method when no scopes are present
     67      //when no permission context is available, use primary authentification
     68      foreach (KeyValuePair<Permission, PermissionContext> item in policyCollection[policyName].Permissions)
     69      {
     70          if (CheckPermission(sessionID, item.Key.Id, Guid.Empty)) return;
     71      }
     72      #endregion
    6573      //throw an exception when user access fails
    66       //throw new PermissionException(policyName);
     74      throw new PermissionException(policyName);
    6775    }
    6876
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Authorization/Policy.cs

    r2065 r2100  
    2828      return null;
    2929    }
     30
    3031  }
    3132}
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Authorization/PolicyCollection.cs

    r2065 r2100  
    33using System.Linq;
    44using System.Text;
     5using System.Collections;
    56
    67namespace HeuristicLab.Hive.Server.Core {
     
    2425    }
    2526
    26     System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
    27       return this._policies.GetEnumerator();
     27    #region IEnumerable Members
     28
     29    IEnumerator IEnumerable.GetEnumerator()
     30    {
     31        return this._policies.GetEnumerator();
    2832    }
     33
     34    #endregion
    2935  }
    3036}
Note: See TracChangeset for help on using the changeset viewer.