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

Allow user to connect without database #1884

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

Conversation

andrejtonev
Copy link
Contributor

@andrejtonev andrejtonev commented Mar 29, 2024

Description

Allow users to connect without a database defined.
If a user has a default db, the user will connect to that database.
If a user does not have a default db, we will connect without a database defined. Only db-less queries should be allowed.
If a user defines the database via the client, we will use the same logic as above, but each query will be executed against the user-defined db. Multi-tenant auth will be executed at first query execution.

Q: Should we allow multi-tenant queries (ex: USE DATABASE x) even without db? YES

Bugfix: Was not updating the explicit flag when user explicitly defines the same database as the current one. This would in turn allow db switching, which is prohibited if user connects via mgclient.connect(database="db", ...)

[master < Task] PR

  • Provide the full content or a guide for the final git message
    • [FINAL GIT MESSAGE]

Documentation checklist

  • Add the documentation label tag
  • Add the bug / feature label tag
  • Add the milestone for which this feature is intended
    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    • [Release note text]
  • Link the documentation PR here
    • [Documentation PR link]
  • Tag someone from docs team in the comments

@andrejtonev andrejtonev self-assigned this Mar 29, 2024
@@ -121,9 +122,14 @@ void MultiDatabaseAuth(memgraph::query::QueryUserOrRole *user, std::string_view
namespace memgraph::glue {

#ifdef MG_ENTERPRISE
std::string SessionHL::GetDefaultDB() {
std::optional<std::string> SessionHL::GetDefaultDB() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Future change: do we want stronger default DB? name + uuid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense.
I will implement this now, since we missed the 2.17 release.

expected.append(", ".join(details))
execute_checker(checker_binary, expected)
print("\033[1;36m~~ Finished permissions test ~~\033[0m\n")
# # Run the test with all combinations of permissions
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this bring removed or updated?

@andrejtonev andrejtonev added Docs needed Docs needed CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push labels May 20, 2024
@andrejtonev andrejtonev added this to the mg-v2.18.0 milestone May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI -build=release -test=core Run release build and core tests on push CI -build=release -test=e2e Run release build and e2e tests on push Docs needed Docs needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants