Skip to content

Commit 2f3c1d6

Browse files
fix: fixed an inaccuracy in the protocol implementation
1 parent 740c562 commit 2f3c1d6

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

HwProj.APIGateway/HwProj.APIGateway.API/Lti/Controllers/LtiAccessTokenController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async Task<IActionResult> GetTokenAsync([FromForm] IFormCollection form)
4949

5050
var unverifiedToken = handler.ReadJwtToken(clientAssertion);
5151

52-
var clientId = unverifiedToken.Subject;
52+
var clientId = unverifiedToken.Issuer;
5353

5454
var tool = toolService.GetByClientId(clientId);
5555
if (tool == null)
@@ -66,7 +66,7 @@ public async Task<IActionResult> GetTokenAsync([FromForm] IFormCollection form)
6666
handler.ValidateToken(clientAssertion, new TokenValidationParameters
6767
{
6868
ValidateIssuer = true,
69-
ValidIssuer = unverifiedToken.Issuer,
69+
ValidIssuer = tool.ClientId,
7070

7171
ValidateAudience = true,
7272
ValidAudience = tokenEndpointUrl,

HwProj.APIGateway/HwProj.APIGateway.API/Lti/Controllers/LtiDeepLinkingReturnController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task<IActionResult> OnDeepLinkingReturnAsync([FromForm] IFormCollec
4242
}
4343

4444
var unverifiedToken = Handler.ReadJwtToken(tokenString);
45-
var clientId = unverifiedToken.Subject;
45+
var clientId = unverifiedToken.Issuer;
4646

4747
var tool = toolService.GetByClientId(clientId);
4848
if (tool == null)
@@ -58,7 +58,7 @@ public async Task<IActionResult> OnDeepLinkingReturnAsync([FromForm] IFormCollec
5858
Handler.ValidateToken(tokenString, new TokenValidationParameters
5959
{
6060
ValidateIssuer = true,
61-
ValidIssuer = tool.issuer,
61+
ValidIssuer = tool.ClientId,
6262
ValidateAudience = true,
6363
ValidAudience = ltiPlatformOptions.Value.Issuer,
6464
ValidateLifetime = true,

HwProj.APIGateway/HwProj.APIGateway.API/Lti/Controllers/MockToolController.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private record MockTask(string Id, string Title, string Description, int Score);
3636
static MockToolController()
3737
{
3838
var rsa = RSA.Create(2048);
39-
var keyId = "mock-tool-key-id";
39+
const string keyId = "mock-tool-key-id";
4040
SigningKey = new RsaSecurityKey(rsa) { KeyId = keyId };
4141
}
4242

@@ -172,8 +172,7 @@ public IActionResult SubmitDeepLinkingSelection(
172172

173173
var payload = new JwtPayload
174174
{
175-
{ "iss", ToolIss },
176-
{ "sub", ToolNameId },
175+
{ "iss", ToolNameId },
177176
{ "aud", platformIssuer },
178177
{ "iat", DateTimeOffset.UtcNow.ToUnixTimeSeconds() },
179178
{ "exp", DateTimeOffset.UtcNow.AddMinutes(5).ToUnixTimeSeconds() },
@@ -333,8 +332,7 @@ public async Task<IActionResult> SendScore(
333332
private static string CreateClientAssertion(string platformIssuer)
334333
{
335334
var claims = new List<Claim> {
336-
new(JwtRegisteredClaimNames.Iss, ToolIss),
337-
new(JwtRegisteredClaimNames.Sub, ToolNameId),
335+
new(JwtRegisteredClaimNames.Iss, ToolNameId),
338336
new(JwtRegisteredClaimNames.Aud, $"{platformIssuer}/api/lti/token"),
339337
new(JwtRegisteredClaimNames.Iat, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64),
340338
new(JwtRegisteredClaimNames.Exp, DateTimeOffset.UtcNow.AddMinutes(5).ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64),

0 commit comments

Comments
 (0)