-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from Strongminds/master
Merge 2.7.0
- Loading branch information
Showing
498 changed files
with
11,526 additions
and
5,888 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Core.ApplicationServices/Authentication/AuthenticationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Core.ApplicationServices.Authentication | ||
{ | ||
public class AuthenticationContext : IAuthenticationContext | ||
{ | ||
public AuthenticationMethod Method { get; } | ||
public int? UserId { get; } | ||
public int? ActiveOrganizationId { get; } | ||
public bool HasApiAccess { get; } | ||
|
||
public AuthenticationContext( | ||
AuthenticationMethod method, | ||
bool hasApiAccess, | ||
int? userId = null, | ||
int? activeOrganizationId = null) | ||
{ | ||
Method = method; | ||
UserId = userId; | ||
ActiveOrganizationId = activeOrganizationId; | ||
HasApiAccess = hasApiAccess; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Core.ApplicationServices/Authentication/AuthenticationMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Core.ApplicationServices.Authentication | ||
{ | ||
public enum AuthenticationMethod | ||
{ | ||
Anonymous, | ||
KitosToken, | ||
Forms | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Core.ApplicationServices/Authentication/IAuthenticationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Core.ApplicationServices.Authentication | ||
{ | ||
public interface IAuthenticationContext | ||
{ | ||
AuthenticationMethod Method { get; } | ||
int? UserId { get; } | ||
int? ActiveOrganizationId { get; } | ||
|
||
bool HasApiAccess { get; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Core.ApplicationServices/Authentication/IAuthenticationContextFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Core.ApplicationServices.Authentication | ||
{ | ||
public interface IAuthenticationContextFactory | ||
{ | ||
IAuthenticationContext Create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Core.ApplicationServices/Authorization/AuthorizationContextFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Core.ApplicationServices.Authorization | ||
{ | ||
public class AuthorizationContextFactory : IAuthorizationContextFactory | ||
{ | ||
public IAuthorizationContext Create(IOrganizationalUserContext userContext) | ||
{ | ||
return userContext is UnauthenticatedUserContext | ||
? new UnauthenticatedAuthorizationContext() | ||
: (IAuthorizationContext) new OrganizationAuthorizationContext(userContext); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
Core.ApplicationServices/Authorization/IAuthorizationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Core.DomainModel; | ||
using Core.DomainServices.Authorization; | ||
|
||
namespace Core.ApplicationServices.Authorization | ||
{ | ||
public interface IAuthorizationContext | ||
{ | ||
/// <summary> | ||
/// Determine the granularity of cross organization read access supported by the current authorization context | ||
/// </summary> | ||
/// <returns></returns> | ||
CrossOrganizationDataReadAccessLevel GetCrossOrganizationReadAccess(); | ||
/// <summary> | ||
/// Determines, at a high level, the depth of read-access which is allowed on objects within the target organization wrt. the active organization. | ||
/// NOTE: Does not provide entity-level access rights. Just answers the question if ANY access at all can be granted. | ||
/// </summary> | ||
/// <param name="organizationId"></param> | ||
/// <returns></returns> | ||
OrganizationDataReadAccessLevel GetOrganizationReadAccessLevel(int organizationId); | ||
/// <summary> | ||
/// Determines if read-access is allowed for the provided entity | ||
/// </summary> | ||
/// <param name="entity"></param> | ||
/// <returns></returns> | ||
bool AllowReads(IEntity entity); | ||
/// <summary> | ||
/// Determines if create-access is allowed for the provided entity type | ||
/// </summary> | ||
/// <returns></returns> | ||
bool AllowCreate<T>(); | ||
/// <summary> | ||
/// Determines if create-access is allowed for the provided entity type and with the representation passed in <paramref name="entity"/> | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="entity"></param> | ||
/// <returns></returns> | ||
bool AllowCreate<T>(IEntity entity); | ||
/// <summary> | ||
/// Determines if update-access is allowed for the provided entity | ||
/// </summary> | ||
/// <param name="entity"></param> | ||
/// <returns></returns> | ||
bool AllowModify(IEntity entity); | ||
/// <summary> | ||
/// Determines if delete-access is allowed for the provided entity | ||
/// </summary> | ||
/// <param name="entity"></param> | ||
/// <returns></returns> | ||
bool AllowDelete(IEntity entity); | ||
/// <summary> | ||
/// Determines if write-access is allowed to entity's visibility control | ||
/// </summary> | ||
/// <param name="entity"></param> | ||
/// <returns></returns> | ||
bool AllowEntityVisibilityControl(IEntity entity); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Core.ApplicationServices/Authorization/IAuthorizationContextFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Core.ApplicationServices.Authorization | ||
{ | ||
public interface IAuthorizationContextFactory | ||
{ | ||
IAuthorizationContext Create(IOrganizationalUserContext userContext); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Core.ApplicationServices/Authorization/IOrganizationalUserContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Core.DomainModel; | ||
using Core.DomainModel.Organization; | ||
|
||
namespace Core.ApplicationServices.Authorization | ||
{ | ||
public interface IOrganizationalUserContext | ||
{ | ||
int ActiveOrganizationId { get; } | ||
int UserId { get; } | ||
bool IsActiveInOrganizationOfType(OrganizationCategory category); | ||
bool HasRole(OrganizationRole role); | ||
bool HasModuleLevelAccessTo(IEntity entity); | ||
bool IsActiveInOrganization(int organizationId); | ||
bool IsActiveInSameOrganizationAs(IEntity entity); | ||
bool HasAssignedWriteAccess(IEntity entity); | ||
bool HasOwnership(IEntity entity); | ||
bool CanChangeVisibilityOf(IEntity entity); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Core.ApplicationServices/Authorization/IUserContextFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Core.ApplicationServices.Authorization | ||
{ | ||
public interface IUserContextFactory | ||
{ | ||
IOrganizationalUserContext Create(int userId, int organizationId); | ||
} | ||
} |
Oops, something went wrong.