Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

05H2 Update #369

Merged
merged 22 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
14eb399
Bump DuoUniversal from 1.2.3 to 1.2.4
dependabot[bot] May 6, 2024
e1f844a
Bump Serilog.Sinks.Seq from 7.0.0 to 7.0.1
dependabot[bot] May 6, 2024
a084de9
Bump Microsoft.Playwright.NUnit from 1.43.0 to 1.44.0
dependabot[bot] May 20, 2024
ab78719
Bump Microsoft.AspNetCore.Components.Web and Microsoft.AspNetCore.Com…
dependabot[bot] May 20, 2024
f71b451
Remove old user settings initialization in API Token generator
jacobsen9026 May 22, 2024
20a1880
Remove uneccessary null checks
jacobsen9026 May 22, 2024
0af7616
Remove exception collection
jacobsen9026 May 22, 2024
5e21c0e
Improved comments
jacobsen9026 May 22, 2024
a35695d
Completed migration to new ADSearch
jacobsen9026 May 22, 2024
2bdf942
Deprecated AppValidationRule class
jacobsen9026 May 22, 2024
9dccf95
Improved comments
jacobsen9026 May 22, 2024
fd181d3
Add description to group view page #362
jacobsen9026 May 22, 2024
381268f
Allow editing of descripion
jacobsen9026 May 22, 2024
f49d131
Align permissions to AD read #362
jacobsen9026 May 22, 2024
1fef9fb
Merge pull request #365 from Blazam-App/dependabot/nuget/multi-1d2a4a…
jacobsen9026 May 22, 2024
c0a103b
Merge pull request #364 from Blazam-App/dependabot/nuget/Microsoft.Pl…
jacobsen9026 May 22, 2024
2d759da
Bump Microsoft.EntityFrameworkCore.Abstractions from 7.0.18 to 7.0.19
dependabot[bot] May 22, 2024
b85c00d
Fix for category lock-in #352
jacobsen9026 May 22, 2024
d580729
Merge pull request #363 from Blazam-App/dependabot/nuget/Microsoft.En…
jacobsen9026 May 22, 2024
47af0b0
Merge pull request #355 from Blazam-App/dependabot/nuget/Serilog.Sink…
jacobsen9026 May 22, 2024
75670fa
Merge pull request #354 from Blazam-App/dependabot/nuget/DuoUniversal…
jacobsen9026 May 22, 2024
81a7243
Merge pull request #368 from Blazam-App/Beta-Dev
jacobsen9026 May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading