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

Updating SuperStream Connection Access Token #340

Closed
Gsantomaggio opened this issue Dec 21, 2023 Discussed in #334 · 5 comments
Closed

Updating SuperStream Connection Access Token #340

Gsantomaggio opened this issue Dec 21, 2023 Discussed in #334 · 5 comments

Comments

@Gsantomaggio
Copy link
Member

Discussed in #334

Originally posted by lngvivek December 13, 2023
We are using SuperStream dotnet client version 1.7.2
For Authentication with Rabbit, we are using IdenitityServer Acces Token. It works perfectly on initial connection. However once the access toke expires, we were looking for something UpdateSecret (as used to be in Queue based sdk) on Connection object so that our connection is updated with lastest Access token. Could not find any such option for updating token to RabbitMQ.Stream.Client.StreamSystem. Could anyone pls suggest on how to refresh the token?

@Gsantomaggio
Copy link
Member Author

@simone-fariselli will follow this issue.

@simone-fariselli
Copy link
Contributor

Hi @Gsantomaggio,
I created the following method in the Client class:

internal async Task UpdateSecret()
{   
    var saslHandshakeResponse =
        await Request<SaslHandshakeRequest, SaslHandshakeResponse>(corr => new SaslHandshakeRequest(corr))
            .ConfigureAwait(false);
    _logger?.LogDebug("Sasl mechanism: {Mechanisms}", saslHandshakeResponse.Mechanisms);

    var saslData = Encoding.UTF8.GetBytes($"\0{Parameters.UserName}\0{Parameters.Password}");
    var authResponse =
        await Request<SaslAuthenticateRequest, SaslAuthenticateResponse>(corr =>
                new SaslAuthenticateRequest(corr, Parameters.AuthMechanism.ToString().ToUpperInvariant(),
                    saslData))
            .ConfigureAwait(false);
    ClientExceptions.MaybeThrowException(authResponse.ResponseCode, Parameters.UserName);
}

which should handle the change of secret (i.e of the access_token).

I get an applicative timeout and the following error log from the server:

unknown command {request,101,
                    {sasl_authenticate,<<"PLAIN">>,
                        <<0,103,117,101,115,116,0,103,117,101,115,116>>}}, sending close command.
Ignored unknown message emit_stats in state close_sent
Closing connection because of timeout in state 'close_sent' likely due to lack of client action.
unknown command {request,101,sasl_handshake}, sending close command.
Ignored unknown message emit_stats in state close_sent
Closing connection because of timeout in state 'close_sent' likely due to lack of client action.

I'm missing something.

@acogoluegnes
Copy link

@simone-fariselli Make sure to use 3.13 (alpha or RC). There's a test in the stream Java client suite.

The server PR that adds support to update a secret in a stream connection is in 3.13: rabbitmq/rabbitmq-server#9187.

@acogoluegnes
Copy link

Note the token update should be done transparently in the background. Getting a new token (by calling a specific CredentialsProvider implementation) and updating the token should be decoupled. The design of the AMQP .NET client should be appropriate for the stream client library as well.

@Gsantomaggio
Copy link
Member Author

dove via #342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants