Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update session id and description for user interaction in device flow #802

Merged
merged 1 commit into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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