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 unauthenticated users to connect to an instance #19

Merged
merged 7 commits into from
Oct 9, 2024

Conversation

rcannood
Copy link
Collaborator

@rcannood rcannood commented Oct 9, 2024

Allow unauthenticated users to query an instance if they ran lamin load <instance> beforehand

@rcannood rcannood requested a review from lazappi October 9, 2024 08:33
R/connect.R Outdated
Comment on lines 48 to 69
if (file.exists(instance_file)) {
.settings_load__load_instance_settings(instance_file)
} else {
# try to load the user settings from the api
user_file <- .settings_store__current_user_settings_file()

if (!file.exists(user_file)) {
cli_abort(paste0(
"No default user or instance is loaded! Either:\n",
" - Call `lamin login` to set a default user.\n",
" - Call `lamin load <slug>` to set a default instance.\n"
))
} else {
user_settings <- .settings_load__load_user_settings(user_file)

.connect_get_instance_settings(
owner = owner_name$owner,
name = owner_name$name,
access_token = user_settings$access_token
)
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the instance settings file does not exist, we could try running lamin load ${slug} ourselves, as opposed to throwing an error message. @lazappi wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For now I would probably leave the setup stuff to the command line, just for easiness. If Python lets you do this then maybe it would be nice to add later.

"db_user_password"
"api_url"
)
optional_columns <- c(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be clearer to call these "settings" or something rather than columns?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point -- done!

R/connect.R Outdated
Comment on lines 48 to 69
if (file.exists(instance_file)) {
.settings_load__load_instance_settings(instance_file)
} else {
# try to load the user settings from the api
user_file <- .settings_store__current_user_settings_file()

if (!file.exists(user_file)) {
cli_abort(paste0(
"No default user or instance is loaded! Either:\n",
" - Call `lamin login` to set a default user.\n",
" - Call `lamin load <slug>` to set a default instance.\n"
))
} else {
user_settings <- .settings_load__load_user_settings(user_file)

.connect_get_instance_settings(
owner = owner_name$owner,
name = owner_name$name,
access_token = user_settings$access_token
)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

For now I would probably leave the setup stuff to the command line, just for easiness. If Python lets you do this then maybe it would be nice to add later.

R/connect.R Outdated
Comment on lines 48 to 60
if (file.exists(instance_file)) {
.settings_load__load_instance_settings(instance_file)
} else {
# try to load the user settings from the api
user_file <- .settings_store__current_user_settings_file()

if (!file.exists(user_file)) {
cli_abort(paste0(
"No default user or instance is loaded! Either:\n",
" - Call `lamin login` to set a default user.\n",
" - Call `lamin load <slug>` to set a default instance.\n"
))
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be combined with the similar chunk above? Possibly the logic is easier this way though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes -- and indeed!

@rcannood rcannood changed the title Allow unauthenticated users to query an instance Allow unauthenticated users to connect to an instance Oct 9, 2024
@rcannood rcannood merged commit 0b426a9 into main Oct 9, 2024
7 checks passed
@rcannood rcannood deleted the refactor-connect branch October 9, 2024 09:19
lazappi added a commit that referenced this pull request Oct 9, 2024
* origin/main:
  Allow unauthenticated users to connect to an instance (#19)
  Create pkgdown docs (#13)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants