Skip to content

Commit

Permalink
Merge pull request #97 from LtiLibrary/net6
Browse files Browse the repository at this point in the history
Upgrade to .NET6
  • Loading branch information
srijken authored Aug 13, 2024
2 parents 164033b + c125c41 commit c29fa4e
Show file tree
Hide file tree
Showing 55 changed files with 550 additions and 673 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
#if NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace LtiAdvantage.AspNetCore.AssignmentGradeServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
#if NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace LtiAdvantage.AspNetCore.AssignmentGradeServices
{
Expand Down
4 changes: 2 additions & 2 deletions src/LtiAdvantage.AspNetCore/LtiAdvantage.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>ASP.NET Core library with IMS LTIAdvantage support for Tool Consumer and Tool Provider applications.</Description>
<AssemblyTitle>LtiAdvantage.AspNetCore</AssemblyTitle>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<AssemblyName>LtiAdvantage.AspNetCore</AssemblyName>
<PackageId>LtiAdvantage.AspNetCore</PackageId>
<PackageTags>IMS;LTI;LTIAdvantage;.NET Core</PackageTags>
Expand Down Expand Up @@ -40,7 +40,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.19" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.24" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
#if NETSTANDARD2_0
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#endif

namespace LtiAdvantage.AspNetCore.NamesRoleProvisioningService
{
Expand Down
12 changes: 6 additions & 6 deletions src/LtiAdvantage.IdentityModel/Client/AccessTokenUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ public static async Task<TokenResponse> GetAccessTokenAsync(string issuer, strin
{
if (issuer.IsMissing())
{
return new TokenResponse(new ArgumentNullException(nameof(issuer)));
return ProtocolResponse.FromException<TokenResponse>(new ArgumentNullException(nameof(issuer)));
}

if (scopes == null)
{
return new TokenResponse(new ArgumentNullException(nameof(scopes)));
return ProtocolResponse.FromException<TokenResponse>(new ArgumentNullException(nameof(scopes)));
}

if (clientId.IsMissing())
{
return new TokenResponse(new ArgumentNullException(nameof(clientId)));
return ProtocolResponse.FromException<TokenResponse>(new ArgumentNullException(nameof(clientId)));
}

if (accessTokenUrl.IsMissing())
{
return new TokenResponse(new ArgumentNullException(nameof(accessTokenUrl)));
return ProtocolResponse.FromException<TokenResponse>(new ArgumentNullException(nameof(accessTokenUrl)));
}

if (privateKey.IsMissing())
{
return new TokenResponse(new ArgumentNullException(nameof(privateKey)));
return ProtocolResponse.FromException<TokenResponse>(new ArgumentNullException(nameof(privateKey)));
}

// Use a signed JWT as client credentials.
Expand All @@ -63,7 +63,7 @@ public static async Task<TokenResponse> GetAccessTokenAsync(string issuer, strin
EpochTime.GetIntDate(DateTime.UtcNow.AddSeconds(-5)).ToString(), ClaimValueTypes.Integer64));
payload.AddClaim(new Claim(JwtRegisteredClaimNames.Exp,
EpochTime.GetIntDate(DateTime.UtcNow.AddMinutes(5)).ToString(), ClaimValueTypes.Integer64));
payload.AddClaim(new Claim(JwtRegisteredClaimNames.Jti, CryptoRandom.CreateRandomKeyString(32)));
payload.AddClaim(new Claim(JwtRegisteredClaimNames.Jti, Convert.ToBase64String(CryptoRandom.CreateRandomKey(32))));

var handler = new JwtSecurityTokenHandler();
var credentials = PemHelper.SigningCredentialsFromPemString(privateKey);
Expand Down
5 changes: 3 additions & 2 deletions src/LtiAdvantage.IdentityModel/Client/PemHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Security.Cryptography;
using IdentityModel;
using Microsoft.IdentityModel.Tokens;
Expand All @@ -25,7 +26,7 @@ public class RsaKeyPair
{
public RsaKeyPair()
{
KeyId = CryptoRandom.CreateRandomKeyString(8);
KeyId = Convert.ToBase64String(CryptoRandom.CreateRandomKey(8));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>.NET Core library with IMS LTIAdvantage support for Tool Consumer and Tool Provider applications.</Description>
<AssemblyTitle>LtiAdvantage.IdentityModel</AssemblyTitle>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>LtiAdvantage.IdentityModel</AssemblyName>
<PackageId>LtiAdvantage.IdentityModel</PackageId>
<PackageTags>IMS;LTI;LTIAdvantage;.NET Core</PackageTags>
Expand All @@ -15,13 +15,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle.NetCore" Version="1.9.0" />
<PackageReference Include="IdentityModel" Version="3.10.5" />
<PackageReference Include="BouncyCastle.NetCore" Version="2.2.1" />
<PackageReference Include="IdentityModel" Version="6.2.0" />
<PackageReference Include="MinVer" Version="4.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>.NET Core library with IMS LTIAdvantage support for Tool Consumer and Tool Provider applications.</Description>
<AssemblyTitle>LtiAdvantage.IdentityServer4</AssemblyTitle>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>LtiAdvantage.IdentityServer4</AssemblyName>
<PackageId>LtiAdvantage.IdentityServer4</PackageId>
<PackageTags>IMS;LTI;LTIAdvantage;.NET Core</PackageTags>
Expand All @@ -15,8 +15,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle.NetCore" Version="1.9.0" />
<PackageReference Include="IdentityServer4" Version="2.3.2" />
<PackageReference Include="BouncyCastle.NetCore" Version="2.2.1" />
<PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="MinVer" Version="4.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
5 changes: 2 additions & 3 deletions src/LtiAdvantage/AssignmentGradeServices/ActivityProgress.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace LtiAdvantage.AssignmentGradeServices
{
/// <summary>
/// The activity progress or status.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ActivityProgress
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace LtiAdvantage.AssignmentGradeServices
{
Expand All @@ -12,19 +12,19 @@ public class AssignmentGradeServicesClaimValueType
/// <summary>
/// The list of scopes the tool may ask for when requesting the access token.
/// </summary>
[JsonProperty("scope")]
[JsonPropertyName("scope")]
public IList<string> Scope { get; set; }

/// <summary>
/// The fully resolved URL to the line item endpoint associated with the resource link.
/// </summary>
[JsonProperty("lineitem")]
[JsonPropertyName("lineitem")]
public string LineItemUrl { get; set; }

/// <summary>
/// The fully resolved URL to the line items endpoint associated with the context.
/// </summary>
[JsonProperty("lineitems")]
[JsonPropertyName("lineitems")]
public string LineItemsUrl { get; set; }
}
}
5 changes: 2 additions & 3 deletions src/LtiAdvantage/AssignmentGradeServices/GradingProgess.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace LtiAdvantage.AssignmentGradeServices
{
/// <summary>
/// The grading progress.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum GradingProgess
{
/// <summary>
Expand Down
18 changes: 9 additions & 9 deletions src/LtiAdvantage/AssignmentGradeServices/LineItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace LtiAdvantage.AssignmentGradeServices
{
Expand All @@ -11,50 +11,50 @@ public class LineItem
/// <summary>
/// The end date and time.
/// </summary>
[JsonProperty("endDateTime")]
[JsonPropertyName("endDateTime")]
public DateTime? EndDateTime { get; set; }

/// <summary>
/// The endpoint url for this item.
/// </summary>
[JsonProperty("id")]
[JsonPropertyName("id")]
public string Id { get; set; }

/// <summary>
/// Optional, human-friendly label for this LineItem suitable for display.
/// For example, this label might be used as the heading of a column in a gradebook.
/// </summary>
[JsonProperty("label")]
[JsonPropertyName("label")]
public string Label { get; set; }

/// <summary>
/// The resource link id.
/// </summary>
[JsonProperty("resourceLinkId")]
[JsonPropertyName("resourceLinkId")]
public string ResourceLinkId { get; set; }

/// <summary>
/// The non-link resource id.
/// </summary>
[JsonProperty("resourceId")]
[JsonPropertyName("resourceId")]
public string ResourceId { get; set; }

/// <summary>
/// The maximum score allowed.
/// </summary>
[JsonProperty("scoreMaximum")]
[JsonPropertyName("scoreMaximum")]
public double? ScoreMaximum { get; set; }

/// <summary>
/// The start date and time.
/// </summary>
[JsonProperty("startDateTime")]
[JsonPropertyName("startDateTime")]
public DateTime? StartDateTime { get; set; }

/// <summary>
/// Optional tag.
/// </summary>
[JsonProperty("tag")]
[JsonPropertyName("tag")]
public string Tag { get; set; }
}
}
15 changes: 8 additions & 7 deletions src/LtiAdvantage/AssignmentGradeServices/Result.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;

using System.Text.Json.Serialization;

namespace LtiAdvantage.AssignmentGradeServices
{
Expand All @@ -15,37 +16,37 @@ public class Result
/// <summary>
/// The endpoint url for this result.
/// </summary>
[JsonProperty("id")]
[JsonPropertyName("id")]
public string Id { get; set; }

/// <summary>
/// A comment associated with this result.
/// </summary>
[JsonProperty("comment")]
[JsonPropertyName("comment")]
public string Comment { get; set; }

/// <summary>
/// Maximum result score.
/// </summary>
[JsonProperty("resultMaximum")]
[JsonPropertyName("resultMaximum")]
public double ResultMaximum { get; set; }

/// <summary>
/// The line item result.
/// </summary>
[JsonProperty("resultScore")]
[JsonPropertyName("resultScore")]
public double? ResultScore { get; set; }

/// <summary>
/// The line item.
/// </summary>
[JsonProperty("scoreOf")]
[JsonPropertyName("scoreOf")]
public string ScoreOf { get; set; }

/// <summary>
/// The user id.
/// </summary>
[JsonProperty("userId")]
[JsonPropertyName("userId")]
public string UserId { get; set; }
}
}
20 changes: 11 additions & 9 deletions src/LtiAdvantage/AssignmentGradeServices/Score.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Newtonsoft.Json;
using LtiAdvantage.Utilities;
using System;
using System.Text.Json.Serialization;

namespace LtiAdvantage.AssignmentGradeServices
{
Expand All @@ -11,43 +12,44 @@ public class Score
/// <summary>
/// Status of the user toward activity's completion.
/// </summary>
[JsonProperty("activityProgress")]
[JsonPropertyName("activityProgress")]
public ActivityProgress ActivityProgress { get; set; }

/// <summary>
/// A comment with the score.
/// </summary>
[JsonProperty("comment")]
[JsonPropertyName("comment")]
public string Comment { get; set; }

/// <summary>
/// The status of the grading process.
/// </summary>
[JsonProperty("gradingProgress")]
[JsonPropertyName("gradingProgress")]
public GradingProgess GradingProgress { get; set; }

/// <summary>
/// The score.
/// </summary>
[JsonProperty("scoreGiven")]
[JsonPropertyName("scoreGiven")]
public double ScoreGiven { get; set; }

/// <summary>
/// The maximum possible score.
/// </summary>
[JsonProperty("scoreMaximum")]
[JsonPropertyName("scoreMaximum")]
public double ScoreMaximum { get; set; }

/// <summary>
/// The UTC time the score was set. ISO 8601 format.
/// </summary>
[JsonProperty("timestamp")]
[JsonPropertyName("timestamp")]
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTime TimeStamp { get; set; }

/// <summary>
/// The user id.
/// </summary>
[JsonProperty("userId")]
[JsonPropertyName("userId")]
public string UserId { get; set; }
}
}
Loading

0 comments on commit c29fa4e

Please sign in to comment.