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

Do not auto-include custom ciba request params in response #1512

Merged
merged 4 commits into from
Jan 16, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task WriteHttpResponse(BackchannelAuthenticationResult result, Http
expires_in = result.Response.ExpiresIn,
interval = result.Response.Interval,

Properties = result.Response.Properties
Custom = result.Response.Custom
});
}
}
Expand All @@ -84,7 +84,7 @@ internal class SuccessResultDto
public int interval { get; set; }

[JsonExtensionData]
public Dictionary<string, object> Properties { get; set; }
public Dictionary<string, object> Custom { get; set; }
#pragma warning restore IDE1006 // Naming Styles
}

Expand Down
5 changes: 3 additions & 2 deletions src/IdentityServer/Models/BackchannelUserLoginRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ public class BackchannelUserLoginRequest
public ResourceValidationResult ValidatedResources { get; set; } = default!;

/// <summary>
/// Gets or sets a dictionary of custom properties that can pass additional
/// state to the notification process.
/// Gets or sets a dictionary of custom properties associated with this
/// request. These properties by default are copied from the validated
/// custom request parameters.
/// </summary>
public Dictionary<string, object> Properties { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public virtual async Task<BackchannelAuthenticationResponse> ProcessAsync(Backch
AuthenticationRequestId = requestId,
ExpiresIn = request.Lifetime,
Interval = interval,
Properties = validationResult.ValidatedRequest.Properties
};

await UserLoginService.SendLoginRequestAsync(new BackchannelUserLoginRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ public BackchannelAuthenticationResponse(string error, string errorDescription =
public int Interval { get; set; }

/// <summary>
/// Gets or sets a dictionary of custom properties that can pass additional
/// state in the response to the client application.
/// Gets or sets a dictionary of custom properties that will be included in
/// the response to the client. This dictionary is intended to be used to
/// implement extensions to CIBA that defines additional response
/// parameters.
/// </summary>
public Dictionary<string, object> Properties { get; set; } = new();
public Dictionary<string, object> Custom { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ public class ValidatedBackchannelAuthenticationRequest : ValidatedRequest
public string? RequestObject { get; set; }

/// <summary>
/// Gets or sets a dictionary of custom properties that can pass
/// additional state to the back channel authentication process.
/// Gets or sets a dictionary of validated custom request parameters. Custom
/// request parameters should be validated and added to this collection in
/// an <see cref="ICustomBackchannelAuthenticationValidator"/>. These
/// properties are persisted to the store and made available in the
/// backchannel authentication UI and notification services.
/// </summary>
public Dictionary<string, object> Properties { get; set; } = new();
}
4 changes: 3 additions & 1 deletion src/Storage/Models/BackChannelAuthenticationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public class BackChannelAuthenticationRequest
public string? Description { get; set; }

/// <summary>
/// Gets or sets a dictionary of custom properties associated with this instance.
/// Gets or sets a dictionary of custom properties associated with this
/// request. These properties by default are copied from the validated
/// custom request parameters.
/// </summary>
public Dictionary<string, object> Properties { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public async Task custom_validators_are_invoked_and_can_process_custom_input()

[Fact]
[Trait("Category", Category)]
public async Task custom_validator_can_add_complex_properties_that_are_passed_to_user_notification_and_client_response()
public async Task custom_validator_can_add_complex_properties_that_are_passed_to_user_notification_but_not_client_response()
{
_mockCustomBackchannelAuthenticationValidator.Thunk = ctx =>
{
Expand Down Expand Up @@ -281,13 +281,12 @@ public async Task custom_validator_can_add_complex_properties_that_are_passed_to
IdentityServerPipeline.BackchannelAuthenticationEndpoint,
new FormUrlEncodedContent(body));

// Custom properties are flattened into the response to the client
// Custom request properties are not included automatically in the response to the client
response.StatusCode.Should().Be(HttpStatusCode.OK);
var responseContent = await response.Content.ReadAsStringAsync();
var json = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(responseContent);
json.Should().NotBeNull();
var complex = json["complex"];
complex.TryGetValue("nested").GetString().Should().Be("value");
json.Should().NotContainKey("complex");

// Custom properties are passed to the notification service
var notificationProperties = _mockCibaUserNotificationService.LoginRequest.Properties;
Expand Down