使用RGoogleDocs时如何防止密码泄露? [英] How do I prevent exposure of my password when using RGoogleDocs?

查看:79
本文介绍了使用RGoogleDocs时如何防止密码泄露?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢 RGoogleDocs 并经常使用它.但是,我不喜欢一直输入密码.显然,我只需要在R脚本中输入密码即可,而不必再次输入密码.但这并不可行,因为这意味着我的密码将在我的硬盘驱动器上保留未加密状态.此外,我与同事分享我的脚本.

I love RGoogleDocs and use it a lot. However, I don't like entering my password all the time. Obviously I could just type the password into the R script and would never have to enter it again. But thats not viable since it means that my password would be left unencrypted on my harddrive. Furthermore I share my scripts with colleagues.

为了解决这个问题,我想到了这个.

To get around the problem I came up with this.

if(exists("ps")){
  print("got password, keep going")
} else {
  ps <-readline(prompt="get the password in ")
}

options(RCurlOptions = list(
  capath = system.file("CurlSSL", "cacert.pem", 
  package = "RCurl"), ssl.verifypeer = FALSE)
)

sheets.con = getGoogleDocsConnection(
  getGoogleAuth("notreal@gmail.com", ps, service ="wise")) 

#WARNING: this would prevent curl from detecting a 'man in the middle' attack
ts2=getWorksheets("hpv type",sheets.con)

我喜欢使用RStudio.当时我正在为办公室中的任何同事显示密码,对此我感到不舒服.我使用了伪造的密码,但查看了图像. .此外,如果我保存了一个工作空间,那么我的密码也将随之保存,并且如果几个月后当我长期忘记了其中的内容时,我发送了.RData,恐怕我会将它提供给其他人.提交给同事.

I love using RStudio. I feel uncomfortable that it is displaying my password for any colleague in my office at the time to see. I used a fake password but look at the image. . Furthermore, if I saved a workspace my password would be saved with it and I am afraid that I would be giving it to someone else if, a few months later, when I had long forgotten about what was in it, I sent my .RData file to a colleague.

我在较早的帖子.使用RGoogleDocs时,它没有提供足够的信息来隐藏我的密码.

I read something general about passwords in R in an earlier post. It did not give me enough information to be able to conceal my password when using RGoogleDocs.

推荐答案

我的方法是设置登录名& R选项列表中的密码 在R启动文件.Rprofile中.然后我的代码获得了价值 使用getOption(),则该值从不可见或存储 在globalenv()中的顶级变量中. (如果 一个可以通过dump.frames进行事后调试.

My approach is to set the login-name & password in the R options list within the R startup file .Rprofile. Then my code gets the value with getOption() and then the value is never visible or stored in a top-level variable in globalenv(). (It could be save if one does post-mortem debugging via dump.frames).

至关重要的是,您以外的任何人都不能读取.Rprofile.

It is vital that the .Rprofile cannot be read by anybody other than you.

所以

options(GoogleDocsPassword = c(login = 'password'))

中的

,然后

in the .Rprofile and then

auth = getGoogleAuth()

仅用作第一个参数的默认值,以查找GoogleDocsPassword选项.

just works as the default value for the first parameter is to look for the GoogleDocsPassword option.

D.

这篇关于使用RGoogleDocs时如何防止密码泄露?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆