Commit Graph

17 Commits

Author SHA1 Message Date
Waldemar Quevedo
3c4ed549a5 resolver: improve signaling for missing account lookups (#4151)
When using the nats account resolver and a JWT is not found, the client could
often get an i/o timeout error due to not receiving a timely response
before the account resolver fetch request times out. Now instead
of waiting for the fetch request to timeout, a resolver without JWTs
will notify as well that it could not find a matching JWT, waiting for a
response from all active servers.

Also included in this PR is some cleanup to the logs emitted by the
resolver.

Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-05-14 11:10:25 -07:00
Ivan Kozlovic
3c9a7cc6e5 Move to Go 1.19, remote io/util, fix data race and a flapper
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2022-08-05 09:55:37 -06:00
Matthias Hanel
64feb142a9 In Merge validate nkey and subsequent saveIfNewer error on invalid jwt (#2985)
Signed-off-by: Matthias Hanel <mh@synadia.com>
2022-03-31 14:25:25 -04:00
Derek Collison
84ff537e66 Make sure jwt claim update does not wipe system imports
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-17 10:03:30 -07:00
Derek Collison
a27b0dd673 Move default file and dir perms
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-19 14:46:07 -07:00
Matthias Hanel
6ffe9adf97 [added] disconnect of all clients and disable account on remove
Error sent to the client: Account Authentication Expired

Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-03-30 02:24:02 -04:00
Matthias Hanel
c3479d339e [added] ability to remove account jwt using an operator signing key
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-03-29 23:58:28 -04:00
Derek Collison
61771e88f8 In operator mode with JetStream we want to load accounts that have stable storage.
Also if an account was registered but not JetStream enabled, update it vs error.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-20 06:53:13 -07:00
Matthias Hanel
4f2db7d187 Fixed linter issues
Signed-off-by: Matthias Hanel <mh@synadia.com>
2021-03-02 20:21:44 -05:00
Matthias Hanel
e4b06cf7da Break test up into shorter ones
Also change ttl to be nanosecond interval and run parallel

Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-12-14 19:48:54 -05:00
Matthias Hanel
f5fd5e4f40 fix test timing issue and flapper caused by unnecessary pop/push 2020-12-03 21:14:04 -05: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
Matthias Hanel
8d8f6480d7 Incorporating comments
Signed-off-by: Matthias Hanel <mh@synadia.com>
2020-10-12 19:21:32 -04: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
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
Ivan Kozlovic
bd920c42bc Fix dirstore code and speed up some tests
When using Unix() time, since it is number of seconds, it is better
to round up the time before adding a ttl. Trying to shorten some
of the tests showed that in some cases a file was removed too early.
This was because the computed expiration with ttl fell in the same
second, so the file was removed prematurely.

So anywhere where we used to do: time.Now().Addd(ttl).Unix(), I
changed to time.Now().Round(time.Second).Add(ttl).Unix().

I was able to reduce the time of TestTTL from 21 seconds down to
less than 5. TestExpiration was also shorten.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-09-10 17:47:33 -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