Closed jselamy closed 3 years ago
You don't have to do that. What makes you think otherwise?
Thanks for the quick response.
This is why i'm saying that i have this connection-string -> esdb://admin:changeit@localhost:2111,localhost:2112,localhost:2113?tls=true&tlsVerifyCert=false&nodePreference=LEADER
Appending event on a stream with no ACL works (haven't gone for as testing with ACL's)
Creating a PersistentSubscription on for a specific stream is not working with implicitly passing passing the credentials in the CreatePersistentSubscriptionOptions
Here's a snippet of my code.
final String stream = "aStream";
final String eventType = "aType";
final String subscription_name = "subscription_name";
EventStoreDBClientSettings settings = EventStoreDBConnectionString.parseOrThrow("esdb://admin:changeit@localhost:2111,localhost:2112,localhost:2113?tls=true&tlsVerifyCert=false&nodePreference=LEADER");
EventStoreDBClient dbClient = EventStoreDBClient.create(settings);
EventStoreDBPersistentSubscriptionsClient persistentSubClient = EventStoreDBPersistentSubscriptionsClient.create(settings);
//appending to stream
EventData eventData = EventData
.builderAsJson(UUID.randomUUID(), eventType, new ESConfig.TestEvent("1", "dummy"))
.build();
AppendToStreamOptions options = AppendToStreamOptions.get()
.expectedRevision(ExpectedRevision.ANY);
dbClient.appendToStream(stream, options, eventData)
.get();
final UserCredentials credentials = new UserCredentials("admin", "changeit");
//Creating a persistent sub
persistentSubClient.create(stream, subscription_name, CreatePersistentSubscriptionOptions.get()
.authenticated(credentials)
.settings(PersistentSubscriptionSettings.builder().build()))
.get();
Here in this snippet i explicitly have to give the UserCredentials to the com.eventstore.dbclient.OptionsBase#authenticated
otherwise there's an exception of type Permission Denied
Caused by: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Access Denied
at io.grpc.Status.asRuntimeException(Status.java:533)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:478)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:434)
at io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:763)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:742)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
It's a bug that has been fixed by #71. A snapshot version is available on Sonatype
https://github.com/EventStore/EventStoreDB-Client-Java/issues/68#issuecomment-827502978
@YoEight can you point me to that Sonatype of yours ?
You can found the instruction in our READM.md file: https://github.com/EventStore/EventStoreDB-Client-Java#snapshot-versions
Hi,
I wanted to know
com.eventstore.dbclient.OptionsBase
we need to provide thecom.eventstore.dbclient.OptionsBase#authenticated
withcom.eventstore.dbclient.UserCredentials
. In the case that it is provided in thecom.eventstore.dbclient.EventStoreDBClientSettings
usingcom.eventstore.dbclient.EventStoreDBConnectionString#parseOrThrow
orcom.eventstore.dbclient.EventStoreDBConnectionString#parse
for a connection-string that contains the credentials of the application... shouldn't it be injected @some point instead of having to constantly passing credentials for Operations that needs to be authenticated ?