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

Secure entry and storage for SharePoint creds #7

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

Secure entry and storage for SharePoint creds #7

wants to merge 2 commits into from

Conversation

brendan-newlon
Copy link

I added an option to enter Username and Password securely and store both in the system key store when a credential isn't provided.

  1. more secure than entering a password as an argument.
  2. convenient for successive API calls with the same credentials.

I also added a function sp_clearKeys() to delete those saved keys from the system key store to allow connecting with different credentials from the same system account.

Added option to enter Username and Password securely and store in system key store.
Added function to delete those saved keys from system key store.
} else { # credential file is given
credentials = yaml::read_yaml(credentialFile) # read credential file
Username = credentials$Username # save username
Password = credentials$Password # save password
}
}
Copy link
Author

Choose a reason for hiding this comment

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

Sorry, this closing curly brace should be removed.

# Last chance to enter Username
if (is.null(Username)) { # No Username is given
if ("sharepointr_username" %in% key_list("sharepointr_username")$service) { # Check system key store
Username <- key_get("sharepointr_username")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Username <- key_get("sharepointr_username")
Username <- keyring::key_get("sharepointr_username")

Username <- key_get("sharepointr_username")
} else { # Username not in key store
Username <- rstudioapi::askForSecret("Enter SharePoint Username")
key_set_with_value("sharepointr_username", password = Username)
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
key_set_with_value("sharepointr_username", password = Username)
keyring::key_set_with_value("sharepointr_username", password = Username)

# Last chance to enter Password
if (is.null(Password)) { # No Password is given
if ("sharepointr_password" %in% key_list("sharepointr_password")$service) { # Check system key store
Password <- key_get("sharepointr_password")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Password <- key_get("sharepointr_password")
Password <- keyring::key_get("sharepointr_password")

Password <- key_get("sharepointr_password")
} else { # Password not in key store
Password <- rstudioapi::askForSecret("Enter SharePoint Password")
key_set_with_value("sharepointr_password", password = Password)
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
key_set_with_value("sharepointr_password", password = Password)
keyring::key_set_with_value("sharepointr_password", password = Password)

if ("sharepointr_username" %in% key_list("sharepointr_username")$service) { # Check system key store
Username <- key_get("sharepointr_username")
} else { # Username not in key store
Username <- rstudioapi::askForSecret("Enter SharePoint Username")
Copy link
Owner

Choose a reason for hiding this comment

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

What happens during non interactive session?

if ("sharepointr_password" %in% key_list("sharepointr_password")$service) { # Check system key store
Password <- key_get("sharepointr_password")
} else { # Password not in key store
Password <- rstudioapi::askForSecret("Enter SharePoint Password")
Copy link
Owner

Choose a reason for hiding this comment

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

What happens during non interactive session?

#' sp_clearKeys()
sp_clearKeys <- function() {
# Delete the Username if stored in system key store.
if ("sharepointr_username" %in% key_list("sharepointr_username")$service) {key_delete("sharepointr_username")}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if ("sharepointr_username" %in% key_list("sharepointr_username")$service) {key_delete("sharepointr_username")}
if ("sharepointr_username" %in% keyring::key_list("sharepointr_username")$service) {keyring::key_delete("sharepointr_username")}

# Delete the Username if stored in system key store.
if ("sharepointr_username" %in% key_list("sharepointr_username")$service) {key_delete("sharepointr_username")}
# Delete the Password if stored in system key store.
if ("sharepointr_password" %in% key_list("sharepointr_password")$service) {key_delete("sharepointr_password")}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if ("sharepointr_password" %in% key_list("sharepointr_password")$service) {key_delete("sharepointr_password")}
if ("sharepointr_password" %in% keyring::key_list("sharepointr_password")$service) {keyring::key_delete("sharepointr_password")}

@LukasK13
Copy link
Owner

Hey @brendan-newlon
Thank you very much for your idea and the related pull request.
I think this is a great idea and should be included. However, I am missing two points:

  1. What happens, if rstudioapi::askForSecret("Enter SharePoint Username") is called during a non interactive session?
  2. Please include keyring:: in your calls for methods from the package keyring (see my review)

Fix dependencies
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