Commit Graph

1800 Commits

Author SHA1 Message Date
Phil Pennock
11d13dc082 ADR-0005 JWT Authentication Extensibility
Constrain our server auth nonce selection with a no-op change for the current
server code-base, in a way which we guarantee and expect clients to check for,
to buy us future proofing.
2020-07-01 12:27:52 -04:00
Derek Collison
1004bd5cae version bump
Signed-off-by: Derek Collison <derek@nats.io>
2020-07-01 08:13:24 -07:00
Derek Collison
ff8dfa8d35 Reordering for inbound processing
Signed-off-by: Derek Collison <derek@nats.io>
2020-07-01 07:33:34 -07:00
Derek Collison
06ca580334 Update write deadline, client processing and slow proxy
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-30 16:41:01 -07:00
Derek Collison
2a799e7f5f Track destination leafnode status
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-26 11:18:11 -07:00
Derek Collison
f41171c146 Merge pull request #1493 from nats-io/lnoc
Properly support leadnode clusters.
2020-06-26 10:36:47 -07:00
Derek Collison
920617d64a Updates based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-26 10:29:53 -07:00
Derek Collison
e1adb58b06 Support clustername change on reload, fixes #1492
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-26 09:48:54 -07:00
Derek Collison
6c805eebc7 Properly support leadnode clusters.
Leafnodes that formed clusters were partially supported. This adds proper support for origin cluster, subscription suppression and data message no echo for the origin cluster.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-26 09:03:22 -07:00
Derek Collison
797dd1a8c9 bump version
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-19 06:14:45 -07:00
Derek Collison
120402241a Fix for #1486
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-18 21:04:34 -07:00
Derek Collison
9bf85aca2b Merge pull request #1483 from nats-io/fs_bug
Run expiration only once at a time and double check cache, fixes #1482
2020-06-18 14:07:33 -07:00
Derek Collison
95462cde57 Fix for memory expiration and age timer
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-18 14:02:11 -07:00
Derek Collison
c7e4d8b194 Avoid data race on cluster name
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-18 13:17:50 -07:00
Ivan Kozlovic
dc88143b82 Merge pull request #1477 from pas2k/ws_cookie_auth
[ADDED] Cookie JWT auth for WebSocket
2020-06-18 14:01:14 -06:00
Ivan Kozlovic
c86bb0b3f2 Merge pull request #1481 from nats-io/filter_ping
Add filtering by name and cluster to PING events
2020-06-18 13:45:07 -06:00
Derek Collison
a13402cd01 Run expiration only once at a time and double check cache, fixes #1482
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-18 12:14:25 -07:00
Pavel Khlebovich
d5eb9ff6f2 Support Cookie JWT auth via WebSocket 2020-06-18 19:27:42 +03:00
Derek Collison
fa744fdcda Proper no response
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-17 15:47:55 -07:00
Derek Collison
6c69c6ae48 Off by one, and need to send in place
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-17 15:32:26 -07:00
Matthias Hanel
1309605563 Filter by host and json name change
Also added more unit tests

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-06-17 15:10:41 -04:00
Matthias Hanel
d086a39b64 Add filtering by name and cluster to PING events
On cluster name change, reset internalSendLoop so it picks up the
changed name.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-06-16 18:26:35 -04:00
Derek Collison
cef1fdae0b Bump version
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-16 14:50:43 -07:00
Derek Collison
3729552a37 Always check publish perms for leafnode delivery
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-16 13:34:53 -07:00
Derek Collison
98f84bdbc8 Make sure to merge with local deny clauses
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-16 11:56:24 -07:00
Derek Collison
3541e3f0f9 Updated older tests for new functionality
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-16 10:56:39 -07:00
Derek Collison
ca4f03c1a6 Properly handle leafnode spoke permissions.
When a leafnode would connect with credentials that had permissions the spoke did not have a way of knowing what those were.
This could lead to being disconnected when sending subscriptions or messages to the hub which were not allowed.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-16 08:33:09 -07:00
Derek Collison
e1c397342c Merge branch 'master' into no_responders 2020-06-15 10:23:01 -07:00
Derek Collison
ddb4219f7a Allow support for a empty response message when no responders are present.
This will also set a response status of 503 with the new header support.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-15 10:10:21 -07:00
Derek Collison
2b9e3e5b15 Merge pull request #1476 from nats-io/cluster_name
Cluster names are now required.
2020-06-15 10:07:30 -07:00
Derek Collison
1e52a1007b More updates based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-13 08:00:57 -07:00
Derek Collison
146d8f5dcb Updates based on feedback, sped up some slow tests
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-12 17:26:43 -07:00
Derek Collison
dd61535e5a Cluster names are now required.
Added cluster names as required for prep work for clustered JetStream. System can dynamically pick a cluster name and settle on one even in large clusters.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-12 15:48:38 -07:00
Ivan Kozlovic
61cccbce02 [FIXED] LeafNode solicit failure race could leave conn registered
This was found due to a recent test that was flapping. The test
was not checking the correct server for leafnode connection, but
that uncovered the following bug:

When a leafnode connection is solicited, the read/write loops are
started. Then, the connection lock is released and several
functions invoked to register the connection with an account and
add to the connection leafs map.
The problem is that the readloop (for instance) could get a read
error and close the connection *before* the above said code
executes, which would lead to a connection incorrectly registered.

This could be fixed either by delaying the start of read/write loops
after the registration is done, or like in this PR, check the
connection close status after registration, and if closed, manually
undoing the registration with account/leafs map.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 16:01:13 -06:00
Ivan Kozlovic
d6de05f49a Fixed a test with data race
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 13:04:05 -06:00
Ivan Kozlovic
67d2638859 [ADDED] Print the config file being used in startup banner
Resolves #1451

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 12:21:50 -06:00
Ivan Kozlovic
02eb98c3c6 Merge pull request #1470 from nats-io/fix_websocket_auth_override_and_perf
[FIXED] LeafNode TLSMap and websocket auth override
2020-06-12 10:14:03 -06:00
Ivan Kozlovic
b60d5e6796 Fixed TestPing test
The test was not checking that PINGs were sent, however, without
disabling the first short ping and with a very low interval, there
was chance on Travis that the first short ping was sent before
the client had connected, which would break the NATS client protocol
that expects to receive a PONG to initial PING (after CONNECT).
The client library could arguably be updated to accept PING during
the CONNECT phase.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 10:03:47 -06:00
Ivan Kozlovic
d2a8282a0d [FIXED] LeafNode TLSMap and websocket auth override
We added authentication override block for websocket configuration
in PR #1463 and #1465 which somehow introduced a drop in perf as
reported by the bench tests.
This PR refactors a bit to restore the performance numbers.

This change also fixes the override behavior for websocket auth:
- If websocket's NoAuthUser is configured, the websocket's auth
  block MUST define Users, and the user be present.
- If there is any override (username/pwd,token,etc..) then the
  whole block config will be used when authenticating a websocket
  client, which means that if websocket NoAuthUser is empty we
  are not falling back to the regular client's NoAuthUser config.
- TLSMap always override the regular client's config. That is,
  whatever TLSMap value specified in the websocket's tls{} block
  will be used.

The TLSMap configuration was not used for LeafNodes. The behavior
now will be:
- If LeafNode's auth block contains users and TLSMap is true,
  the user is looked up based on the cert's info. If not found,
  authentication will fail. If found, it will be authenticated
  and bound to associated account.
- If no user is specified in LeafNode's auth block and TLSMap
  is true, then the cert's info will be used against the global
  users map.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-11 17:06:54 -06:00
Ivan Kozlovic
313cf898c1 Refactor some code to make it reuseable
Building server's nkeys and users map out of slices form options
has been made a function so it can be used for the server and
websocket (and in future for mqtt)

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-09 17:27:51 -06:00
Ivan Kozlovic
d18b013676 Merge pull request #1463 from nats-io/websocket_auth_block
Added dedicated auth block for websocket
2020-06-09 16:09:41 -06:00
Ivan Kozlovic
b9bd5c2d35 Fixed flappers
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-09 15:34:52 -06:00
Ivan Kozlovic
01b14c2abe Added dedicated auth block for websocket
Websocket can now override
- Username/password
- Token
- Users
- NKeys
- no_auth_user
- auth_timeout

For TLS, support for verify and verify_and_map. We used to set
tls config's ClientAuth to NoClientCert. It will now depend
if the config requires client certificate verification, which
is needed if TLSMap is enabled.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-09 11:29:52 -06:00
Derek Collison
bfe52fdb77 Merge pull request #1458 from nats-io/mixed
Allow mixed TLS and non-TLS on same port.
2020-06-08 11:12:45 -07:00
Ivan Kozlovic
cd6d71deaa [ADDED] lame_duck_grace_period option
The grace period used to be hardcoded at 10 seconds.
This option allows the user to configure the amount of time the
server will wait before initiating the closing of client connections.

Note that the grace period needs to be strictly lower than the overall
lame_duck_duration. The server deducts the grace period from that
overall duration and spreads the closing of connections during
that time.
For instance, if there are 1000 connections and the lame duck
duration is set to 30 seconds and grace period to 10, then
the server will use 30-10 = 20 seconds to spread the closing
of those 1000 connections, so say roughly 50 clients per second.

Resolves #1459.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-08 11:43:25 -06:00
Derek Collison
3a4e835311 Key off TLS first byte
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-06 13:41:34 -07:00
Derek Collison
75395ed862 Read 4 bytes, wait TLS timeout
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 18:38:20 -07:00
Derek Collison
4dee03b587 Allow mixed TLS and non-TLS on same port
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 18:04:11 -07:00
Derek Collison
d0f65c8a74 Don't leak service import subs on claim updates
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 13:28:40 -07:00
Ivan Kozlovic
82968f64d4 Merge pull request #1455 from nats-io/fix_ln_sub_interest_propagation
[FIXED] Unsubscribe may not be propagated through a leaf node
2020-06-05 11:11:26 -06:00