-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ODS-5987] Relationship Authorization for StudentAssessment based on …
…ReportingSchool (#835) * Override for auth by reported school on student assessment (#814) In order to use role based field for establishing edorg relationship, a custom authorization context data provider implementation is needed to use ReportingSchoolId. This follows the pattern established in DisciplineActionRelationshipsAuthorizationContextDataProvider. * Reduce debug noise and performance hit related to logging cache hits. * Updated IsEducationOrganizationIdName method to allow for role-named EdOrgId-related identifiers. * Updated IsPersonIdentifier method to allow for role-named person identifiers. * Updated main data context provider registration module to register context data providers succinctly and to avoid registering any of the custom override providers. * Minor cleanup of the StudentAssessmentRelationshipsAuthorizationContextDataProvider class, and added the missing license header. * Reverting suspect changes to test builds. * Restoring changes for adding support for role-named EdOrgIds in IsEducationOrganizationIdName method. * Restoring changes for making logic around registrations of relationship authorization context data providers for generated entities more concise. * Modified unit tests with slight delay to prevent timing-based unit test failures. * Restoring PersonEntitySpecification implementation. * Tightening up the conventions around identifying person types to ensure the identifier's property name matches the entity name + USI. * Renamed constants on UniqueIdConventions from USI and UniqueId to UsiSuffix and UniqueIdSuffix respectively. * Added an alternative implementation of the IsPersonIdentifier method. * Fixed bug with new support for role-named person identifier identification. * Fixed issue with original concise code related to person identifier identification. * Comment. --------- Co-authored-by: Audrey Shay <[email protected]>
- Loading branch information
1 parent
0abd7f5
commit 237580c
Showing
12 changed files
with
168 additions
and
78 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
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
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
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
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
64 changes: 64 additions & 0 deletions
64
...Authorization/Overrides/StudentAssessmentRelationshipsAuthorizationContextDataProvider.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,64 @@ | ||
// 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 EdFi.Ods.Api.Security.AuthorizationStrategies.Relationships; | ||
using EdFi.Ods.Entities.Common.EdFi; | ||
using EdFi.Ods.Entities.NHibernate.StudentAssessmentAggregate.EdFi; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace EdFi.Ods.Standard.Security.Authorization.Overrides | ||
{ | ||
/// <summary> | ||
/// Creates and returns an <see cref="RelationshipsAuthorizationContextData"/> instance for making authorization decisions for access to the edfi.StudentAssessment table of the StudentAssessment aggregate in the Ods Database. | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
public class StudentAssessmentRelationshipsAuthorizationContextDataProvider<TContextData> : IRelationshipsAuthorizationContextDataProvider<IStudentAssessment, TContextData> | ||
where TContextData : RelationshipsAuthorizationContextData, new() | ||
{ | ||
/// <summary> | ||
/// Creates and returns an <see cref="TContextData"/> instance based on the supplied resource. | ||
/// </summary> | ||
public TContextData GetContextData(IStudentAssessment resource) | ||
{ | ||
if (resource == null) | ||
{ | ||
throw new ArgumentNullException(nameof(resource), "The 'studentAssessment' resource for obtaining authorization context data cannot be null."); | ||
} | ||
|
||
var entity = resource as StudentAssessment; | ||
|
||
var contextData = new TContextData | ||
{ | ||
SchoolId = entity.ReportedSchoolId, // Role name applied and not part of primary key | ||
StudentUSI = entity.StudentUSI == default ? null : entity.StudentUSI // Primary key property, USI | ||
}; | ||
|
||
return contextData; | ||
} | ||
|
||
/// <summary> | ||
/// Creates and returns a signature key based on the resource, which can then be used to get and instance of IEdFiSignatureAuthorizationProvider | ||
/// </summary> | ||
public string[] GetAuthorizationContextPropertyNames() | ||
{ | ||
var properties = new[] | ||
{ | ||
"ReportedSchoolId", | ||
"StudentUSI", | ||
}; | ||
|
||
return properties; | ||
} | ||
|
||
/// <summary> | ||
/// Creates and returns an <see cref="RelationshipsAuthorizationContextData"/> instance based on the supplied resource. | ||
/// </summary> | ||
public TContextData GetContextData(object resource) | ||
{ | ||
return GetContextData((StudentAssessment)resource); | ||
} | ||
} | ||
} |
Oops, something went wrong.