Skip to content

Commit

Permalink
Merge pull request #369 from Blazam-App/Beta-Nightly
Browse files Browse the repository at this point in the history
05H2 Update
  • Loading branch information
jacobsen9026 committed May 24, 2024
2 parents c0df38c + 81a7243 commit fb3b008
Show file tree
Hide file tree
Showing 24 changed files with 182 additions and 136 deletions.
6 changes: 3 additions & 3 deletions BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>0.9.2</AssemblyVersion>
<Version>2024.05.07.1847</Version>
<Version>2024.05.22.2338</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down Expand Up @@ -56,15 +56,15 @@
<ItemGroup>
<PackageReference Include="BlazorTemplater" Version="1.5.1" />
<PackageReference Include="Cassia" Version="2.0.0.60" />
<PackageReference Include="DuoUniversal" Version="1.2.3" />
<PackageReference Include="DuoUniversal" Version="1.2.4" />
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.29" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.29" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.29" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.19" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.18" />
Expand Down
11 changes: 1 addition & 10 deletions BLAZAM/Pages/API/Token.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,7 @@ public JsonResult OnGet()
{
userSettings.APIToken = Token;
}
else
{
userSettings = new AppUser
{
UserGUID = User.Identity.Name,
APIToken = Token
};
Context.UserSettings.Add(userSettings);

}

Context.SaveChanges();
return new JsonResult(userSettings);
}
Expand Down
8 changes: 4 additions & 4 deletions BLAZAM/Pages/Configure/Fields.razor
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
<CellTemplate>
<MudCheckBox Size="@Size.Small"
ReadOnly=true
Value="@(context.Item?.ObjectTypes.Where(ot=>ot.ObjectType==objectType).Any()==true)" />
Value="@(context.Item.ObjectTypes.Where(ot=>ot.ObjectType==objectType).Any()==true)" />
</CellTemplate>
</TemplateColumn>
}
<TemplateColumn CellClass="d-flex justify-end" Title=@AppLocalization["Delete"] Sortable="false">
<CellTemplate>
<MudIconButton Disabled=@(context.Item?.Id>100000)
<MudIconButton Disabled=@(context.Item.Id>100000)
Size="@Size.Small"
Icon="@Icons.Material.Outlined.Delete"
OnClick="@(async()=>{await Delete(context.Item);})" />
Expand Down Expand Up @@ -109,9 +109,9 @@
if (await MessageService.Confirm("Are you sure you want to delete " + field.DisplayName + "?", "Delete " + field.DisplayName + "?"))
{
field.DeletedAt = DateTime.UtcNow;
if (Context != null && await Context.SaveChangesAsync() > 0)
if (Context != null && await Context.SaveChangesAsync() > 0 && fieldGrid!=null)
{
await fieldGrid?.ReloadServerData();
await fieldGrid.ReloadServerData();

SnackBarService.Success(field.DisplayName + " deleted");
}
Expand Down
122 changes: 62 additions & 60 deletions BLAZAM/Pages/Groups/ViewGroup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@



<EditForm Model="Group">


<SetSubHeader>
<DirectoryEntryViewHeader EditMode="@EditMode"
DirectoryEntry="@Group"
OnAssignTo="@(()=>{AssignToModal?.Show();})"
OnChangeThumbnail="@(()=>{UploadThumbnailModal?.Show();})"
OnDelete="@DeleteGroup"
OnMove="@(()=>{MoveToModal?.Show();})"
OnRename="@(()=>{RenameModal?.Show();})"
OnResetPassword="@(()=>{ChangePasswordModal?.Show();})"
OnShowHistory="@(()=>{ChangeHistoryModal?.Show();})"
OnToggleEditMode="@ToggleEditMode" />
<MudOverlay Visible="SavingChanges" DarkBackground="false" Absolute="true" />
</SetSubHeader>

<CascadingValue Value="EditMode">


<AppModal Title=@AppLocalization["Assign To"] @ref=@AssignToModal>
<AssignToModalContent OnGroupMembershipChange=@((change)=>{AssignToModal?.Hide(); InvokeAsync(StateHasChanged);}) DirectoryModel="Group" />
</AppModal>
<AppModal Title=@AppLocalization["Add Members"] @ref=@AssignMemberModal>
<AddMemberModalContent ModelChanged=@((change)=>{AssignMemberModal?.Hide();InvokeAsync(StateHasChanged);}) Group="Group" />
</AppModal>
<AppModal Title=@AppLocalization["Move To"] @ref=@MoveToModal>
@if (MoveToModal?.IsShown == true)
<EditForm Model="Group">


<SetSubHeader>
<DirectoryEntryViewHeader EditMode="@EditMode"
DirectoryEntry="@Group"
OnAssignTo="@(()=>{AssignToModal?.Show();})"
OnChangeThumbnail="@(()=>{UploadThumbnailModal?.Show();})"
OnDelete="@DeleteGroup"
OnMove="@(()=>{MoveToModal?.Show();})"
OnRename="@(()=>{RenameModal?.Show();})"
OnResetPassword="@(()=>{ChangePasswordModal?.Show();})"
OnShowHistory="@(()=>{ChangeHistoryModal?.Show();})"
OnToggleEditMode="@ToggleEditMode" />
<MudOverlay Visible="SavingChanges" DarkBackground="false" Absolute="true" />
</SetSubHeader>

<CascadingValue Value="EditMode">


<AppModal Title=@AppLocalization["Assign To"] @ref=@AssignToModal>
<AssignToModalContent OnGroupMembershipChange=@((change)=>{AssignToModal?.Hide(); InvokeAsync(StateHasChanged);}) DirectoryModel="Group" />
</AppModal>
<AppModal Title=@AppLocalization["Add Members"] @ref=@AssignMemberModal>
<AddMemberModalContent ModelChanged=@((change)=>{AssignMemberModal?.Hide();InvokeAsync(StateHasChanged);}) Group="Group" />
</AppModal>
<AppModal Title=@AppLocalization["Move To"] @ref=@MoveToModal>
@if (MoveToModal?.IsShown == true)
{
<MoveToOUModalContent DirectoryModel="Group" />
}
Expand All @@ -46,59 +46,61 @@
</AppModal>





<MudGrid>
<MudItem xs="12" md="6">
<Section Style="min-height:200px;" Title="Group Details">
<MudTextField Label="@AppLocalization["Group Name"]" @bind-Value="@Group.CanonicalName" Disabled />

<MudTextField Label="@AppLocalization["Account Name"]" @bind-Value="@Group.SamAccountName" Disabled />
<MudTextField Label="@AppLocalization["Account Name"]" @bind-Value="@Group.SamAccountName" Disabled />

<MudTextField Label="@AppLocalization["Description"]" @bind-Value="@Group.Description" Disabled=@(!EditMode || !Group.CanEdit) />

<MudTextField Label="@AppLocalization["Email Address"]" @bind-Value="@Group.Email" Disabled=@(!EditMode || !Group.CanEditField(ActiveDirectoryFields.Mail)) />

<MudStack Row=true>
<MudText Typo="Typo.subtitle2">@AppLocalization["Created"]:</MudText>
<MudSpacer />
<DateWithTimeTooltip DateTime="Group?.Created" />
<MudTextField Label="@AppLocalization["Email Address"]" @bind-Value="@Group.Email" Disabled=@(!EditMode || !Group.CanEditField(ActiveDirectoryFields.Mail)) />

</MudStack>
<MudStack Row=true>
<MudText Typo="Typo.subtitle2">@AppLocalization["Created"]:</MudText>
<MudSpacer />
<DateWithTimeTooltip DateTime="Group?.Created" />

<MudStack Row=true>
</MudStack>

<MudText Typo="Typo.subtitle2">@AppLocalization["Last Change"]:</MudText>
<MudSpacer />
<MudStack Row=true>

<DateWithTimeTooltip DateTime="Group?.LastChanged" />
<MudText Typo="Typo.subtitle2">@AppLocalization["Last Change"]:</MudText>
<MudSpacer />

</MudStack>
<DateWithTimeTooltip DateTime="Group?.LastChanged" />

</MudStack>

<MudStack Row=true>
<MudText Typo="Typo.subtitle2">@AppLocalization["OU"]:</MudText>
<MudSpacer />

<MudText Style="text-align:end;" Typo="Typo.caption">@Group.OU.ToPrettyOu()</MudText>
</MudStack>
<MudStack Row=true>
<MudText Typo="Typo.subtitle2">@AppLocalization["OU"]:</MudText>
<MudSpacer />

<MudText Style="text-align:end;" Typo="Typo.caption">@Group.OU.ToPrettyOu()</MudText>
</MudStack>

</Section>
</MudItem>
<MudItem xs="12" md="6">
<Section Style="min-height:200px;" Title=@AppLocalization["Parent Groups"]>
<MemberOfList Model="Group" />

</Section>
</MudItem>
<MudItem xs="12" md="12">
<Section Style="min-height:200px;" Title=@AppLocalization["Members"]>
<GroupMembersDataGrid Group="Group" />
</Section>
</MudItem>
<MudItem xs="12" md="6">
<Section Style="min-height:200px;" Title=@AppLocalization["Parent Groups"]>
<MemberOfList Model="Group" />

</Section>
</MudItem>
<MudItem xs="12" md="12">
<Section Style="min-height:200px;" Title=@AppLocalization["Members"]>
<GroupMembersDataGrid Group="Group" />

</Section>
</MudItem>
</MudGrid>
</Section>
</MudItem>
</MudGrid>



Expand All @@ -112,7 +114,7 @@



@if (Group.CanEdit && Group.HasUnsavedChanges)
@if (Group.CanEdit && Group.HasUnsavedChanges)
{
<UnsavedChangesPrompt SaveChanges="SaveChanges" DiscardChanges="DiscardChanges" />
}
Expand Down
3 changes: 2 additions & 1 deletion BLAZAM/Pages/MFACallback.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public async Task<IActionResult> OnGet(string? state=null,string? code=null)
await _audit.Logon.Login(user.User, HttpContext.Connection.RemoteIpAddress?.ToString());
return new RedirectResult("/");
}
}catch (Exception ex)
}catch
{

return new RedirectResult("/");
}

Expand Down
13 changes: 8 additions & 5 deletions BLAZAM/Pages/Users/CreateUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@
</MudCarouselItem>

<MudCarouselItem Class="pa-5">
<MudFab StartIcon="@Icons.Material.Filled.ArrowBack"

<FlexContainer>
<MudFab StartIcon="@Icons.Material.Filled.ArrowBack"
Size="Size.Small"
OnClick="@(()=>{_templateCarouselIndex=0;})"
OnClick="@(()=>{_templateCarouselIndex=0; SelectedCategory=null;})"
Color="Color.Primary" />
<FlexContainer>

@foreach (var template in TemplatesUserCanUse.Where(t => t.DeletedAt == null && t.Visible))
{
<MudButton OnClick=@(async()=>{await SetTemplate(template);}) Variant="Variant.Filled" Color="Color.Primary" Size="Size.Large">@template.Name</MudButton>
<MudButton OnClick=@(async()=>{await SetTemplate(template);})
Variant="Variant.Filled"
Color="Color.Primary"
Size="Size.Large">@template.Name</MudButton>

}
</FlexContainer>
Expand Down
23 changes: 16 additions & 7 deletions BLAZAM/ProgramHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace BLAZAM.Server
{
public static class ProgramHelpers
{
/// <summary>
/// Sets up the core configuration like debug, installation id, and running process and version
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static WebApplicationBuilder IntializeProperties(this WebApplicationBuilder builder)
{
//Set DebugMode flag from configuration
Expand All @@ -45,25 +50,27 @@ public static WebApplicationBuilder IntializeProperties(this WebApplicationBuild
//Set the installation ID
try
{
//Attempts to get the windows installation GUID
ApplicationInfo.installationId = GetInstallationId();


}catch (Exception ex)
}catch
{
//Default to a hash type method on the machine name
ApplicationInfo.installationId = Environment.MachineName.ToGuid();

}
//Set application directories
//Program.RootDirectory = new SystemDirectory(builder.Environment.ContentRootPath);
//Program.TempDirectory = new SystemDirectory(Path.GetTempPath() + "Blazam\\");

Program.AppDataDirectory = new SystemDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Blazam\\");


//Store the configuration so other pages/objects can easily access it
Program.Configuration = builder.Configuration;


//Captures the running process
ApplicationInfo.runningProcess = Process.GetCurrentProcess();

//Gets the application version from he running assembly version
ApplicationInfo.runningVersion = new ApplicationVersion(Assembly.GetExecutingAssembly()) ;


Expand Down Expand Up @@ -208,6 +215,7 @@ completed so it may not be usable as is

//Provide an Http client as a service with custom construction via api service class
builder.Services.AddHttpClient();

//Also keeping this here for a possible future API, though this would be for internal use
//builder.Services.AddTransient<ApiService>();
//builder.Services.AddTransient<IPrincipal>(provider => provider.GetService<IHttpContextAccessor>().HttpContext.User);
Expand All @@ -225,7 +233,7 @@ completed so it may not be usable as is
//Provide chat as a service
builder.Services.AddSingleton<IChatService,ChatService>();


//Sets up Active Directory communications
builder.Services.AddActiveDirectoryServices();


Expand All @@ -252,7 +260,8 @@ completed so it may not be usable as is
builder.Services.AddScoped<SearchService>();



//A substitue Navigation Manager for the app to enable navigation warning on unsaved
//changes
builder.Services.AddScoped<AppNavigationManager>();


Expand Down
6 changes: 3 additions & 3 deletions BLAZAMActiveDirectory/Searchers/ADGroupSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task<List<IADGroup>> FindNewGroupsAsync(int maxAgeInDays = 14)
public List<IGroupableDirectoryAdapter>? GetAllNestedMembers(IADGroup group)
{
string UserSearchFieldsQuery = "(&(memberOf:1.2.840.113556.1.4.1941:=" + group.DN + "))";
return ConvertTo<GroupableDirectoryAdapter>(SearchObjects(UserSearchFieldsQuery, ActiveDirectoryObjectType.User)).Cast<IGroupableDirectoryAdapter>().ToList();
return SearchObjects(UserSearchFieldsQuery, ActiveDirectoryObjectType.User).Cast<IGroupableDirectoryAdapter>().ToList();

}

Expand Down Expand Up @@ -173,7 +173,7 @@ public List<IADUser> GetDirectUserMembers(IADGroup group, bool ignoreDisabledUse
}.Search<ADUser, IADUser>();
*/
string UserSearchFieldsQuery = "(memberOf=" + group.DN + ")";
return new List<IADUser>(ConvertTo<ADUser>(SearchObjects(UserSearchFieldsQuery, ActiveDirectoryObjectType.User, 500, ignoreDisabledUsers)));
return SearchObjects(UserSearchFieldsQuery, ActiveDirectoryObjectType.User, 500, ignoreDisabledUsers).Cast<IADUser>().ToList();


}
Expand All @@ -188,7 +188,7 @@ public List<IADGroup> GetGroupMembers(IADGroup group)
}.Search<ADGroup, IADGroup>();
*/
string UserSearchFieldsQuery = "(memberOf=" + group.DN + ")";
return new List<IADGroup>(ConvertTo<ADGroup>(SearchObjects(UserSearchFieldsQuery, ActiveDirectoryObjectType.Group, 500)));
return SearchObjects(UserSearchFieldsQuery, ActiveDirectoryObjectType.Group, 500).Cast<IADGroup>().ToList();


}
Expand Down
6 changes: 3 additions & 3 deletions BLAZAMActiveDirectory/Searchers/ADOUSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public List<IADOrganizationalUnit> FindOuByString(string searchTerm)
return FindOuByString(searchTerm).OrderBy(x => x.DN).FirstOrDefault();
}

public List<IADOrganizationalUnit> FindSubOusByDN(string? searchBaseDN) => new List<IADOrganizationalUnit>(ConvertTo<ADOrganizationalUnit>(SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.OU, 1000, true, SearchScope.OneLevel)));
public List<IADOrganizationalUnit> FindSubOusByDN(string? searchBaseDN) => SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.OU, 1000, true, SearchScope.OneLevel).Cast<IADOrganizationalUnit>().ToList();

public List<IADUser> FindSubUsersByDN(string searchBaseDN) => new List<IADUser>(ConvertTo<ADUser>(SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.User, 1000, true, SearchScope.OneLevel)));
public List<IADUser> FindSubUsersByDN(string searchBaseDN) => SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.User, 1000, true, SearchScope.OneLevel).Cast<IADUser>().ToList();

public List<IADComputer> FindSubComputerByDN(string searchBaseDN) {
var search = NewSearch;
Expand All @@ -61,7 +61,7 @@ public List<IADComputer> FindSubComputerByDN(string searchBaseDN) {
}
// new List<IADComputer>(ConvertTo<ADComputer>(SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.Computer, 1000, true, SearchScope.OneLevel)));

public List<IADGroup> FindSubGroupsByDN(string searchBaseDN) => new List<IADGroup>(ConvertTo<ADGroup>(SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.Group, 1000, true, SearchScope.OneLevel)));
public List<IADGroup> FindSubGroupsByDN(string searchBaseDN) => SearchObjects(searchBaseDN, "", ActiveDirectoryObjectType.Group, 1000, true, SearchScope.OneLevel).Cast<IADGroup>().ToList();



Expand Down
Loading

0 comments on commit fb3b008

Please sign in to comment.