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

Runtime Authorization/Security reload #3004

Open
Biacode opened this issue Apr 5, 2022 · 22 comments
Open

Runtime Authorization/Security reload #3004

Biacode opened this issue Apr 5, 2022 · 22 comments

Comments

@Biacode
Copy link

Biacode commented Apr 5, 2022

Feature Request

The NATS server/client could support runtime auth/security context reload.

Use Case:

If I am connected to the NATS server with a JWT token for the X.Y.Z topic, I should be able to change my JWT without re-connecting to the server.
This could be a chat application. So you have access to the a.b.c session, then requesting for access to the x.y.z session and change your JWT without the required re-connect.

Proposed Change:

The changes should be made for both - the server and the client

Who Benefits From The Change(s)?

I think any client application that requires some User JWT will benefit from this feature.

Alternative Approaches

The main goal is to do this without re-connect. I don't see that many options here.

@derekcollison
Copy link
Member

100% agree and this has been in discussions for awhile. We will be turning our attention more towards the clients soon (we have alot!) and this as well as general simplifications, smart reconnect etc. are all on the table.

@Biacode
Copy link
Author

Biacode commented Apr 6, 2022

Thanks, @derekcollison, any idea where I can track this table? Surely many clients will benefit from this feature.

@derekcollison
Copy link
Member

Might make sense to create a discussion from this.

@Biacode
Copy link
Author

Biacode commented Apr 25, 2022

Any info on this? Where would you like to create a discussion?
The feature is convenient.

@windmeup
Copy link

It's very useful for me

@derekcollison
Copy link
Member

In your scenario, how would the new JWT be delivered to the client in order for the client to resend to the server?

@Biacode
Copy link
Author

Biacode commented Apr 26, 2022

Hi @derekcollison. I plan to sign valid user JWT using the Java back-end and NATS Account in my scenario.

@derekcollison
Copy link
Member

But you would need to get that to the end clients so they can resend to the server to change the JWT "on file" for the connection.

@Biacode
Copy link
Author

Biacode commented Apr 27, 2022

Hi @derekcollison, you didn't need any JWT file when you signed ephemeral User's JWT. I use Java SDK JwtUtils to generate a JWT token and authorize the connection. So no file is needed. You can create the token using the NATS account signing key (decentralized security).
The flow is the following:

  • Given we have a user
  • When the user authenticates in internal back-end
  • Then, the user can request a NATS JWT token (authorized)
  • Then, the user can connect to the NATS server using the JWT token
  • Then, the user can request a new NATS JWT token without closing the existing connection (to subscribe or publish on different NATS topics).

I hope this helps

@derekcollison
Copy link
Member

Yes that helps, what I was asking you solved for but the app/client requesting new tokens. That is what I meant by the JWT needs to make it way to the app somehow.

@Biacode
Copy link
Author

Biacode commented May 16, 2022

Hey folks. Any forecast on when this could be included in the NATS server? I can contribute to the Java and JS client-side implementation. Or even Go-Lang if you give me some hints on where to take a look.

@derekcollison
Copy link
Member

We are doing some client planning now (this is more client then server), will keep you posted.

@Biacode
Copy link
Author

Biacode commented May 17, 2022

As a suggestion, I think it would be reasonable to unsubscribe from all the previous subscriptions that the client has (after changing the JWT key).
This could also be delegated to the client and make it responsible for tracking the subscriptions and unsubscribing when needed. But perhaps some simple flag/parameter could do the job (e.g., pass argument like unsubscribe all, etc.).

@Biacode
Copy link
Author

Biacode commented Oct 11, 2022

Hello.
I wonder if there is any progress on this. Also, bumping the issue.
@derekcollison

@derekcollison
Copy link
Member

Yes we are progressing, lots of different requirements from different users/customers but you should see something hopefully before end of year.

@szdanowski
Copy link

@derekcollison Are there any updates around this issue? Is it still looking as something that can be available by the end of the year?

@derekcollison
Copy link
Member

This is planned for the 2.10 release, that and auth (and generic) callouts. The clients will need to be updated after server properly supports this but it will happen as part of the auth callout work with is the top priority after any bug fixes etc.

@derekcollison
Copy link
Member

I will code this out next week.

@windmeup
Copy link

windmeup commented Apr 4, 2023

I will code this out next week.

Is there any progress?

@derekcollison
Copy link
Member

Yes its completed and in the dev branch and part of the dev nightly builds which will become 2.10 probably sometime in May.

The auth callout also has its own ADR which has been kept up to date. So all there already and ready for the 2.10 release.

@brettinternet
Copy link

Can this be accomplished now by updating the UserJWT on Opts?

nc, err := nats.Connect(...)

nc.Opts.UserJWT = nats.UserJWT(userCB, sigCB)

@Jarema
Copy link
Member

Jarema commented Jul 29, 2024

@brettinternet unfortunately, no.
The Auth Callout is released, but that is a more complex solution.
We are planning simple auth-refresh to be worked on soon.

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

7 participants