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

Add support for auth with custom schemes #62

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

antepusic
Copy link

@antepusic antepusic commented May 20, 2024

This PR extends the processing of Bolt v4 HELLO message to support custom auth schemes. The purpose is twofold:

  • improve Bolt support
  • support SSO via clients other than Lab (Memgraph’s SSO requires custom values of the scheme field)

TODOs

  • Make sure Bolt v4 is fully correct

@antepusic antepusic self-assigned this May 20, 2024
@antepusic antepusic added feature feature Docs - changelog only Docs - changelog only Docs needed Docs needed and removed Docs - changelog only Docs - changelog only labels May 20, 2024
@antepusic antepusic marked this pull request as ready for review June 18, 2024 22:55
@antepusic antepusic changed the title Add support for auth with custom schemas Add support for auth with custom schemes Jun 19, 2024
@antepusic antepusic requested a review from gitbuda June 20, 2024 10:23
Copy link

@as51340 as51340 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, have few comments

mgclient_cpp/include/mgclient.hpp Outdated Show resolved Hide resolved
mgclient_cpp/include/mgclient.hpp Outdated Show resolved Hide resolved
src/mgclient.c Outdated
return extra;
}

mg_value *scheme_ = mg_value_make_string(scheme ? scheme : "basic");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would scheme return false?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess when mg_value_make_string fails (e.g., allocation, but unlikely + when it fails since it's small, there are bigger problems most likely)?


if (username) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the change is also that username and password won't be inserted to extra if empty?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean here?

uint32_t version = htobe32(0x0104);
ASSERT_EQ(SendData(sockfd, (char *)&version, 4), 0);
}
uint32_t version = htobe32(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why changed from 0x0104 to 1?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 0x0104 is here the tests never finishes

&mg_system_allocator);
mg_session *session = mg_session_init(&mg_system_allocator);
ASSERT_TRUE(session);
session->version = 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version from 4 to 1?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea these seems like hacks to make the client work 🤔


// Read HELLO message.
// Read INIT message.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is changed from sending HELLO msg to INIT msg, any specific reason?

@gitbuda gitbuda assigned gitbuda and unassigned antepusic Aug 30, 2024
@gitbuda gitbuda removed their request for review August 30, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs needed Docs needed feature feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants