Permissions & Authorization for Users #24
Initial Release; Includes Database and MVC refactoring
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Authorization
|
||||
{
|
||||
public interface IAuthorizationToken
|
||||
{
|
||||
User User { get; set; }
|
||||
List<string> GroupMembership { get; set; }
|
||||
List<IRoleToken> RoleTokens { get; set; }
|
||||
|
||||
bool HasAny(params string[] ClaimKeys);
|
||||
bool HasAny(IEnumerable<string> ClaimKeys);
|
||||
bool HasAll(params string[] ClaimKeys);
|
||||
bool HasAll(IEnumerable<string> ClaimKeys);
|
||||
bool Has(string ClaimKey);
|
||||
|
||||
void Require(string ClaimKey);
|
||||
void RequireAll(params string[] ClaimKeys);
|
||||
void RequireAny(params string[] ClaimKeys);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Authorization
|
||||
{
|
||||
public interface IClaimNavigatorItem
|
||||
{
|
||||
string Key { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
bool Hidden { get; }
|
||||
|
||||
List<IClaimNavigatorItem> Children { get; }
|
||||
bool IsGroup { get; }
|
||||
bool? Value { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Authorization
|
||||
{
|
||||
public interface IRoleToken
|
||||
{
|
||||
AuthorizationRole Role { get; set; }
|
||||
List<string> SubjectIds { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ namespace Disco.Models.BI.Config
|
||||
public string ToConfigurationEntry()
|
||||
{
|
||||
StringBuilder entryBuilder = new StringBuilder();
|
||||
|
||||
|
||||
entryBuilder.AppendLine(Name.Trim());
|
||||
entryBuilder.AppendLine(Address.Trim());
|
||||
entryBuilder.AppendLine(Suburb.Trim());
|
||||
@@ -46,7 +46,7 @@ namespace Disco.Models.BI.Config
|
||||
{
|
||||
entryBuilder.AppendLine(ShortName.Trim());
|
||||
}
|
||||
|
||||
|
||||
return entryBuilder.ToString();
|
||||
}
|
||||
|
||||
@@ -70,5 +70,9 @@ namespace Disco.Models.BI.Config
|
||||
throw new ArgumentException("Invalid Configuration Address Entry", "entry");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} ({1})", this.Name, this.ShortName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Authorization\IAuthorizationToken.cs" />
|
||||
<Compile Include="Authorization\IClaimNavigatorItem.cs" />
|
||||
<Compile Include="Authorization\IRoleToken.cs" />
|
||||
<Compile Include="BI\Config\OrganisationAddress.cs" />
|
||||
<Compile Include="BI\Device\ImportDevice.cs" />
|
||||
<Compile Include="BI\Device\ImportDeviceSession.cs" />
|
||||
@@ -72,7 +75,9 @@
|
||||
<Compile Include="ClientServices\WhoAmI.cs" />
|
||||
<Compile Include="ClientServices\WhoAmIResponse.cs" />
|
||||
<Compile Include="Interop\ActiveDirectory\ActiveDirectoryMachineAccount.cs" />
|
||||
<Compile Include="Interop\ActiveDirectory\ActiveDirectoryGroup.cs" />
|
||||
<Compile Include="Interop\ActiveDirectory\ActiveDirectoryUserAccount.cs" />
|
||||
<Compile Include="Interop\ActiveDirectory\IActiveDirectoryObject.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Repository\ConfigurationItem.cs" />
|
||||
<Compile Include="Repository\Device\Device.cs" />
|
||||
@@ -98,7 +103,11 @@
|
||||
<Compile Include="Repository\User\User.cs" />
|
||||
<Compile Include="Repository\User\UserAttachment.cs" />
|
||||
<Compile Include="Repository\User\UserDetail.cs" />
|
||||
<Compile Include="Repository\User\AuthorizationRole.cs" />
|
||||
<Compile Include="UI\BaseUIModel.cs" />
|
||||
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleCreateModel.cs" />
|
||||
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleIndexModel.cs" />
|
||||
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleShowModel.cs" />
|
||||
<Compile Include="UI\Config\DeviceBatch\ConfigDeviceBatchCreateModel.cs" />
|
||||
<Compile Include="UI\Config\DeviceBatch\ConfigDeviceBatchIndexModel.cs" />
|
||||
<Compile Include="UI\Config\DeviceBatch\ConfigDeviceBatchIndexModelItem.cs" />
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Interop.ActiveDirectory
|
||||
{
|
||||
public class ActiveDirectoryGroup : IActiveDirectoryObject
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string DistinguishedName { get; set; }
|
||||
public string SamAccountName { get; set; }
|
||||
public string SecurityIdentifier { get; set; }
|
||||
public string CommonName { get; set; }
|
||||
|
||||
public List<string> MemberOf { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,37 +6,24 @@ using Disco.Models.Repository;
|
||||
|
||||
namespace Disco.Models.Interop.ActiveDirectory
|
||||
{
|
||||
public class ActiveDirectoryMachineAccount
|
||||
public class ActiveDirectoryMachineAccount : IActiveDirectoryObject
|
||||
{
|
||||
public string DistinguishedName { get; set; }
|
||||
public string DnsName { get; set; }
|
||||
public string Domain { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid NetbootGUID { get; set; }
|
||||
public string ObjectSid { get; set; }
|
||||
public string SecurityIdentifier { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string sAMAccountName { get; set; }
|
||||
public string SamAccountName { get; set; }
|
||||
public bool IsCriticalSystemObject { get; set; }
|
||||
public Dictionary<string, object[]> LoadedProperties { get; set; }
|
||||
|
||||
public string ParentDistinguishedName
|
||||
{
|
||||
get
|
||||
{
|
||||
// Determine Parent
|
||||
if (!string.IsNullOrWhiteSpace(DistinguishedName))
|
||||
return DistinguishedName.Substring(0, DistinguishedName.IndexOf(",DC=")).Substring(DistinguishedName.IndexOf(",") + 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public User ToRepositoryUser()
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = this.sAMAccountName,
|
||||
Type = "Computer",
|
||||
Id = this.SamAccountName,
|
||||
DisplayName = this.Name
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Disco.Models.Repository;
|
||||
|
||||
namespace Disco.Models.Interop.ActiveDirectory
|
||||
{
|
||||
public class ActiveDirectoryUserAccount
|
||||
public class ActiveDirectoryUserAccount : IActiveDirectoryObject
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string DistinguishedName { get; set; }
|
||||
@@ -15,25 +15,23 @@ namespace Disco.Models.Interop.ActiveDirectory
|
||||
public string GivenName { get; set; }
|
||||
public List<string> Groups { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ObjectSid { get; set; }
|
||||
public string SecurityIdentifier { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string sAMAccountName { get; set; }
|
||||
public string SamAccountName { get; set; }
|
||||
public string Surname { get; set; }
|
||||
public string Type { get; set; }
|
||||
public Dictionary<string, object[]> LoadedProperties { get; set; }
|
||||
|
||||
public User ToRepositoryUser()
|
||||
{
|
||||
return new User
|
||||
{
|
||||
Id = this.sAMAccountName,
|
||||
Id = this.SamAccountName,
|
||||
DisplayName = this.DisplayName,
|
||||
Surname = this.Surname,
|
||||
GivenName = this.GivenName,
|
||||
EmailAddress = this.Email,
|
||||
PhoneNumber = this.Phone,
|
||||
Type = this.Type
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Interop.ActiveDirectory
|
||||
{
|
||||
public interface IActiveDirectoryObject
|
||||
{
|
||||
string DistinguishedName { get; set; }
|
||||
string SecurityIdentifier { get; set; }
|
||||
|
||||
string SamAccountName { get; set; }
|
||||
|
||||
string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0725.2249")]
|
||||
[assembly: AssemblyFileVersion("1.2.0725.2249")]
|
||||
[assembly: AssemblyVersion("1.2.1001.1541")]
|
||||
[assembly: AssemblyFileVersion("1.2.1001.1541")]
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Repository
|
||||
{
|
||||
public class AuthorizationRole
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
[Required, StringLength(100)]
|
||||
public string Name { get; set; }
|
||||
|
||||
public string SubjectIds { get; set; }
|
||||
|
||||
public string ClaimsJson { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ namespace Disco.Models.Repository
|
||||
[StringLength(200)]
|
||||
public string GivenName { get; set; }
|
||||
|
||||
[StringLength(8)]
|
||||
public string Type { get; set; }
|
||||
[StringLength(100)]
|
||||
public string PhoneNumber { get; set; }
|
||||
[StringLength(150)]
|
||||
@@ -32,17 +30,6 @@ namespace Disco.Models.Repository
|
||||
[InverseProperty("UserId")]
|
||||
public virtual IList<Job> Jobs { get; set; }
|
||||
|
||||
//#region Helper Members
|
||||
//[NotMapped, XmlIgnore, ScriptIgnore]
|
||||
//public List<DeviceUserAssignment> CurrentDeviceUserAssignments
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return this.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue).ToList();
|
||||
// }
|
||||
//}
|
||||
//#endregion
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} ({1})", this.DisplayName, this.Id);
|
||||
@@ -63,17 +50,6 @@ namespace Disco.Models.Repository
|
||||
this.EmailAddress = u.EmailAddress;
|
||||
if (this.PhoneNumber != u.PhoneNumber)
|
||||
this.PhoneNumber = u.PhoneNumber;
|
||||
if (this.Type != u.Type)
|
||||
this.Type = u.Type;
|
||||
}
|
||||
|
||||
public static class Types
|
||||
{
|
||||
public const string Admin = "Admin";
|
||||
public const string Computer = "Computer";
|
||||
public const string Staff = "Staff";
|
||||
public const string Student = "Student";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.UI.Config.AuthorizationRole
|
||||
{
|
||||
public interface ConfigAuthorizationRoleCreateModel : BaseUIModel
|
||||
{
|
||||
Models.Repository.AuthorizationRole AuthorizationRole { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Disco.Models.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.UI.Config.AuthorizationRole
|
||||
{
|
||||
public interface ConfigAuthorizationRoleIndexModel : BaseUIModel
|
||||
{
|
||||
List<IRoleToken> Tokens { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Disco.Models.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.UI.Config.AuthorizationRole
|
||||
{
|
||||
public interface ConfigAuthorizationRoleShowModel : BaseUIModel
|
||||
{
|
||||
IRoleToken Token { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@ namespace Disco.Models.UI.Config.DeviceBatch
|
||||
public interface ConfigDeviceBatchShowModel : BaseUIModel
|
||||
{
|
||||
Disco.Models.Repository.DeviceBatch DeviceBatch { get; set; }
|
||||
|
||||
Disco.Models.Repository.DeviceModel DefaultDeviceModel { get; set; }
|
||||
|
||||
List<Disco.Models.Repository.DeviceModel> DeviceModels { get; set; }
|
||||
|
||||
List<ConfigDeviceBatchShowModelMembership> DeviceModelMembers { get; set; }
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Disco.Models.UI.Config.DeviceProfile
|
||||
public interface ConfigDeviceProfileShowModel : BaseUIModel
|
||||
{
|
||||
Disco.Models.Repository.DeviceProfile DeviceProfile { get; set; }
|
||||
Disco.Models.BI.Config.OrganisationAddress DefaultOrganisationAddress { get; set; }
|
||||
|
||||
List<Disco.Models.BI.Config.OrganisationAddress> OrganisationAddresses { get; set; }
|
||||
|
||||
int DeviceCount { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Disco.Models.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -11,5 +12,6 @@ namespace Disco.Models.UI.User
|
||||
Disco.Models.Repository.User User { get; set; }
|
||||
Disco.Models.BI.Job.JobTableModel Jobs { get; set; }
|
||||
List<Disco.Models.Repository.DocumentTemplate> DocumentTemplates { get; set; }
|
||||
IClaimNavigatorItem ClaimNavigator { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user