Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Building Connection string fails on namespace auth when reading data. #152

Open
2 tasks done
AdaptGit opened this issue Nov 22, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@AdaptGit
Copy link

Describe the bug

Building a connection string fails when reading, inserting or creating only when using a namespace auth. this use to work in the version 0.5.1. however doesn't work in the latest.

further to this the same connection details can be used to login via the sign in method and this works to read data.

Steps to reproduce

to reproduce this bug create a connection string to database with a namespace authentication method and read some data. This will result in there was a problem with the database and a problem with authentication, this authentication can be used on a sign method check test case below:

`
var surrealDbClient = new SurrealDbClient(SurrealDbOptions
.Create()
.WithEndpoint("ws://127.0.0.1:8000/rpc")
.WithNamespace("Name")
.WithDatabase("db")
.WithUsername("Name_space")
.WithPassword("root")
.Build()
);
var db = new SurrealDbClient("ws://127.0.0.1:8000/rpc");
await db.Connect();
await db.Use("Namespace", "db");
var namespaceAuth = new NamespaceAuth
{
Namespace = "Name",
Username = "Name_space",
Password = "root"
};
await db.SignIn(namespaceAuth);

        var getResult = await db.RawQuery("Select * from 1");
        Assert.IsFalse(getResult.HasErrors);

        var result = await surrealDbClient.RawQuery("Select * from 1");
        Assert.IsFalse(result.HasErrors);

`

Screenshot 2024-11-23 at 10 34 59 AM Screenshot 2024-11-23 at 10 35 46 AM

Expected behaviour

this should work like the signin method, allowing access to the database and to read the data.

SurrealDB version

Running 2.1.0 for macos on aarch64

Package version(s)

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@AdaptGit AdaptGit added the bug Something isn't working label Nov 22, 2024
@Odonno
Copy link
Contributor

Odonno commented Nov 23, 2024

I am not sure to see where the issue lies here.

Some reviews about the code example you provided:

  • The surrealDbClient client is created from options, it will automatically Use the ns/db provided and SignIn as root auth from the user/password on Connect
  • The db will use and sign in as namespace auth because you call these methods manually

From what I can see in your error output, it is the SignIn method call using the surrealDbClient client that fails. It means that root authentication fails.

Are you sure this is the intended purpose?

@AdaptGit
Copy link
Author

Hi @Odonno

I wrote this to show the difference between both connection methods and results. (probably should of explained it better in the code.)

  • the first connection fails with surrealDbOptions and fails to make a read when using the namespace auth.
  • where as the second connection does work with the namespace auth.

further to this i'm able to connect via surrealist using namespace auth.

let me know if i need to provide any extra details if required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants