diff --git a/Logic/Security/Authority.cs b/Logic/Security/Authority.cs
index 6eddf8f3..29c43d31 100644
--- a/Logic/Security/Authority.cs
+++ b/Logic/Security/Authority.cs
@@ -147,6 +147,108 @@ namespace Swarmops.Logic.Security
+ ///
+ /// Determines if this Authority has a particular Access.
+ ///
+ /// The access desired.
+ /// True if access can be granted.
+ 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)
diff --git a/Logic/Swarm/DashboardTodos.cs b/Logic/Swarm/DashboardTodos.cs
index d7ed1ce1..354dbbcc 100644
--- a/Logic/Swarm/DashboardTodos.cs
+++ b/Logic/Swarm/DashboardTodos.cs
@@ -11,19 +11,14 @@ namespace Swarmops.Logic.Swarm
public class DashboardTodos : List
{
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 expenseClaimIds = new List();
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 cashAdvanceIds = new List();
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)
{
diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs
index 191a79a1..d880caff 100644
--- a/Logic/Swarm/Person.cs
+++ b/Logic/Swarm/Person.cs
@@ -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 resultingPeople = new List();
- 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);
diff --git a/Logic/Swarm/Position.cs b/Logic/Swarm/Position.cs
index d924786d..693f2a1c 100644
--- a/Logic/Swarm/Position.cs
+++ b/Logic/Swarm/Position.cs
@@ -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;
+ }
}
}
diff --git a/Logic/Swarm/PositionAssignment.cs b/Logic/Swarm/PositionAssignment.cs
index 18e0e84d..42d59542 100644
--- a/Logic/Swarm/PositionAssignment.cs
+++ b/Logic/Swarm/PositionAssignment.cs
@@ -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
}
+
}
}
diff --git a/Site5/App_Code/DataV5Base.cs b/Site5/App_Code/DataV5Base.cs
index 9eb2b639..e197898b 100644
--- a/Site5/App_Code/DataV5Base.cs
+++ b/Site5/App_Code/DataV5Base.cs
@@ -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");
}
diff --git a/Site5/App_Code/PageV5Base.cs b/Site5/App_Code/PageV5Base.cs
index a9d296c5..33f10eb1 100644
--- a/Site5/App_Code/PageV5Base.cs
+++ b/Site5/App_Code/PageV5Base.cs
@@ -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");
}
diff --git a/Site5/Automation/SwarmFunctions.aspx.cs b/Site5/Automation/SwarmFunctions.aspx.cs
index 745eab9d..df6937d1 100644
--- a/Site5/Automation/SwarmFunctions.aspx.cs
+++ b/Site5/Automation/SwarmFunctions.aspx.cs
@@ -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();
diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs
index 002329e1..b6efdb0c 100644
--- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs
+++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs
index c17a12c1..e931c610 100644
--- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs
+++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs
index 76a1cc20..0a78f902 100644
--- a/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs
+++ b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Admin/OrgSettings.aspx.cs b/Site5/Pages/v5/Admin/OrgSettings.aspx.cs
index 60d48478..2a38490f 100644
--- a/Site5/Pages/v5/Admin/OrgSettings.aspx.cs
+++ b/Site5/Pages/v5/Admin/OrgSettings.aspx.cs
@@ -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;
diff --git a/Site5/Pages/v5/Admin/SystemSettings.aspx.cs b/Site5/Pages/v5/Admin/SystemSettings.aspx.cs
index 0270dca0..a3767f9c 100644
--- a/Site5/Pages/v5/Admin/SystemSettings.aspx.cs
+++ b/Site5/Pages/v5/Admin/SystemSettings.aspx.cs
@@ -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
diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs
index 6c7e6d2b..b1e6b789 100644
--- a/Site5/Pages/v5/Financial/AttestCosts.aspx.cs
+++ b/Site5/Pages/v5/Financial/AttestCosts.aspx.cs
@@ -45,7 +45,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this._attestationRights = GetAttestationRights();
this._documentList = new List();
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
diff --git a/Site5/Pages/v5/Financial/Json-ValidatableReceipts.aspx.cs b/Site5/Pages/v5/Financial/Json-ValidatableReceipts.aspx.cs
index f6ba0dea..b77c3c50 100644
--- a/Site5/Pages/v5/Financial/Json-ValidatableReceipts.aspx.cs
+++ b/Site5/Pages/v5/Financial/Json-ValidatableReceipts.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs b/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs
index 182f01fa..69dfa81c 100644
--- a/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs
+++ b/Site5/Pages/v5/Financial/PayOutMoney.aspx.cs
@@ -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");
}
diff --git a/Site5/Pages/v5/Financial/ValidateReceipts.aspx.cs b/Site5/Pages/v5/Financial/ValidateReceipts.aspx.cs
index f9ac622f..0fbfca3e 100644
--- a/Site5/Pages/v5/Financial/ValidateReceipts.aspx.cs
+++ b/Site5/Pages/v5/Financial/ValidateReceipts.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs b/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs
index fc1b7470..f5ea2d23 100644
--- a/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/BalanceTransactions.aspx.cs
@@ -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();
diff --git a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs
index 383887f2..813c31d2 100644
--- a/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/InspectLedgers.aspx.cs
@@ -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
diff --git a/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs
index 64663e68..c1c51ee6 100644
--- a/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs
index af371648..0e2b6117 100644
--- a/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/Json-InspectLedgerData.aspx.cs
@@ -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)
{
diff --git a/Site5/Pages/v5/Ledgers/Json-InspectLedgerTxData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-InspectLedgerTxData.aspx.cs
index d11d6eac..1b3fcff0 100644
--- a/Site5/Pages/v5/Ledgers/Json-InspectLedgerTxData.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/Json-InspectLedgerTxData.aspx.cs
@@ -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");
}
diff --git a/Site5/Pages/v5/Ledgers/Json-ResyncPreview.aspx.cs b/Site5/Pages/v5/Ledgers/Json-ResyncPreview.aspx.cs
index 6ad02ef4..3e113d43 100644
--- a/Site5/Pages/v5/Ledgers/Json-ResyncPreview.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/Json-ResyncPreview.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Ledgers/Json-UnbalancedTransactions.aspx.cs b/Site5/Pages/v5/Ledgers/Json-UnbalancedTransactions.aspx.cs
index 0085947a..0139e3e1 100644
--- a/Site5/Pages/v5/Ledgers/Json-UnbalancedTransactions.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/Json-UnbalancedTransactions.aspx.cs
@@ -15,7 +15,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
List rows = new List();
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)
{
diff --git a/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs b/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs
index 736a3c76..93c5a1ce 100644
--- a/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs
index 0fc438db..4e69d45e 100644
--- a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs
+++ b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs
@@ -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();
}
diff --git a/Site5/Pages/v5/Support/StreamUpload.aspx.cs b/Site5/Pages/v5/Support/StreamUpload.aspx.cs
index 7fac095d..8f04ebe6 100644
--- a/Site5/Pages/v5/Support/StreamUpload.aspx.cs
+++ b/Site5/Pages/v5/Support/StreamUpload.aspx.cs
@@ -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;
}
diff --git a/Site5/Pages/v5/Swarm/Json-ListFindPeople.aspx.cs b/Site5/Pages/v5/Swarm/Json-ListFindPeople.aspx.cs
index 66d2da82..99f35589 100644
--- a/Site5/Pages/v5/Swarm/Json-ListFindPeople.aspx.cs
+++ b/Site5/Pages/v5/Swarm/Json-ListFindPeople.aspx.cs
@@ -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");
}
diff --git a/Site5/Pages/v5/Swarm/ListFindPeople.aspx.cs b/Site5/Pages/v5/Swarm/ListFindPeople.aspx.cs
index 22065749..7489dde1 100644
--- a/Site5/Pages/v5/Swarm/ListFindPeople.aspx.cs
+++ b/Site5/Pages/v5/Swarm/ListFindPeople.aspx.cs
@@ -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");
}