Skip to content

Commit

Permalink
Merge pull request #802 from DuendeSoftware/brock/device-flow
Browse files Browse the repository at this point in the history
update session id and description for user interaction in device flow
  • Loading branch information
brockallen authored Mar 18, 2022
2 parents b22c7ea + ed2d462 commit bd1778d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clients/src/ConsoleDeviceFlow/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Clients;
using Clients;
using IdentityModel;
using IdentityModel.Client;
using System;
Expand Down Expand Up @@ -35,7 +35,8 @@ static async Task<DeviceAuthorizationResponse> RequestAuthorizationAsync()
var response = await client.RequestDeviceAuthorizationAsync(new DeviceAuthorizationRequest
{
Address = disco.DeviceAuthorizationEndpoint,
ClientId = "device"
ClientId = "device",
ClientCredentialStyle = ClientCredentialStyle.PostBody
});

if (response.IsError) throw new Exception(response.Error);
Expand Down
6 changes: 6 additions & 0 deletions src/EntityFramework.Storage/Stores/DeviceFlowStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public virtual async Task UpdateByUserCodeAsync(string userCode, DeviceCode data

existing.SubjectId = data.Subject?.FindFirst(JwtClaimTypes.Subject).Value;
existing.Data = entity.Data;
existing.SessionId = data.SessionId;
existing.Description = data.Description;

try
{
Expand Down Expand Up @@ -194,6 +196,8 @@ public virtual async Task RemoveByDeviceCodeAsync(string deviceCode)
/// <returns></returns>
protected DeviceFlowCodes ToEntity(DeviceCode model, string deviceCode, string userCode)
{
// TODO: consider removing this in v7.0 since it's not properly/fully used

if (model == null || deviceCode == null || userCode == null) return null;

return new DeviceFlowCodes
Expand All @@ -202,6 +206,8 @@ protected DeviceFlowCodes ToEntity(DeviceCode model, string deviceCode, string u
UserCode = userCode,
ClientId = model.ClientId,
SubjectId = model.Subject?.FindFirst(JwtClaimTypes.Subject).Value,
SessionId = model.SessionId,
Description = model.Description,
CreationTime = model.CreationTime,
Expiration = model.CreationTime.AddSeconds(model.Lifetime),
Data = Serializer.Serialize(model)
Expand Down

0 comments on commit bd1778d

Please sign in to comment.