nats.net.v2 icon indicating copy to clipboard operation
nats.net.v2 copied to clipboard

NatsOpts.ConfigureWebSocketOpts callback handler

Open wolfman42 opened this issue 1 year ago • 4 comments

As discussed in #305 this PR is adding support for manipulating the ClientWebSocketOptions used for WebSocket connections. Among other things, this allows setting an authorization header.

wolfman42 avatar Aug 16 '24 15:08 wolfman42

I left this in draft state to see if it'll pass all tests within the pipeline first. If a maintainer could approve running the pipeline I'd appreciate. @mtmk

wolfman42 avatar Aug 16 '24 15:08 wolfman42

@wolfman42 done.

galvesribeiro avatar Aug 16 '24 15:08 galvesribeiro

@galvesribeiro I think (hope) the issues are fixed now.

wolfman42 avatar Aug 16 '24 19:08 wolfman42

@wolfman42 convert it out of draft when you feel ready and others can review it.

galvesribeiro avatar Aug 16 '24 19:08 galvesribeiro

Thanks @wolfman42. Could you also sing your commits please? it's a CNCF requirement we need to follow.

mtmk avatar Aug 20 '24 11:08 mtmk

I checked but don't think my changes could affect this failing unit test: NATS.Client.JetStream.Tests.ConsumerConsumeTest.Consume_dispose_test Perhaps run the tests again?

wolfman42 avatar Aug 21 '24 11:08 wolfman42

I checked but don't think my changes could affect this failing unit test: NATS.Client.JetStream.Tests.ConsumerConsumeTest.Consume_dispose_test Perhaps run the tests again?

it's a flapper. I'm rerunning it now.

mtmk avatar Aug 21 '24 14:08 mtmk

Thanks @wolfman42. Could you also sing your commits please? it's a CNCF requirement we need to follow.

sorry @wolfman42 could you sign all your commits please? (you will have to force push, which should be fine) we set github checks, unfortunately can't merge with unsigned commits. thanks.

mtmk avatar Aug 21 '24 15:08 mtmk

Thanks @wolfman42. Could you also sing your commits please? it's a CNCF requirement we need to follow.

sorry @wolfman42 could you sign all your commits please? (you will have to force push, which should be fine) we set github checks, unfortunately can't merge with unsigned commits. thanks.

Done. I went ahead and squashed the 3 commits as well.

wolfman42 avatar Aug 21 '24 19:08 wolfman42

A couple more ideas, which could be done in a follow-up before releasing:

  1. Do we want to nest this option under NatsWebSocketOpts instead of setting it directly in NatsOpts? This could make it easier to offer a shortcuts for popular options such as adding headers:
public sealed record NatsWebSocketOpts
{
    public Dictionary<string, StringValues>? RequestHeaders { get; init; }

    public Func<Uri, ClientWebSocketOptions, CancellationToken, ValueTask>? ConfigureWebSocketOptions { get; init; }
}
  1. We probably want to invoke NatsTlsOpts.AuthenticateAsClientOptionsAsync and copy both ClientCertificates and RemoteCertificateValidationCallback to ClientWebSocketOptions prior to passing it to the callback

caleblloyd avatar Aug 21 '24 19:08 caleblloyd

A couple more ideas, which could be done in a follow-up before releasing:

Great ideas @caleblloyd created #610 so we don't forget ;) let us know if you want more changes to this PR? We might release a preview with this PR but we'll make sure #610 is resolved before a stable release.

mtmk avatar Aug 22 '24 19:08 mtmk

merging so @Ivandemidov00 can have a look with #610

mtmk avatar Aug 24 '24 11:08 mtmk