Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
3973333
Add support to the Change Queries feature in Ed-Fi ODS API v5.2 to en…
gmcelhanon Aug 15, 2021
a5ae893
Modified script for creating ReadChanges action to include authorizat…
gmcelhanon Sep 24, 2021
3bc59fe
Removed NDE LDS plugin artifacts from common generator solution.
gmcelhanon Sep 24, 2021
531f14f
Implemented support for exposing natural key changes in the API.
gmcelhanon Sep 26, 2021
942bfcc
Semantic Model Enhancement: Added clear delineation between the Defin…
gmcelhanon Sep 30, 2021
f4688d7
Semantic Model Enhancement: Fix bug with DefiningProperty implementat…
gmcelhanon Oct 20, 2021
3433f9a
Squashed commit of several SQL script changes (see individual commit …
gmcelhanon Oct 10, 2021
f54d26e
Squashed commit of several non-SQL script related changes (see indivi…
gmcelhanon Oct 19, 2021
426c309
Fix issues with the registration of the authorization decorators for …
gmcelhanon Oct 20, 2021
f8c3298
Updated SQL Server security metadata scripts to use the Authorization…
gmcelhanon Oct 20, 2021
8f6dc17
Refined authorization views for including deletes (for LEA-based API …
gmcelhanon Oct 21, 2021
a89432b
Added authorization views for including deletes for School-based API …
gmcelhanon Oct 21, 2021
5bfbff3
Add authorization support for School-level API clients.
gmcelhanon Oct 21, 2021
2615b4c
Semantic Model Enhancement: BUG FIX - Moved resolution of DescriptorR…
gmcelhanon Jan 15, 2022
c700fa8
BUGFIX: Invalid SQL results when relationship-based authorization was…
gmcelhanon Jan 27, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ void RegisterModels()
.AsSelf()
.SingleInstance();

builder.RegisterGeneric(typeof(GetDeletedResourceModelByIds<,,>))
.AsSelf()
.SingleInstance();

builder.RegisterGeneric(typeof(ValidateResourceModel<,,,>))
.AsSelf()
.SingleInstance();
Expand Down Expand Up @@ -296,11 +292,6 @@ void RegisterPipeLineStepProviders()
.As<IPipelineStepsProvider>()
.SingleInstance();

builder.RegisterType<GetDeletedResourceIdsPipelineStepsProvider>()
.As<IGetDeletedResourceIdsPipelineStepsProvider>()
.As<IPipelineStepsProvider>()
.SingleInstance();

builder.RegisterType<PutPipelineStepsProvider>()
.As<IPutPipelineStepsProvider>()
.As<IPipelineStepsProvider>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System.Data.Common;
using Autofac;
using EdFi.Common.Configuration;
using EdFi.Ods.Common.Configuration;
using EdFi.Ods.Common.Container;
using EdFi.Ods.Common.Infrastructure.Activities;
using EdFi.Ods.Common.Infrastructure.Configuration;
using EdFi.Ods.Common.Infrastructure.PostgreSql;
using EdFi.Ods.Generator.Database.Engines.PostgreSql;
using EdFi.Ods.Generator.Database.NamingConventions;
using EdFi.Ods.Security.Authorization;
using Npgsql;
using SqlKata.Compilers;

namespace EdFi.Ods.Api.Container.Modules
{
Expand All @@ -34,6 +39,16 @@ public override void ApplyConfigurationSpecificRegistrations(ContainerBuilder bu
builder.RegisterType<PostgreSqlDatabaseEngineNHibernateConfigurationActivity>()
.As<INHibernateConfigurationActivity>()
.SingleInstance();

builder.RegisterInstance(NpgsqlFactory.Instance)
.As<DbProviderFactory>();

builder.Register<Compiler>(ctx => new PostgresCompiler());

// Register PostgreSQL naming convention
builder.RegisterType<PostgreSqlDatabaseNamingConvention>()
.As<IDatabaseNamingConvention>()
.SingleInstance();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System.Data.Common;
using System.Data.SqlClient;
using Autofac;
using EdFi.Common.Configuration;
using EdFi.Ods.Common.Configuration;
using EdFi.Ods.Common.Container;
using EdFi.Ods.Common.Infrastructure.Activities;
using EdFi.Ods.Common.Infrastructure.Configuration;
using EdFi.Ods.Common.Infrastructure.SqlServer;
using EdFi.Ods.Generator.Database.Engines.SqlServer;
using EdFi.Ods.Generator.Database.NamingConventions;
using EdFi.Ods.Security.Authorization;
using SqlKata.Compilers;

namespace EdFi.Ods.Api.Container.Modules
{
Expand All @@ -34,6 +39,16 @@ public override void ApplyConfigurationSpecificRegistrations(ContainerBuilder bu
builder.RegisterType<SqlServerDatabaseEngineNHibernateConfigurationActivity>()
.As<INHibernateConfigurationActivity>()
.SingleInstance();

builder.RegisterInstance(SqlClientFactory.Instance)
.As<DbProviderFactory>();

builder.Register<Compiler>(ctx => new SqlServerCompiler());

// Register SQL Server SQL naming convention
builder.RegisterType<SqlServerDatabaseNamingConvention>()
.As<IDatabaseNamingConvention>()
.SingleInstance();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using EdFi.Ods.Api.Filters;
using EdFi.Ods.Api.Infrastructure.Pipelines.Factories;
using EdFi.Ods.Api.Infrastructure.Pipelines.Get;
using EdFi.Ods.Api.Infrastructure.Pipelines.GetDeletedResource;
using EdFi.Ods.Api.Infrastructure.Pipelines.GetMany;
using EdFi.Ods.Api.Infrastructure.Pipelines.Put;
using EdFi.Ods.Common;
Expand Down Expand Up @@ -62,7 +61,6 @@ public abstract class DataManagementControllerBase<TResourceReadModel, TResource
protected Lazy<DeletePipeline> DeletePipeline;
protected Lazy<GetPipeline<TResourceReadModel, TAggregateRoot>> GetByIdPipeline;

protected Lazy<GetDeletedResourcePipeline<TAggregateRoot>> GetDeletedResourcePipeline;
protected Lazy<GetManyPipeline<TResourceReadModel, TAggregateRoot>> GetManyPipeline;

protected Lazy<PutPipeline<TResourceWriteModel, TAggregateRoot>> PutPipeline;
Expand All @@ -87,10 +85,6 @@ protected DataManagementControllerBase(
GetManyPipeline = new Lazy<GetManyPipeline<TResourceReadModel, TAggregateRoot>>
(pipelineFactory.CreateGetManyPipeline<TResourceReadModel, TAggregateRoot>);

// Change queries resource pipeline for deleted objects.
GetDeletedResourcePipeline = new Lazy<GetDeletedResourcePipeline<TAggregateRoot>>
(pipelineFactory.CreateGetDeletedResourcePipeline<TResourceReadModel, TAggregateRoot>);

PutPipeline = new Lazy<PutPipeline<TResourceWriteModel, TAggregateRoot>>
(pipelineFactory.CreatePutPipeline<TResourceWriteModel, TAggregateRoot>);

Expand Down
2 changes: 2 additions & 0 deletions Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
<PackageReference Include="Remotion.Linq" Version="2.2.0" />
<PackageReference Include="Remotion.Linq.EagerFetching" Version="2.2.0" />
<PackageReference Include="Sandwych.QuickGraph.Core" Version="1.0.0" />
<PackageReference Include="SqlKata" Version="2.3.7" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Services\Metadata\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Utilities\Generator\EdFi.Ods.Generator\EdFi.Ods.Generator.csproj" />
<ProjectReference Include="..\EdFi.Security.DataAccess\EdFi.Security.DataAccess.csproj" />
<ProjectReference Include="..\EdFi.Ods.Sandbox\EdFi.Ods.Sandbox.csproj" />
<ProjectReference Include="..\EdFi.Ods.Common\EdFi.Ods.Common.csproj" />
Expand Down
25 changes: 25 additions & 0 deletions Application/EdFi.Ods.Api/Helpers/ControllerHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System.Net;
using Microsoft.AspNetCore.Mvc;

namespace EdFi.Ods.Api.Helpers
{
public static class ControllerHelpers
{
/// <summary>
/// Gets an IActionResult returning a 404 Not Found status with no response body.
/// </summary>
/// <returns></returns>
public static IActionResult NotFound()
{
return new ObjectResult(null)
{
StatusCode = (int) HttpStatusCode.NotFound,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using EdFi.Ods.Api.Infrastructure.Pipelines.Get;
using EdFi.Ods.Api.Infrastructure.Pipelines.GetDeletedResource;
using EdFi.Ods.Api.Infrastructure.Pipelines.GetMany;
using EdFi.Ods.Api.Infrastructure.Pipelines.Put;
using EdFi.Ods.Common;
Expand All @@ -22,9 +21,6 @@ GetManyPipeline<TResourceModel, TEntityModel> CreateGetManyPipeline<TResourceMod
where TResourceModel : IHasETag
where TEntityModel : class;

GetDeletedResourcePipeline<TEntityModel> CreateGetDeletedResourcePipeline<TResourceModel, TEntityModel>()
where TEntityModel : class;

PutPipeline<TResourceModel, TEntityModel> CreatePutPipeline<TResourceModel, TEntityModel>()
where TEntityModel : class, IHasIdentifier, new()
where TResourceModel : IHasETag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
using System.Linq;
using EdFi.Common.InversionOfControl;
using EdFi.Ods.Api.Infrastructure.Pipelines.Get;
using EdFi.Ods.Api.Infrastructure.Pipelines.GetDeletedResource;
using EdFi.Ods.Api.Infrastructure.Pipelines.GetMany;
using EdFi.Ods.Api.Infrastructure.Pipelines.Put;
using EdFi.Ods.Common;
using EdFi.Ods.Common.Infrastructure.Pipelines;
using EdFi.Ods.Common.Infrastructure.Pipelines.Delete;
using EdFi.Ods.Common.Infrastructure.Pipelines.GetDeletedResource;
using EdFi.Ods.Common.Infrastructure.Pipelines.GetMany;

namespace EdFi.Ods.Api.Infrastructure.Pipelines.Factories
Expand All @@ -25,21 +23,18 @@ public class PipelineFactory : IPipelineFactory
private readonly IDeletePipelineStepsProvider deletePipelineStepsProvider;
private readonly IGetBySpecificationPipelineStepsProvider getBySpecificationPipelineStepsProvider;
private readonly IGetPipelineStepsProvider getPipelineStepsProvider;
private readonly IGetDeletedResourceIdsPipelineStepsProvider getDeletedResourceIdsPipelineStepsProvider;
private readonly IPutPipelineStepsProvider putPipelineStepsProvider;

public PipelineFactory(
IServiceLocator locator,
IGetPipelineStepsProvider getPipelineStepsProvider,
IGetBySpecificationPipelineStepsProvider getBySpecificationPipelineStepsProvider,
IGetDeletedResourceIdsPipelineStepsProvider getDeletedResourceIdsPipelineStepsProvider,
IPutPipelineStepsProvider putPipelineStepsProvider,
IDeletePipelineStepsProvider deletePipelineStepsProvider)
{
_locator = locator;
this.getPipelineStepsProvider = getPipelineStepsProvider;
this.getBySpecificationPipelineStepsProvider = getBySpecificationPipelineStepsProvider;
this.getDeletedResourceIdsPipelineStepsProvider = getDeletedResourceIdsPipelineStepsProvider;
this.putPipelineStepsProvider = putPipelineStepsProvider;
this.deletePipelineStepsProvider = deletePipelineStepsProvider;
}
Expand Down Expand Up @@ -71,18 +66,6 @@ public GetManyPipeline<TResourceModel, TEntityModel> CreateGetManyPipeline<TReso
return new GetManyPipeline<TResourceModel, TEntityModel>(steps);
}

public GetDeletedResourcePipeline<TEntityModel> CreateGetDeletedResourcePipeline<TResourceModel, TEntityModel>()
where TEntityModel : class
{
var stepsTypes = getDeletedResourceIdsPipelineStepsProvider.GetSteps();

var steps =
ResolvePipelineSteps<GetDeletedResourceContext<TEntityModel>, GetDeletedResourceResult, TResourceModel,
TEntityModel>(stepsTypes);

return new GetDeletedResourcePipeline<TEntityModel>(steps);
}

public PutPipeline<TResourceModel, TEntityModel> CreatePutPipeline<TResourceModel, TEntityModel>()
where TEntityModel : class, IHasIdentifier, new()
where TResourceModel : IHasETag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ public Type[] GetSteps()
}
}

/// <summary>
/// Provides the core Ed-Fi ODS API steps for "GetTrackedDelete" access.
/// </summary>
public class GetDeletedResourceIdsPipelineStepsProvider : IGetDeletedResourceIdsPipelineStepsProvider
{
public Type[] GetSteps()
{
return new[]
{
typeof(GetDeletedResourceModelByIds<,,>),
};
}
}

/// <summary>
/// Provides the core Ed-Fi ODS API steps for "Upsert" persistence.
/// </summary>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using EdFi.Common;
using EdFi.Ods.Api.Caching;
using EdFi.Ods.Common.Context;
using EdFi.Ods.Common.Exceptions;
using EdFi.Security.DataAccess.Models;
using Action = EdFi.Security.DataAccess.Models.Action;

Expand Down Expand Up @@ -53,7 +54,14 @@ public virtual Action GetActionByName(string actionName)
var instanceSecurityRepoCacheObject = InstanceSecurityRepositoryCache.GetCache()
.GetSecurityRepository(instanceId);

return instanceSecurityRepoCacheObject.Actions.First(a => a.ActionName.Equals(actionName, StringComparison.InvariantCultureIgnoreCase));
var action = instanceSecurityRepoCacheObject.Actions.FirstOrDefault(a => a.ActionName.Equals(actionName, StringComparison.InvariantCultureIgnoreCase));

if (action == null)
{
throw new ApiSecurityConfigurationException($"Action '{actionName}' not found in the security metadata.");
}

return action;
}

public virtual AuthorizationStrategy GetAuthorizationStrategyByName(string authorizationStrategyName)
Expand Down
3 changes: 3 additions & 0 deletions Application/EdFi.Ods.Common/Extensions/ResourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -199,8 +200,10 @@ public static string SchemaUriSegment(this Resource resource) => resource
/// </summary>
/// <param name="resourceClass">The resource class that is being inspected.</param>
/// <returns><b>true</b> if the resource class has a discriminator; otherwise <b>false</b>.</returns>
[Obsolete("This extension method doesn't make sense in the context of a resource that is derived and combines multiple entities. The Discriminator is an Entity-specific concept. Be explicit, and use the Entity's HasDiscriminator extension method instead.")]
public static bool HasDiscriminator(this ResourceClassBase resourceClass)
{
// NOTE: This returns unexpected values for resources that are derived.
return resourceClass.Entity?.HasDiscriminator() == true;
}

Expand Down
Loading