Commit Graph

88 Commits

Author SHA1 Message Date
Matthias Hanel
eb1a91d5b6 [fixed] private import issue by pulling in up to date jwt library
Also prevent nats based account resolver from storing invalid jwt
Updated compress and highwayhash

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-03-14 19:37:14 -04:00
Matthias Hanel
c50ee2a1c6 [Changed] all times exposed will be computed in UTC (#1943)
This also applies to times that end up in that json.
Where applicable moved time.Now() to where it is used.
Moved calls to .UTC() to where time is created it that time is converted
later anyway.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-03-02 21:37:42 -05:00
Matthias Hanel
0cae6ab4e7 [added] support for jwt based account mappings (#1897)
support for jwt based account mappings

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-02-08 17:25:14 -05:00
Derek Collison
c11a733502 Broken test for non MarshalIndent
Signed-off-by: Derek Collison <derek@nats.io>
2021-02-07 05:08:22 -08:00
Matthias Hanel
3799b90011 [Adding] support for account_token_position (#1874)
This change does 4 things:
Refactor to only have one function to validate imports.
Have this function support the jwt field account_token_position.
For completeness make this value configurable as well.
unit tests.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-02-01 19:51:36 -05:00
Matthias Hanel
ffc20e950b [removed] activation token download (#1867)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-02-01 12:30:47 -05:00
Derek Collison
8bd290c77a Fix for #1864.
When trying to make sure we properly created all subs for service imports we would check the internal client to see if we should process.
With JS enabled on the server we would place system imports that would break that check and orphan other service imports.

Signed-off-by: Derek Collison <derek@nats.io>
2021-01-29 17:51:14 -08:00
Matthias Hanel
2761bbf29a added test demonstrating how js breaks imports
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-29 14:29:04 -05:00
Matthias Hanel
dea9effa8d [added] support for StrictSigningKeyUsage and updated jwt library (#1845)
This will cause the server to not trust accounts/user signed by an
identity key

The boot strapping system account will assume the account is issued by
the operator.
If this is not desirable, the system account can be provided right away
as resolver_preload.

[fixes] crash when the system account uses signing keys and an update changes that key set.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-26 17:49:58 -05:00
Matthias Hanel
d35cd2996d [added] jwt/issuerkey/nametag/tags to monitoring and event endpoints (#1830)
Also added a trace on jwt authentication

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-21 21:16:34 -05:00
Ivan Kozlovic
6f8285b1f0 Merge pull request #1806 from nats-io/latency-sharing
Fixing latency sharing which was overwritten
2021-01-14 16:57:15 -07:00
Matthias Hanel
f1af382929 Fixing latency sharing which was overwritten
Also adjusting unit test to not check for renamed values

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-14 18:47:44 -05:00
Ivan Kozlovic
343968067c Merge pull request #1805 from nats-io/scoped-signing-keys
[added] enforcement and usage of scoped signing keys
2021-01-14 15:24:28 -07:00
Matthias Hanel
2cb5f1b391 Fix flapping unit test and incorporate more review comments
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-14 16:59:57 -05:00
Matthias Hanel
c14076b13f Incorporating review comments
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-14 15:15:20 -05:00
Matthias Hanel
2edd883a6e [added] enforcement and usage of scoped signing keys
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-14 14:52:54 -05:00
Derek Collison
4bfe9d4c24 Fixes to PR.
Add nats to default storage directory
Fix race in raft, change leader notice
Fix test crash on failure

Signed-off-by: Derek Collison <derek@nats.io>
2021-01-14 05:56:05 -08:00
Derek Collison
37cf7584bd Merge branch 'master' into jsc 2021-01-14 02:52:35 -07:00
Derek Collison
f0cdf89c61 JetStream Clustering WIP
Signed-off-by: Derek Collison <derek@nats.io>
2021-01-14 01:14:52 -08:00
Matthias Hanel
9c2bf8e4a9 [Added] support for jwt export response threshold
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-14 01:12:35 -08:00
Matthias Hanel
431b642cbe Incorporating review comments
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-07 18:19:25 -05:00
Matthias Hanel
0ff6252692 Added tests for cfg/jwt based queue restrictions and updated jwt lib
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-07 17:30:51 -05:00
Matthias Hanel
1149c4cef9 [Added] support for jwt export response threshold
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-05 19:52:52 -05:00
Matthias Hanel
592a6447a7 [Added] support for wildcard services and import remapping by JWT.
Imports in JWT where extended to contain a new filed LocalSubject.
This Change pulls the new JWT library version in.
It was needed as prefix did not exist in the JWT library and the
original field could not be used. The field To has been deprecated.

When LocalSubject is set, service imports can be configured the same way
they are in config. Meaning, no reversal due to the type.

This change also ensures that wildcard references in transforms are only
set in To/LocalSubject. Before, for services, $1 would have to be set in Subject.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-01-04 14:11:36 -05:00
Matthias Hanel
c6daffbfcc [Added] ability to use jwt latency sampling properties headers/share
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-12-16 14:34:09 -05:00
Alberto Ricart
3c0cc64877 fixed testing of the user issuer against the account id (Name) - was set to Issuer instead
added some tests.

FIX #1740
2020-11-23 17:38:34 -06:00
Derek Collison
63477acb61 Merge pull request #1658 from nats-io/waitq
[JetStream] Upgrade for wait queues for pull based consumers
2020-10-22 09:59:57 -07:00
Matthias Hanel
2144f01f21 Adding support and an option for removal of jwt
To enable in full mode configure allow_delete: true
When enabled the file will be renamed to allow for manual restore.

In cache mode it will be enabled by default.
When enabled files will be deleted.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-20 16:45:11 -04:00
Derek Collison
a37f53e236 Updated tests for addition of ErrNoResponders
Signed-off-by: Derek Collison <derek@nats.io>
2020-10-19 20:11:52 -07:00
Matthias Hanel
bb63fd5f40 Adding list/delete/update operations for jwt stored by nats-resolver
Update already existed scoped by account, this exposes update without account.
List returns a list of all stored accounts.
Delete deletes accounts.
Fix a crash on startup with non existing directory.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-12 18:07:07 -04:00
Matthias Hanel
387e1e1ee4 [Fixed] revocation check used current time instead of jwt issue time
Also empty revoked keys once account jwt has no revocations.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-06 21:45:34 -04:00
Matthias Hanel
01453e03cd Add defer srv.Shutdown() where manual shutdown was done
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-29 15:54:20 -04:00
Matthias Hanel
4e055d7b72 Fixing test race condition
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-29 14:36:04 -04:00
Matthias Hanel
f3e6cd12ec Adding fetch on missing jwt of full nats based resolver
Full nats based resolver sync within a cluster.
This functionality addresses syncing between cluster.

Fixing deadlock when more than one server responds to lookup.
Fixing crash when shutdown and pack happen at the same time.
2020-09-29 14:36:04 -04:00
Matthias Hanel
3d2b65228a [Fixed] race condition where account conns timer was disabled too soon
The connection count sent and the connection count used to determine if
the timer should be disabled could differ.

Also fixed issues in unit test triggering this behavior.
It did not check if remote connections where set to 0 prior to doing
more tests.

Fixes #1613

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-24 18:49:32 -04:00
Matthias Hanel
634ce9f7c8 [Adding] Accountz monitoring endpoint and INFO monitoring req subject
Returned imports/exports are formated like jwt exports imports, even if
they originating account is from config.

Fixes #1604

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-23 16:22:48 -04:00
Matthias Hanel
5df6cb425c Add $SYS.REQ.ACCOUNT.%s.CLAIMS.UPDATE
Old $SYS.ACCOUNT.%s.CLAIMS.UPDATE is keept for backwards compatibility.
The old name is in the same name space as events.
To be able to abuse this, an attacker needs to be in possession of the
operator key as well.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-21 14:32:17 -04:00
Matthias Hanel
d6ab6799b4 Fixing unit test
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-04 17:14:51 -04:00
Matthias Hanel
a3c5fd4575 Updating jetstream account settings from jwt
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-04 16:07:38 -04:00
Matthias Hanel
3954030abf [FIXED] Error when importing an account results in an error, retry later (#1578)
* [FIXED] Error when importing an account results in an error

When the account that could not be imported is updated, update the
original account as well.

Fixes #1582

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-09-03 13:57:06 -06:00
Matthias Hanel
b02b6215b6 Support locale for times in user jwt
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-28 16:01:00 -04:00
Matthias Hanel
cc14e54179 Discard client provided jwt when not in operator mode
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-28 12:31:02 -04:00
Matthias Hanel
431560b004 Update JWT and incorporate change of cidr ranges from string to array
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-27 23:11:54 -04:00
Matthias Hanel
846b2b5ce0 Fix flapping test and limit channel recv when there is an error
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-25 00:36:14 -04:00
Matthias Hanel
9d1526cbb8 Adding user jwt payload and subscriber limits
Addresses part of #1552

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-24 18:16:25 -04:00
Matthias Hanel
9bad6725aa Speed up test and make it more robust (#1569)
* Speed up test and make it more robust

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-21 17:41:44 -06:00
Matthias Hanel
6c61464915 [ADDED] Checks for CIDR blocks and connect time ranges specified in jwt (#1567)
because times stored are hh:mm:ss it is possible to end up with start > end where end is actually the next day.
jwt.go line 189

Also, ranges are based on the servers location, not the clients.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-20 13:28:16 -06:00
Matthias Hanel
48c87c1447 Nats based resolver & avoiding nats account server in smaller deployments (#1550)
* Adding nats based resolver and bootstrap system account

These resolver operate on an exclusive  directory
Two types:
full: managing all jwt in the directory
    Will synchronize with other full resolver
    nats-account-server will also run such a resolver
cache: lru cache managing only a subset of all jwt in the directory
    Will lookup jwt from full resolver
    Can overwrite expiration with a ttl for the file

Both:
    track expiration of jwt and clean up
    Support reload
    Notify the server of changed jwt

Bootstrapping system account allows users signed with the system account
jwt to connect, without the server knowing the jwt.
This allows uploading jwt (including system account) using nats by
publishing to $SYS.ACCOUNT.<name>.CLAIMS.UPDATE
Sending a request, server will respond with the result of the operation.

Receive all jwt stored in one server by sending a
request to $SYS.ACCOUNT.CLAIMS.PACK
One server will respond with a message per stored jwt.
The end of the responses is indicated by an empty message.

The content of dirstore.go and dirstore_test.go was moved from
nats-account-server

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-08-18 13:58:41 -06:00
Matthias Hanel
37692d2cf9 [Fixed] Skip fetch when a non config based account resolver is used
Resolves #1532

Instead of the fetched account we create a dummy account that is
expired. Any client connecting will trigger a fetch of the actual
account jwt.

This also avoids one fetch, thus the unit test was changed to reflect
this.
Unlike other resolver the memory resolver does not depend on external
systems. It is purely based on server configuration. Therefore, fetch
can be done and not finding an account means there is a configuration issue.
2020-07-27 17:36:55 -04:00
Matthias Hanel
99921725a9 Ensuring that an untrusted account is not held in memory
The check that an account has to be signed by a configured operator is
done after fetch as well. As a consequence an account claim will never
become an Account in memory.
The original check during client or leaf authentication is left in
place.

Adding unit tests.
Modifying existing tests to not rely on an account but it's name instead.

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-07-27 11:59:49 -04:00