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 <noreply@anthropic.com>
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package debug
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/checks"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/handlers"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
|
"github.com/owncloud/reva/v2/pkg/events/stream"
|
|
)
|
|
|
|
// Server initializes the debug service and server.
|
|
func Server(opts ...Option) (*http.Server, error) {
|
|
options := newOptions(opts...)
|
|
|
|
readyHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
|
|
WithLogger(options.Logger).
|
|
WithCheck("nats reachability", checks.NewNatsCheckWithConfig(options.Config.Postprocessing.Events.Endpoint, stream.NatsConfig(options.Config.Postprocessing.Events)))
|
|
|
|
return debug.NewService(
|
|
debug.Logger(options.Logger),
|
|
debug.Name(options.Config.Service.Name),
|
|
debug.Version(version.GetString()),
|
|
debug.Address(options.Config.Debug.Addr),
|
|
debug.Token(options.Config.Debug.Token),
|
|
debug.Pprof(options.Config.Debug.Pprof),
|
|
debug.Zpages(options.Config.Debug.Zpages),
|
|
debug.Ready(handlers.NewCheckHandler(readyHandlerConfiguration)),
|
|
), nil
|
|
}
|