public async Task <InitRegistrationResponse> Generate(InitRegistrationRequestValidationResult validationResult) { var authorizationCode = new TrustedDeviceAuthorizationCode { ClientId = validationResult.Client.ClientId, DeviceId = validationResult.DeviceId, InteractionMode = validationResult.InteractionMode, CodeChallenge = validationResult.CodeChallenge.Sha256(), CreationTime = SystemClock.UtcNow.UtcDateTime, Lifetime = validationResult.Client.AuthorizationCodeLifetime, RequestedScopes = validationResult.RequestedScopes, Subject = validationResult.Principal }; var challenge = await CodeChallengeStore.GenerateChallenge(authorizationCode); return(new InitRegistrationResponse { Challenge = challenge }); }
public async Task <DeviceAuthorizationResponse> Generate(DeviceAuthorizationRequestValidationResult validationResult) { var authorizationCode = new TrustedDeviceAuthorizationCode { ClientId = validationResult.Client.ClientId, CodeChallenge = validationResult.CodeChallenge.Sha256(), CreationTime = SystemClock.UtcNow.UtcDateTime, DeviceId = validationResult.Device.DeviceId, InteractionMode = validationResult.InteractionMode, Lifetime = validationResult.Client.AuthorizationCodeLifetime, RequestedScopes = validationResult.RequestedScopes, Subject = Principal.Create("TrustedDevice", new Claim(JwtClaimTypes.Subject, validationResult.UserId)) }; var challenge = await CodeChallengeStore.GenerateChallenge(authorizationCode); return(new DeviceAuthorizationResponse { Challenge = challenge }); }