Repository navigation
feat: [stable-8.0][OCSRE-1629] nats creds - #782
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A NATS server in operator (JWT) mode authenticates a client with a user JWT and an NKey seed. reva could connect to NATS only with a username and a password. The new package pkg/natsauth builds the nats.Option for a .creds file (nats.UserCredentials) or for the content of a .creds file (nats.UserCredentialBytes). The content takes precedence over the file. The package checks that the JWT and the seed can be parsed and that they match, so an invalid value gives a clear error at startup. - Event streams: stream.NatsConfig has the new fields CredsFile and Creds. NatsFromConfig passes the option to the natsjs plugin with natsjs.NatsOptions. All structs that convert to stream.NatsConfig have the new fields. - Stores: the new option store.Credentials sets the credentials for the nats-js and nats-js-kv stores. cache.Config, the IDCache users and the publicshares auth manager pass it. - When JWT credentials are set, reva does not send the username and the password. This change needs github.com/go-micro/plugins/v4/events/natsjs with the NatsOptions option (kobergj/plugins, branch NatsjskvWatcher). The replace directive follows when that change is merged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Merged
6 tasks done
Only the tests used natsauth.Enabled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
store.Create cannot return an error. For invalid NATS credentials it only logged an error. The service started and reported Ready, and each store operation failed later. Example: an invalid STORAGE_PUBLICLINK_STORE_CREDS made the system refuse all password protected public links. Check the credentials in the constructors that can return an error: - natsauth.Check checks the credentials like CredentialsOption. - cache.Config.CheckCredentials checks the credentials of a cache. - publicshares.New checks the store credentials. - decomposedfs options.New checks the statcache, filemetadatacache and idcache credentials. posix uses the same options. - gateway.New checks the provider cache and the create personal space cache credentials. - The OCS shares handler checks the stat cache credentials. store.Create keeps the error log as a fallback. Set the pull request number in the changelog to 782. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Before this change, the startup checks of the stores and the caches ran for every store type. A service with a memory or a redis store stopped at startup when the global OCIS_NATS_CREDS_FILE pointed to a path that was not mounted. That store does not use NATS. - store.UsesNats returns true for the nats-js and nats-js-kv types. - cache.Config.CheckCredentials and publicshares.New skip the check for the other types. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Before this change, three places selected the NATS authentication: stream.NatsFromConfig, the oCIS health check and the oCIS service registry. The TLS rules were different. The health check only logged a bad root CA, but the event stream failed. - stream.NatsOptions returns the authentication and the TLS options. NatsFromConfig uses it. A bad root CA certificate gives an error. - natsauth.Option returns the credentials option without a check. nats.UserCredentials reads the file when a caller applies the option. natsauth.Option reads the file only when the connection connects. Thus a partly written file after a reconnect does not remove the credentials from a new connection. - CredentialsOption uses natsauth.Option after the check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2403905
marked this pull request as ready for review
October 29, 2026 22:05
mklos-kw
previously approved these changes
Oct 31, 2026
…onnect The store checks the .creds file one time at the start. Before this change, a failed check made each later connect fail with the same error. The store then did not recover when the file appeared or became valid. Now the store reads the file again on each connect. A failed check of the creds content still gives the saved error, because the content cannot change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… order The check used a map, so the error named a random cache when more than one cache had invalid credentials. A slice now keeps the order fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kobergj
approved these changes
Nov 3, 2026
mzner
self-requested a review
November 3, 2026 12:23
mmattel
approved these changes
Nov 3, 2026
mzner
approved these changes
Nov 3, 2026
kobergj
added a commit
to owncloud/ocis
that referenced
this pull request
Nov 3, 2026
owncloud/reva#782 is merged. Pin the merged commit instead of the commit of the pull request branch. The vendored code does not change. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]>
kobergj
added a commit
to owncloud/ocis
that referenced
this pull request
Nov 4, 2026
owncloud/reva#782 is merged. Pin the merged commit instead of the commit of the pull request branch. The vendored code does not change. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]>
mklos-kw
added a commit
to owncloud/ocis
that referenced
this pull request
Nov 4, 2026
…eds file (#13220) * build: [OCSRE-1629] bump nats.go to v1.54.0 and go to 1.26.10 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * feat: [OCSRE-1629] add NATS JWT authentication with a .creds file A NATS server in operator (JWT) mode authenticates a client with a user JWT and an NKey seed. oCIS could connect to NATS only with a username and a password. All NATS connections now accept JWT credentials: events, caches, persistent stores, the service registry, and the health checks. - OCIS_NATS_CREDS_FILE: the path of a .creds file (nats.UserCredentials). The file is read again on each reconnect. - OCIS_NATS_CREDS: the content of a .creds file (nats.UserCredentialBytes). It takes precedence over the file. - Each events, cache and store struct has the fields CredsFile and Creds with a per-service override, for example PROXY_EVENTS_CREDS_FILE. - The registry reads MICRO_REGISTRY_AUTH_CREDS_FILE and MICRO_REGISTRY_AUTH_CREDS. If they are empty, it uses the OCIS_NATS_* variables. - store.Credentials is passed next to each store.Authentication call. The revaconfig maps pass the new reva keys. - The new checks.NewNatsCheckWithConfig uses the authentication and TLS settings of the service. The NATS health checks connected without credentials and without TLS before. This change needs the reva commit with pkg/natsauth and the natsjs plugin with the NatsOptions option. go.mod and vendor/ follow when these changes are pushed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix(proxy): [OCSRE-1629] use the events endpoint for the nats health check The proxy health check used Events.Cluster, the cluster ID of the event system, as the NATS address. The check thus never reached the NATS server. The check now uses Events.Endpoint. The proxy uses NATS only to publish events, and an empty endpoint disables the events. So the check returns no error when the endpoint is empty. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix: [OCSRE-1629] pass the NATS credentials in the search and storage-users streams The search service and the storage-users event stream build stream.NatsConfig field by field. They did not set CredsFile and Creds, so these two connections did not use the JWT credentials. The NATS server rejected them with "Authorization Violation". A test of "ocis server" against a NATS server in operator mode found this. The compiler cannot find a missing field in a struct literal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * docs: [OCSRE-1629] describe NATS JWT authentication with an external cluster The nats service README did not tell that the embedded nats service cannot run in operator (JWT) mode. Add a section that describes the .creds variables, the registry variables, and the steps to use an external NATS cluster in JWT mode. Add the same note to the changelog. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix(proxy): [OCSRE-1629] mask all secret values in the debug output go-masker copies a field without a mask tag unchanged, also a nested struct. A mask:"password" tag thus has an effect only when every parent field on the path has mask:"struct". Several parent fields did not have this tag, and some secret fields had no mask tag. - Add mask:"struct" to the proxy fields OIDC, OIDC.UserinfoCache, PreSignedURL, PreSignedURL.SigningKeys, ServiceAccount and Events, and to the shared Commons.Cache field. - Add mask:"password" to the AuthPassword fields of the proxy and of the shared cache, and to ServiceAccountSecret. - Add a test that sets a marker in every secret field of the proxy config and checks that the debug output does not show it. The test also fails when a secret-like field has no mask:"password" tag. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * chore: [OCSRE-1629] temporary bump reva and replace github.com/kobergj/plugins Signed-off-by: Julian Koberg <[email protected]> * docs: [OCSRE-1629] set the pull request number in the changelog Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix: [OCSRE-1629] let the more specific scope win for NATS credentials Each config has two fields for the NATS credentials: CredsFile (OCIS_NATS_CREDS_FILE;<SERVICE>_..._CREDS_FILE) and Creds (OCIS_NATS_CREDS;<SERVICE>_..._CREDS). envdecode sets each field on its own, and the content always won. Example: OCIS_NATS_CREDS set globally and GRAPH_CACHE_CREDS_FILE set for the service. The graph cache then used the global content and ignored the service file. The registry already used a different rule: the registry variables take precedence over the global variables. Use the registry rule everywhere. After envdecode decodes a struct, it resolves each CredsFile/Creds pair: when the file comes from a more specific environment variable than the content, the content is cleared. In the same scope the content still wins. A value from the config file has the lowest scope, because environment variables override the config file. Update the descriptions of the Creds fields, the nats README, and the changelog. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix: [OCSRE-1629] check the registry NATS credentials only at startup storeOptions checked the NATS credentials and called os.Exit(1) on an error. ReconnectedCB calls Init, and Init runs storeOptions again. If a reconnect happened while a rotated .creds file was only partly written, the service stopped. In the same path, nats.UserCredentials reads the file once when the option is applied. When this read failed, the error was ignored and the connection had no credentials. Now only the first call checks the credentials, at startup. Later calls do not check the file. For a file, they set the JWT callbacks without a read. The callbacks read the file on each connect, so a partly written file fails only that connect attempt, and NATS retries it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix(gateway): [OCSRE-1629] pass the TLS settings to the create home cache The create home cache of the gateway (create_personal_space_cache_config) got the NATS credentials, but it had no TLS settings. With TLS on the NATS server, this cache could not connect. Add CreateHomeCacheEnableTLS, CreateHomeCacheTLSInsecure and CreateHomeCacheTLSRootCACertificate with the same variables as the provider cache, and pass them to reva. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * chore: [OCSRE-1629] bump reva Signed-off-by: Julian Koberg <[email protected]> * refactor: [OCSRE-1629] keep only the global NATS credentials variables Remove the service-specific NATS credentials variables. Only OCIS_NATS_CREDS_FILE and OCIS_NATS_CREDS remain. The service registry also uses these two variables and no longer reads MICRO_REGISTRY_AUTH_CREDS_FILE and MICRO_REGISTRY_AUTH_CREDS. Remove the envdecode logic that let the more specific scope win, because only one scope remains. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix(gateway): [OCSRE-1629] use the correct key to disable the provider cache persistence Reva reads the key "cache_disable_persistence". The gateway sent "disable_persistence", so reva ignored the setting. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * refactor: [OCSRE-1629] use nats.UserCredentials in the registry nats.UserCredentials reads the creds file only in its callbacks. The custom lazyCredsFileOption function did the same work, so remove it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix: [OCSRE-1629] check the store NATS credentials at startup The reva store cannot return an error for invalid NATS credentials. It only logs the error, and each store operation fails later. The config validation of each service with a store now checks the credentials. An invalid value now stops the service at startup. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * revert: [OCSRE-1629] restore the service-specific NATS credentials variables This reverts commit 5b7d19d. With only the global variables, an operator cannot set different credentials for one NATS connection. The service-specific variables let the more specific scope win again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * chore: bump deps Signed-off-by: Julian Koberg <[email protected]> * fix: [OCSRE-1629] apply the scope rules to the NATS username and fix the NATS checks - A service-specific username or password now takes precedence over the global NATS JWT credentials. Before, OCIS_NATS_CREDS_FILE always replaced a value like GRAPH_CACHE_AUTH_USERNAME. The service registry uses the same rule for MICRO_REGISTRY_AUTH_USERNAME and MICRO_REGISTRY_AUTH_PASSWORD. - The NATS health check keeps one connection and uses it again for each probe. Before, each probe read the .creds file and opened a new connection. A probe could read a rotated file before the write was complete. The proxy, ocs and gateway services now build the check once. - The startup check of the store credentials runs only for the nats-js and nats-js-kv store types. Other store types do not use the credentials. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * refactor: [OCSRE-1629] map the NATS config in one place for each service - The search, sharing, storage-users, ocs and gateway config structs now have a method that returns the stream.NatsConfig. Before, the same literal was in 7 places. A new NATS field then needed 7 edits. A test fails when a field of stream.NatsConfig is not mapped. - Remove the CredsFile and Creds fields from shared.Cache. No service copied these fields from the commons, so they had no effect. - Add a changelog entry for the provider cache persistence fix of the gateway service. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * docs: [OCSRE-1629] describe the precedence of a service-specific NATS username A service-specific username or password takes precedence over the global OCIS_NATS_CREDS and OCIS_NATS_CREDS_FILE variables. The descriptions of the creds variables said that a set creds value always replaces the username and the password. Add the exception to each creds variable that has a service-specific variable, and to services/nats/README.md. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * chore: [OCSRE-1629] bump reva and fix the etcd client/pkg version - Bump reva to 4358c1ee0. reva now has stream.NatsOptions and natsauth.Option. - Set go.etcd.io/etcd/client/pkg/v3 back to v3.6.11. The earlier dependency bump set v3.7.3. That version does not compile with go.etcd.io/etcd/client/v3 v3.6.11. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix: [OCSRE-1629] make the NATS health checks find a lost server The NATS health check kept one connection and checked only its status. The status stays CONNECTED until the client notices a lost server, so a probe reported ready for minutes. The check also kept the lock during the dial and ignored the probe context. - Each probe sends a PING and waits for the PONG. The probe uses its context, or a limit of 2s when the context has no deadline. - One dial runs without the lock. The other probes wait for it only until their context ends. - An empty address means that the service does not use NATS. The check then succeeds. This fixes graph when its events are off. - checks.NewNatsStoreCheck checks a store only for the nats-js and nats-js-kv types. The ocs and gateway checks use it. - The health check uses reva stream.NatsOptions, so it has the same authentication and TLS rules as the event stream. The username and the password now replace the JWT credentials only when both have a value. Before, a leftover service password alone removed the global credentials. The registry logs a fatal error through the oCIS logger. It uses natsauth.Option after the first check, so the option reads the .creds file only when the connection connects. The sharing and storage-users Events fields now have the names of stream.NatsConfig. The NATS test helpers are in ocis-pkg/natstest. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * fix(userlog): [OCSRE-1629] add a default node for the store The userlog store was the only store without a default node. With OCIS_PERSISTENT_STORE=nats-js-kv, the store could not connect and userlog failed with "no servers available for connection" for each event. The acceptance test run with NATS JWT credentials found this. The problem does not depend on the credentials. Use 127.0.0.1:9233 like the other services. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * chore: replace deps back Signed-off-by: Julian Koberg <[email protected]> * test: [OCSRE-1629] remove a passing scenario from the expected failures The scenario "check default services readiness (graph, idp, proxy)" (serviceAvailabilityCheck.feature:111) passes now. The proxy health check used the events cluster ID as the NATS address, so the proxy readiness check failed. This pull request uses the events endpoint. The test run reports a scenario that passes but is in the list of expected failures as an error. Thus the job cliCommands, apiServiceAvailability failed in each run of this pull request. The only other failures in the job were the two expected failures at lines 120 and 131. Remove the entry for line 111. Keep the entries for the auth-bearer scenarios at lines 120 and 131. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * ci: [OCSRE-1629] run API tests against an external NATS in JWT mode The embedded nats service cannot run in JWT mode. Thus no job tested the JWT credentials end to end. A client that connects without credentials caused only retries in the background, so the tests could pass. Add the scripts in tests/nats-jwt: - natscreds creates new keys and the NATS config at each run. The repository never has a seed. - start-nats.sh starts a stand-alone NATS server in operator mode. - verify.sh checks the NATS log for authentication errors, the KV buckets, the consumers of the events stream, and the isolation of the account. - startup-check.sh starts oCIS with audit, policies, antivirus, and notifications, and requests /readyz of 17 services. Add two jobs to the acceptance test workflow: - nats-jwt-tests runs apiAsyncUpload, apiActivities, apiSearch1, apiSharingNgShares, apiSharingNgItemLinkShare, and apiNotification. The creds are a file or the content. - nats-jwt-startup-check runs startup-check.sh. Both jobs are in the needs of all-acceptance-tests. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * refactor: [OCSRE-1629] simplify the NATS health check - WithCheck skips a nil check. The NATS checks return nil when nothing needs a check. - The store check uses all nodes. It succeeds when one node is reachable, like the store connection. - The check creates one connection with RetryOnFailedConnect. The nats client reconnects by itself. Each probe only sends a PING. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * refactor: [OCSRE-1629] build the registry store options one time Init built the store options two times. Init runs again on each NATS reconnect, so the registry did the work two times in a reconnect storm. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * test: [OCSRE-1629] check the NATS credentials field names of all services The envdecode package finds the NATS credentials of a struct by the field names. It skips a struct without an error when a name does not match. The new test walks the config of all services and fails when a name does not match. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * chore: [OCSRE-1629] bump reva to the merged stable-8.0 commit owncloud/reva#782 is merged. Pin the merged commit instead of the commit of the pull request branch. The vendored code does not change. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * docs: [OCSRE-1629] set the introductionVersion of the new variables to 8.0.10 The NATS credentials variables are new in this pull request, which targets stable-8.0, so they are introduced with the 8.0.10 release. The TLS variables keep 8.3.0, because they are already released with 8.0.9. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * feat: [OCSRE-1629] review fixes Signed-off-by: Michal Klos <[email protected]> * fix: [OCSRE-1629] annotate the env tags of the registry credentials scope The credsScope struct carries env tags, so check-env-var-annotations requires a desc and an introductionVersion annotation on each field. Without them the build-and-test job fails. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> * docs: [OCSRE-1629] set the introductionVersion of the new variables to 9.0.0 The introductionVersion of a new environment variable is always the latest unreleased release, which is 9.0.0, also for a change that targets stable-8.0. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Julian Koberg <[email protected]> --------- Signed-off-by: Julian Koberg <[email protected]> Signed-off-by: Michal Klos <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Julian Koberg <[email protected]> Co-authored-by: Michal Klos <[email protected]>
2403905
added a commit
that referenced
this pull request
Nov 9, 2026
The events/natsjs plugin of go-micro has no NatsOptions option. Use the kobergj/plugins replace lines of stable-8.0, as in #782. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2403905
added a commit
that referenced
this pull request
Nov 9, 2026
The events/natsjs plugin of go-micro has no NatsOptions option. Use the kobergj/plugins replace lines of stable-8.0, as in #782. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2403905
added a commit
that referenced
this pull request
Nov 9, 2026
…le (#799) * feat: [main][OCSRE-1629] add NATS JWT authentication with a .creds file Backport of #782 to main. Changes for the backport: - pkg/natsauth/natsauth_test.go: build the creds file without jwt.FormatUserConfig. The jwt/v2 version v2.8.2 refuses a seed that does not match the JWT. - internal/grpc/services/gateway/gateway.go: main has no create_personal_space_cache_config, so the gateway checks only the provider cache. - pkg/storage/fs/posix: main does not have this driver. Drop the changes for it. - go.mod: keep the NATS versions of main. (cherry picked from commit bb724be) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * build: [OCSRE-1629] use the plugins with NatsOptions The events/natsjs plugin of go-micro has no NatsOptions option. Use the kobergj/plugins replace lines of stable-8.0, as in #782. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
2403905
added a commit
that referenced
this pull request
Nov 9, 2026
…eds file (#798) * feat: [stable-9.0][OCSRE-1629] add NATS JWT authentication with a .creds file Backport of #782 to stable-9.0. Changes for the backport: - pkg/natsauth/natsauth_test.go: build the creds file without jwt.FormatUserConfig. The jwt/v2 version v2.8.2 refuses a seed that does not match the JWT. - internal/grpc/services/gateway/gateway.go: stable-9.0 has no create_personal_space_cache_config, so the gateway checks only the provider cache. - go.mod: keep the NATS versions of stable-9.0. (cherry picked from commit bb724be) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * build: [OCSRE-1629] use the plugins with NatsOptions The events/natsjs plugin of go-micro has no NatsOptions option. Use the kobergj/plugins replace lines of stable-8.0, as in #782. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The description is in a main pr owncloud/ocis#13220
Enhancement: Add NATS JWT authentication with a .creds file
A NATS server in operator (JWT) mode authenticates a client with a user JWT and
an NKey seed. Before this change, reva could connect to NATS only with a
username and a password.
The event streams and the
nats-jsandnats-js-kvstores now accept JWTcredentials. You can give the path of a NATS
.credsfile, or the content ofsuch a file. The content takes precedence over the file. When JWT credentials
are set, reva does not send the username and the password.
stream.NatsConfighas the new fieldsCredsFileandCreds.store.Credentials(credsFile, creds)sets the credentials for a store.cache_creds_fileandcache_creds.nats_creds_fileand
nats_creds.store_creds_fileandstore_creds.stream.NatsOptions(cfg)returns thenats.Optionvalues for theauthentication and the TLS settings. The event streams use it. Other NATS
connections, for example health checks, can use the same rules.
natsauth.Option(credsFile, creds)returns the credentials option without acheck. For a file, the option reads the file only when the connection
connects. Use it after a reconnect, when a rotated file can be partly written.
reva checks the credentials at startup. An invalid value gives a clear error.
The event streams, the publicshares auth manager, the decomposedfs and posix
caches, the gateway caches, and the OCS stat cache stop with this error. Before,
an invalid value for a store only caused an error log, and each store operation
failed later. reva checks the credentials of a store or a cache only when its
type is
nats-jsornats-js-kv. Other types do not use the credentials.