Checkpoint commit - code does not yet rebuild. Migrating HasAccess() from Person to Authority
This commit is contained in:
@@ -147,6 +147,108 @@ namespace Swarmops.Logic.Security
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines if this Authority has a particular Access.
|
||||
/// </summary>
|
||||
/// <param name="access">The access desired.</param>
|
||||
/// <returns>True if access can be granted.</returns>
|
||||
public bool HasAccess(Access access)
|
||||
{
|
||||
if (access == null)
|
||||
{
|
||||
throw new ArgumentNullException("access", @"Access cannot be null, but must always be explicitly specified. Specify AccessAspect.Null if null access is desired.");
|
||||
}
|
||||
|
||||
if (access.Aspect == AccessAspect.Null)
|
||||
{
|
||||
// Null security (like Dashboard), so return true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for participant financials
|
||||
|
||||
if (access.Aspect == AccessAspect.Financials && access.Type == AccessType.Read)
|
||||
{
|
||||
if (access.Organization.ParticipantFinancialsEnabled)
|
||||
{
|
||||
// This organization has decided to open its financial reports to all participants. Reselect the access request to "participant" level.
|
||||
|
||||
access = new Access(access.Organization, AccessAspect.Participant);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Participant access level
|
||||
|
||||
if (access.Aspect == AccessAspect.Participant)
|
||||
{
|
||||
// Check that a membership (or whatever this org calls it) exists, for this org or a parentline org
|
||||
|
||||
if (Person.MemberOfWithInherited(access.Organization))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// if Open Ledgers, return true
|
||||
|
||||
if ((access.Aspect == AccessAspect.Bookkeeping || access.Aspect == AccessAspect.Financials) &&
|
||||
access.Type == AccessType.Read && this.Person.Identity == Swarm.Person.OpenLedgersIdentity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// We're at the end of generic access control - now, check against position assignments
|
||||
|
||||
// Check if the person is currently acting at sysadmin level
|
||||
|
||||
// TODO: CHECK POSITION ASSIGNMENT
|
||||
// for now, check if position assignment exists
|
||||
|
||||
// This is not very efficient, but there shouldn't be many system-level positions or
|
||||
// assignments, so it should scale reasonably even in an 1M organization
|
||||
|
||||
PositionAssignments assignments = Positions.ForSystem().Assignments;
|
||||
|
||||
foreach (PositionAssignment assignment in assignments)
|
||||
{
|
||||
if (assignment.Active && assignment.PersonId == this._data.PersonId)
|
||||
{
|
||||
if ((assignment.Position.PositionType == PositionType.System_SysadminMain ||
|
||||
assignment.Position.PositionType == PositionType.System_SysadminReadWrite))
|
||||
return true;
|
||||
|
||||
if (assignment.Position.PositionType == PositionType.System_SysadminAssistantReadOnly &&
|
||||
access.Type == AccessType.Read)
|
||||
{
|
||||
return true; // Read-only access
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If system-level access was requested and has not been granted at this point, deny it
|
||||
|
||||
if (access.Organization == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Organization-level or geography-level access requested
|
||||
|
||||
if (Assignment == null)
|
||||
{
|
||||
// No assignment to ask, therefore, no access
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ask the current position assignment if it has the requested access
|
||||
|
||||
return Assignment.Position.HasAccess(access);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public bool CanSeePerson (Person person)
|
||||
|
||||
@@ -11,19 +11,14 @@ namespace Swarmops.Logic.Swarm
|
||||
public class DashboardTodos : List<DashboardTodo>
|
||||
{
|
||||
public static DashboardTodos ForAuthority (Authority authority)
|
||||
{
|
||||
return ForPerson (authority.Person, authority.Organization); // TODO: Add actual assigned-position check here
|
||||
}
|
||||
|
||||
public static DashboardTodos ForPerson (Person person, Organization organization)
|
||||
{
|
||||
DashboardTodos result = new DashboardTodos();
|
||||
|
||||
result.AddExpenseClaimAttestations (person, organization);
|
||||
result.AddCashAdvanceAttestations (person, organization);
|
||||
result.AddExpenseClaimAttestations(authority);
|
||||
result.AddCashAdvanceAttestations(authority);
|
||||
//result.AddSalaryAttestations(person, organization); TODO!
|
||||
result.AddReceiptValidations (person, organization);
|
||||
result.AddPayouts (person, organization);
|
||||
result.AddReceiptValidations(authority);
|
||||
result.AddPayouts(authority);
|
||||
|
||||
// TODO: Add any hooks
|
||||
|
||||
@@ -31,14 +26,14 @@ namespace Swarmops.Logic.Swarm
|
||||
}
|
||||
|
||||
|
||||
private void AddReceiptValidations (Person person, Organization organization)
|
||||
private void AddReceiptValidations (Authority authority)
|
||||
{
|
||||
if (!person.HasAccess (new Access (organization, AccessAspect.Financials, AccessType.Write)))
|
||||
if (!authority.HasAccess (new Access (authority.Organization, AccessAspect.Financials, AccessType.Write)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization (organization);
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization (authority.Organization);
|
||||
claims = claims.WhereUnvalidated;
|
||||
|
||||
if (claims.Count == 0)
|
||||
@@ -69,14 +64,14 @@ namespace Swarmops.Logic.Swarm
|
||||
// TODO: Refactor the attest-X functions into one function with minimal differences
|
||||
|
||||
|
||||
private void AddExpenseClaimAttestations (Person person, Organization organization)
|
||||
private void AddExpenseClaimAttestations (Authority authority)
|
||||
{
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization (organization);
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization (authority.Organization);
|
||||
List<int> expenseClaimIds = new List<int>();
|
||||
|
||||
bool isPersonOrgAdmin = false;
|
||||
|
||||
if (person.Identity == 1)
|
||||
if (authority.Person.Identity == 1)
|
||||
{
|
||||
isPersonOrgAdmin = true; // TODO: Make more advanced, obviously
|
||||
}
|
||||
@@ -94,7 +89,7 @@ namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
attestable = true;
|
||||
}
|
||||
else if (claim.Budget.OwnerPersonId == person.Identity)
|
||||
else if (claim.Budget.OwnerPersonId == authority.Person.Identity)
|
||||
{
|
||||
attestable = true;
|
||||
}
|
||||
@@ -127,14 +122,14 @@ namespace Swarmops.Logic.Swarm
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCashAdvanceAttestations (Person person, Organization organization)
|
||||
private void AddCashAdvanceAttestations (Authority authority)
|
||||
{
|
||||
CashAdvances advances = CashAdvances.ForOrganization (organization);
|
||||
CashAdvances advances = CashAdvances.ForOrganization (authority.Organization);
|
||||
List<int> cashAdvanceIds = new List<int>();
|
||||
|
||||
bool isPersonOrgAdmin = false;
|
||||
|
||||
if (person.Identity == 1)
|
||||
if (authority.Person.Identity == 1)
|
||||
{
|
||||
isPersonOrgAdmin = true; // TODO: Make more advanced, obviously
|
||||
}
|
||||
@@ -152,7 +147,7 @@ namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
attestable = true;
|
||||
}
|
||||
else if (advance.Budget.OwnerPersonId == person.Identity)
|
||||
else if (advance.Budget.OwnerPersonId == authority.Person.Identity)
|
||||
{
|
||||
attestable = true;
|
||||
}
|
||||
@@ -186,9 +181,9 @@ namespace Swarmops.Logic.Swarm
|
||||
}
|
||||
}
|
||||
|
||||
private void AddPayouts (Person person, Organization organization)
|
||||
private void AddPayouts (Authority authority)
|
||||
{
|
||||
if (!person.HasAccess (new Access (organization, AccessAspect.Financials, AccessType.Write)))
|
||||
if (!authority.HasAccess (new Access (authority.Organization, AccessAspect.Financials, AccessType.Write)))
|
||||
{
|
||||
return; // do not add this if can't pay out
|
||||
}
|
||||
@@ -209,7 +204,7 @@ namespace Swarmops.Logic.Swarm
|
||||
int urgentPayoutCount = 0;
|
||||
int overduePayoutCount = 0;
|
||||
|
||||
Payouts payouts = Payouts.Construct (organization);
|
||||
Payouts payouts = Payouts.Construct (authority.Organization);
|
||||
|
||||
foreach (Payout payout in payouts)
|
||||
{
|
||||
|
||||
@@ -1131,87 +1131,6 @@ namespace Swarmops.Logic.Swarm
|
||||
get { return PositionAssignments.ForPerson (this); }
|
||||
}
|
||||
|
||||
public bool HasAccess (Access access)
|
||||
{
|
||||
if (access == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// TEMPORARY access control lists
|
||||
|
||||
// TODO: Build access control list from org chart, compare against required access
|
||||
|
||||
string ids = string.Empty;
|
||||
|
||||
if (access.Aspect == AccessAspect.Null)
|
||||
{
|
||||
// Null security (like Dashboard), so return true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (access.Aspect == AccessAspect.Financials && access.Type == AccessType.Read)
|
||||
{
|
||||
if (access.Organization.ParticipantFinancialsEnabled)
|
||||
{
|
||||
// This organization has decided to open its financial reports to all participants. Reselect the access request to "participant" level.
|
||||
|
||||
access = new Access (access.Organization, AccessAspect.Participant);
|
||||
}
|
||||
}
|
||||
|
||||
if (access.Aspect == AccessAspect.Participant)
|
||||
{
|
||||
// Check that a membership (or whatever this org calls it) exists, for this org or a parentline org
|
||||
|
||||
if (this.MemberOfWithInherited (access.Organization))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// if Open Ledgers
|
||||
|
||||
if ((access.Aspect == AccessAspect.Bookkeeping || access.Aspect == AccessAspect.Financials) &&
|
||||
access.Type == AccessType.Read && this.Identity == Person.OpenLedgersIdentity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ENTERING TEMPORARY TERRITORY HERE, UNTIL REAL ACCESS COMPLETED
|
||||
|
||||
if (access.Organization == null)
|
||||
{
|
||||
access = new Access (Organization.FromIdentity (1), access.Aspect, access.Type);
|
||||
}
|
||||
|
||||
|
||||
if (access.Type == AccessType.Write)
|
||||
{
|
||||
ids = access.Organization.Parameters.TemporaryAccessListWrite;
|
||||
}
|
||||
else if (access.Type == AccessType.Read)
|
||||
{
|
||||
ids = access.Organization.Parameters.TemporaryAccessListWrite + " " +
|
||||
access.Organization.Parameters.TemporaryAccessListRead; // Write access implies read access
|
||||
}
|
||||
|
||||
|
||||
List<string> resultingPeople = new List<string>();
|
||||
string[] idStrings = ids.Trim().Replace (" ", " ").Split (' ');
|
||||
|
||||
foreach (string idString in idStrings)
|
||||
{
|
||||
if (Int32.Parse (idString) == Identity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public PositionAssignment GetPrimaryAssignment (Organization organization)
|
||||
{
|
||||
PositionAssignments personAssignments = PositionAssignments.ForPerson (this);
|
||||
|
||||
@@ -9,6 +9,7 @@ using Swarmops.Common.Enums;
|
||||
using Swarmops.Common.Generics;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Resources;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
|
||||
namespace Swarmops.Logic.Swarm
|
||||
@@ -170,5 +171,18 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
return Logic_Swarm_Position.ResourceManager.GetString("Position_" + titleString);
|
||||
}
|
||||
|
||||
|
||||
public bool HasAccess(Access access)
|
||||
{
|
||||
// TODO TODO TODO
|
||||
|
||||
if (access == null)
|
||||
{
|
||||
throw new ArgumentNullException ("access", @"Access requested must always be specified. Use AccessAspect.Null if null access is desired (and access should always be true).");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using NBitcoin;
|
||||
using Swarmops.Basic.Types.Swarm;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
|
||||
namespace Swarmops.Logic.Swarm
|
||||
@@ -112,5 +113,6 @@ namespace Swarmops.Logic.Swarm
|
||||
base.TerminationNotes = terminationNotes;
|
||||
base.TerminatedDateTimeUtc = DateTime.UtcNow; // may differ by milliseconds from actual value set, but shouldn't matter for practical purposes
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class DataV5Base : Page
|
||||
|
||||
if (this.PageAccessRequired != null)
|
||||
{
|
||||
if (!CurrentUser.HasAccess (this.PageAccessRequired))
|
||||
if (!this.CurrentAuthority.HasAccess (this.PageAccessRequired))
|
||||
{
|
||||
Response.Redirect ("/Pages/v5/Security/AccessDenied.aspx");
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class PageV5Base : Page
|
||||
|
||||
// Check security of page against users's credentials
|
||||
|
||||
if (!CurrentUser.HasAccess (this.PageAccessRequired))
|
||||
if (!this.CurrentAuthority.HasAccess (this.PageAccessRequired))
|
||||
{
|
||||
Response.Redirect ("/Pages/v5/Security/AccessDenied.aspx");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Swarmops.Frontend.Automation
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
if (!authData.CurrentUser.HasAccess (new Access (AccessAspect.Administration)))
|
||||
if (!authData.Authority.HasAccess (new Access (AccessAspect.Administration)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace Swarmops.Frontend.Automation
|
||||
|
||||
if (assignment.OrganizationId == 0)
|
||||
{
|
||||
if (!authData.CurrentUser.HasAccess (new Access (AccessAspect.Administration))) // System-wide admin
|
||||
if (!authData.Authority.HasAccess (new Access (AccessAspect.Administration))) // System-wide admin
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace Swarmops.Frontend.Automation
|
||||
{
|
||||
if (assignment.GeographyId == 0)
|
||||
{
|
||||
if (!authData.CurrentUser.HasAccess (new Access(authData.CurrentOrganization, AccessAspect.Administration)))
|
||||
if (!authData.Authority.HasAccess (new Access(authData.CurrentOrganization, AccessAspect.Administration)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Swarmops.Frontend.Automation
|
||||
else // Org- and geo-specific assignment
|
||||
{
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
assignment.Position.Geography, AccessAspect.Administration)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
|
||||
@@ -55,14 +55,12 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
|
||||
|
||||
if (!PilotInstallationIds.IsPilot (PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached)
|
||||
{
|
||||
// throw new UnauthorizedAccessException("This may only run on Swarmops Master");
|
||||
throw new UnauthorizedAccessException("This may only run on Swarmops Master");
|
||||
}
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown,
|
||||
AccessType.Write)))
|
||||
if (!authData.Authority.HasAccess (new Access (AccessAspect.Administration)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -59,9 +59,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown,
|
||||
AccessType.Write)))
|
||||
if (!authData.Authority.HasAccess (new Access (AccessAspect.Administration)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown,
|
||||
AccessType.Write)))
|
||||
!authData.Authority.HasAccess (new Access (AccessAspect.Administration)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
AjaxTextBox.CallbackResult result = new AjaxTextBox.CallbackResult();
|
||||
AuthenticationData authenticationData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (!authenticationData.CurrentUser.HasAccess (new Access (authenticationData.CurrentOrganization, AccessAspect.Administration, AccessType.Write)))
|
||||
if (!authenticationData.Authority.HasAccess (new Access (authenticationData.CurrentOrganization, AccessAspect.Administration, AccessType.Write)))
|
||||
{
|
||||
result.ResultCode = AjaxTextBox.CodeNoPermission;
|
||||
return result;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
AjaxTextBox.CallbackResult result = new AjaxTextBox.CallbackResult();
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (!authData.CurrentUser.HasAccess (new Access (AccessAspect.System, AccessType.Write)))
|
||||
if (!authData.Authority.HasAccess (new Access (AccessAspect.Administration, AccessType.Write)))
|
||||
{
|
||||
result.ResultCode = AjaxTextBox.CodeNoPermission;
|
||||
return result; // fail silently
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
this._attestationRights = GetAttestationRights();
|
||||
this._documentList = new List<RepeatedDocument>();
|
||||
this.LiteralCanOverdraftBudgets.Text =
|
||||
CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Administration)).ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
|
||||
CurrentAuthority.HasAccess (new Access (CurrentOrganization, AccessAspect.Administration)).ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
|
||||
|
||||
PopulateInboundInvoices();
|
||||
PopulateExpenses();
|
||||
@@ -72,7 +72,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
foreach (FinancialAccount account in accounts)
|
||||
{
|
||||
if (account.OwnerPersonId == authData.CurrentUser.Identity ||
|
||||
(account.OwnerPersonId == 0 && authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Administration))))
|
||||
(account.OwnerPersonId == 0 && authData.Authority.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Administration))))
|
||||
{
|
||||
result[account.Identity] = true;
|
||||
}
|
||||
@@ -547,7 +547,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
if (amountCents > budgetRemaining)
|
||||
{
|
||||
if (
|
||||
authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.Administration)))
|
||||
{
|
||||
// Admin rights, so allow (forced) overdraft
|
||||
|
||||
@@ -7,7 +7,7 @@ public partial class Pages_v5_Finance_Json_ValidatableReceipts : DataV5Base
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
if (!CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Financials, AccessType.Read)))
|
||||
if (!CurrentAuthority.HasAccess (new Access (CurrentOrganization, AccessAspect.Financials, AccessType.Read)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ namespace Swarmops.Frontend.Pages.Financial
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Financials,
|
||||
AccessType.Write)))
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Financials, AccessType.Write)))
|
||||
{
|
||||
throw new SecurityAccessDeniedException ("Insufficient privileges for operation");
|
||||
}
|
||||
@@ -92,7 +91,7 @@ namespace Swarmops.Frontend.Pages.Financial
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.Financials)))
|
||||
!authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.Financials)))
|
||||
{
|
||||
throw new SecurityAccessDeniedException("Insufficient privileges for operation");
|
||||
}
|
||||
|
||||
@@ -132,9 +132,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
throw new InvalidOperationException ("Called to attest out-of-org line item");
|
||||
}
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.Financials,
|
||||
AccessType.Write)))
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.Financials, AccessType.Write)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.BookkeepingDetails)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
@@ -139,7 +139,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess(new Access(authData.CurrentOrganization,
|
||||
AccessAspect.BookkeepingDetails)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
@@ -168,7 +168,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess(new Access(authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess(new Access(authData.CurrentOrganization,
|
||||
AccessAspect.BookkeepingDetails)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
// if write access
|
||||
|
||||
if (
|
||||
CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails,
|
||||
CurrentAuthority.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails,
|
||||
AccessType.Write)))
|
||||
{
|
||||
LiteralEditHeader.Text = Resources.Pages.Ledgers.InspectLedgers_EditingTransactionX;
|
||||
@@ -111,16 +111,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
// Access helpers to JavaScript (these don't actually determine access, but help in UI prettiness)
|
||||
|
||||
this.LiteralAuditAccess.Text =
|
||||
(CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Auditing, AccessType.Write)))
|
||||
(CurrentAuthority.HasAccess (new Access (CurrentOrganization, AccessAspect.Auditing, AccessType.Write)))
|
||||
? "true"
|
||||
: "false";
|
||||
this.LiteralWriteAccess.Text =
|
||||
(CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write)))
|
||||
(CurrentAuthority.HasAccess(new Access(CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Write)))
|
||||
? "true"
|
||||
: "false";
|
||||
this.LiteralDetailAccess.Text =
|
||||
(CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails,
|
||||
AccessType.Read)))
|
||||
(CurrentAuthority.HasAccess(new Access(CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read)))
|
||||
? "true"
|
||||
: "false";
|
||||
|
||||
@@ -133,7 +132,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.Bookkeeping, AccessType.Write)))
|
||||
{
|
||||
return false; // fail
|
||||
@@ -172,7 +171,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.Bookkeeping, AccessType.Read)))
|
||||
{
|
||||
return string.Empty; // leave no clue to an attacker why the call failed
|
||||
@@ -189,7 +188,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization,
|
||||
!authData.Authority.HasAccess (new Access (authData.CurrentOrganization,
|
||||
AccessAspect.BookkeepingDetails, AccessType.Read)))
|
||||
{
|
||||
return string.Empty; // leave no clue to an attacker why the call failed
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
this._year = DateTime.Today.Year;
|
||||
|
||||
if (
|
||||
!this._authenticationData.CurrentUser.HasAccess (new Access (
|
||||
this._authenticationData.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
|
||||
!this._authenticationData.CurrentUser.PositionAssignment.HasAccess (new Access (
|
||||
this._authenticationData.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read), this._authenticationData.CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
throw new UnauthorizedAccessException ("All the nopes in the world");
|
||||
}
|
||||
|
||||
if (!CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
|
||||
if (!CurrentUser.PositionAssignment.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read), CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException ("Access denied because security tokens say so");
|
||||
}
|
||||
@@ -55,8 +55,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
DateTime balanceStart = dawnOfMankind;
|
||||
bool zeroStart = false;
|
||||
bool zeroEnd = false;
|
||||
bool displayDescription = CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read));
|
||||
bool canSeeAudit = CurrentUser.HasAccess(new Access(CurrentOrganization, AccessAspect.Auditing, AccessType.Read));
|
||||
bool displayDescription = CurrentUser.PositionAssignment.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read), CurrentUser);
|
||||
bool canSeeAudit = CurrentUser.PositionAssignment.HasAccess(new Access(CurrentOrganization, AccessAspect.Auditing, AccessType.Read), CurrentUser);
|
||||
|
||||
if (month > 0 && month <= 12)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
throw new UnauthorizedAccessException ("All the nopes in the world");
|
||||
}
|
||||
|
||||
if (!CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
|
||||
if (!CurrentUser.PositionAssignment.HasAccess (new Access (CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read), CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException ("Access denied because security tokens say so");
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
(ExternalBankDataProfile) Session["LedgersResync" + guid + "Profile"];
|
||||
|
||||
if (
|
||||
!this._authenticationData.CurrentUser.HasAccess (new Access (
|
||||
this._authenticationData.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read)))
|
||||
!this._authenticationData.CurrentUser.PositionAssignment.HasAccess (new Access (
|
||||
this._authenticationData.CurrentOrganization, AccessAspect.Bookkeeping, AccessType.Read), this._authenticationData.CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
List<string> rows = new List<string>();
|
||||
|
||||
if (
|
||||
CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read)))
|
||||
CurrentUser.PositionAssignment.HasAccess (new Access (CurrentOrganization, AccessAspect.BookkeepingDetails, AccessType.Read), CurrentUser))
|
||||
{
|
||||
foreach (FinancialTransaction transaction in unbalancedTransactions)
|
||||
{
|
||||
|
||||
@@ -156,8 +156,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
FinancialAccount account = FinancialAccount.FromIdentity (accountId);
|
||||
|
||||
if (account.Organization.Identity != authData.CurrentOrganization.Identity ||
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Bookkeeping,
|
||||
AccessType.Write)))
|
||||
!authData.CurrentUser.PositionAssignment.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Bookkeeping,
|
||||
AccessType.Write), authData.CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
@@ -177,8 +177,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
AuthenticationData authenticationData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authenticationData.CurrentUser.HasAccess (new Access (authenticationData.CurrentOrganization,
|
||||
AccessAspect.Bookkeeping, AccessType.Write)))
|
||||
!authenticationData.CurrentUser.PositionAssignment.HasAccess (new Access (authenticationData.CurrentOrganization,
|
||||
AccessAspect.Bookkeeping, AccessType.Write), authenticationData.CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -229,8 +229,8 @@ namespace Swarmops.Site.Pages.Ledgers
|
||||
FinancialAccount account = FinancialAccount.FromIdentity (accountId);
|
||||
|
||||
if (account.Organization.Identity != authData.CurrentOrganization.Identity ||
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Bookkeeping,
|
||||
AccessType.Write)))
|
||||
!authData.CurrentUser.PositionAssignment.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Bookkeeping,
|
||||
AccessType.Write), authData.CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ namespace Swarmops.Pages.v5.Support
|
||||
// TODO: Security leak - check CurrentOrganization against Document's org
|
||||
|
||||
if (
|
||||
CurrentUser.HasAccess (new Access (CurrentOrganization, AccessAspect.Financials,
|
||||
AccessType.Write)))
|
||||
CurrentUser.PositionAssignment.HasAccess (new Access (CurrentOrganization, AccessAspect.Financials,
|
||||
AccessType.Write), CurrentUser))
|
||||
{
|
||||
hasPermission = true;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace Swarmops.Frontend.Pages.Swarm
|
||||
Geography geography = Geography.FromIdentity (geographyId);
|
||||
|
||||
if (
|
||||
!CurrentUser.HasAccess (new Access (CurrentOrganization, geography, AccessAspect.PersonalData,
|
||||
AccessType.Read)))
|
||||
!CurrentUser.PositionAssignment.HasAccess (new Access (CurrentOrganization, geography, AccessAspect.PersonalData,
|
||||
AccessType.Read), CurrentUser))
|
||||
{
|
||||
throw new UnauthorizedAccessException ("nope");
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace Swarmops.Frontend.Pages.Swarm
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Financials,
|
||||
AccessType.Write)))
|
||||
!authData.CurrentUser.PositionAssignment.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Financials,
|
||||
AccessType.Write), authData.CurrentUser))
|
||||
{
|
||||
throw new SecurityAccessDeniedException ("Insufficient privileges for operation");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user