EventStore / EventStore-Client-Go

Go Client for Event Store version 20 and above.
Apache License 2.0
103 stars 25 forks source link

CreatePersistentSubscriptionAll Permission Denied error with default Admin user #131

Closed HazemElAgaty closed 1 year ago

HazemElAgaty commented 1 year ago

Pkg Version

v1.0.2

ES Version

v21.10.8 using the cloud solution

Problem

Whenever I try subscribing to the stream using the pkg, I end up with PermissionDenied error. I am using the default admin credentials.

    db.CreatePersistentSubscriptionAll(ctx, SubsGroupName,
        esdb.PersistentAllSubscriptionOptions{
            Authenticated: &esdb.Credentials{
                Login:    config.ESUser,
                Password: config.ESPass,
            }})

Would you please tell me what I might be doing wrong?

YoEight commented 1 year ago

Hey @HazemElAgaty,

Are you sure you are providing the right password then? I know it sounds trivial but it happens more than you might think.

Also, version 1.0.2 is a year old. Even if I'm positive persistent subscriptions to all were working back then, would you consider moving to the latest version of the client and retry? Currently, it's version 3.0.0

HazemElAgaty commented 1 year ago

@YoEight Thanks a lot for the quick response. I double checked the credentials being used yes, but I just noticed that I am using an old version. I will upgrade the sdk and try again.

HazemElAgaty commented 1 year ago

@YoEight After upgrading the pkg to the latest version, the error has changed to "Unauthenticated" although I am passing the admin credentials as shown below.

    creds := &esdb.Credentials{
        Login:    "admin",
        Password: "changeit",
    }
    persistentSubsOptions := esdb.PersistentAllSubscriptionOptions{
        Filter:        &esdb.SubscriptionFilter{Type: esdb.StreamFilterType, Prefixes: []string{string(account.AccountAggregateType)}},
        Authenticated: creds,
    }
    logger.Log.Info("creating persistent subscription..")
    err := db.CreatePersistentSubscriptionToAll(ctx, SubsGroupName, persistentSubsOptions)

Error

error when creating reading server features from the best candidate 'xxx.eventstore.cloud:2113': rpc error: code = Unauthenticated desc = Unauthenticated
YoEight commented 1 year ago

Hey @HazemElAgaty ,

After some investigation, based on how cloud clusters are set up, you'll need to be authenticated prior to even start issuing commands. I suggest you to configure your default credentials at the connection string level like shown below:

esdb.ParseConnectionString("esdb+discover://{login}:{password}@xxx.eventstore.cloud")

You won't need to be pass the Authenticated setting later on either.

HazemElAgaty commented 1 year ago

@YoEight Thanks a lot, it worked now.