HARPgroup / r-dh-ecohydro

A set of R scripts for generating Ecological Limit Functions (ELF), storing the modeled output with REST in drupal VAHydro (dH), and a set of scripts for querying and analyzing processed ELF data
0 stars 1 forks source link

Updated rest authentication function breaks gage MLLR script #38

Closed rburghol closed 6 years ago

rburghol commented 6 years ago

The changes made in #36 breaks backwards compatibility with other routines because they remove the handling of the rest_uname and rest_pass params into the authentication function. The MLLR code that runs on the pages breaks as a result.

Wondering:

  1. was there a problem with passing those parameters in to rest_token(base_url, token, rest_uname = rest_uname, rest_pw = rest_pw)?
  2. I think that keeping them in there helps the potential security issue around having rest_uname and rest_pass being global.
passeroe commented 6 years ago

This may be unrelated and not a priority, but I am no longer able to run the scripts from the elf_user_inputs, and the error I get is that object 'token' is not found. I was able to run the scripts with no issues before this update was made.

rburghol commented 6 years ago

Check the error messages -- we now have authentication info stored in a file named "rest.private" this is likely what you need

On Tue, Feb 20, 2018 at 4:36 PM, passeroe notifications@github.com wrote:

This may be unrelated and not a priority, but I am no longer able to run the scripts from the elf_user_inputs, and the error I get is that object 'token' is not found. I was able to run the scripts with no issues before this update was made.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HARPgroup/r-dh-ecohydro/issues/38#issuecomment-367128315, or mute the thread https://github.com/notifications/unsubscribe-auth/AEXAIhQSw5ueihlVZujlQqKaXYMY0KNLks5tWzrggaJpZM4SDqdJ .

--

Robert W. Burgholzer 'Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity.' - Charles Mingus Athletics: http://athleticalgorithm.wordpress.com/ Science: http://robertwb.wordpress.com/ Wine: http://reesvineyard.wordpress.com/

rburghol commented 6 years ago

We need to fix up the README to account for these changes :)

On Wed, Feb 21, 2018 at 7:34 AM, Robert Burgholzer rburghol@vt.edu wrote:

Check the error messages -- we now have authentication info stored in a file named "rest.private" this is likely what you need

On Tue, Feb 20, 2018 at 4:36 PM, passeroe notifications@github.com wrote:

This may be unrelated and not a priority, but I am no longer able to run the scripts from the elf_user_inputs, and the error I get is that object 'token' is not found. I was able to run the scripts with no issues before this update was made.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HARPgroup/r-dh-ecohydro/issues/38#issuecomment-367128315, or mute the thread https://github.com/notifications/unsubscribe-auth/AEXAIhQSw5ueihlVZujlQqKaXYMY0KNLks5tWzrggaJpZM4SDqdJ .

--

Robert W. Burgholzer 'Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity.' - Charles Mingus Athletics: http://athleticalgorithm.wordpress.com/ Science: http://robertwb.wordpress.com/ Wine: http://reesvineyard.wordpress.com/

--

Robert W. Burgholzer 'Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity.' - Charles Mingus Athletics: http://athleticalgorithm.wordpress.com/ Science: http://robertwb.wordpress.com/ Wine: http://reesvineyard.wordpress.com/

jenniferRapp commented 6 years ago

So she doesn't just have to update the PWD?

Jen

Jennifer Lynn Rapp, Biogeographer and GIS Specialist jrapp@usgs.gov U.S. Geological Survey Virginia and West Virginia Water Science Center 1730 East Parham Road Richmond, VA 23228 w. 804-261-2635

On Wed, Feb 21, 2018 at 7:35 AM, rburghol notifications@github.com wrote:

We need to fix up the README to account for these changes :)

On Wed, Feb 21, 2018 at 7:34 AM, Robert Burgholzer rburghol@vt.edu wrote:

Check the error messages -- we now have authentication info stored in a file named "rest.private" this is likely what you need

On Tue, Feb 20, 2018 at 4:36 PM, passeroe notifications@github.com wrote:

This may be unrelated and not a priority, but I am no longer able to run the scripts from the elf_user_inputs, and the error I get is that object 'token' is not found. I was able to run the scripts with no issues before this update was made.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HARPgroup/r-dh-ecohydro/issues/38# issuecomment-367128315, or mute the thread https://github.com/notifications/unsubscribe-auth/ AEXAIhQSw5ueihlVZujlQqKaXYMY0KNLks5tWzrggaJpZM4SDqdJ .

--

Robert W. Burgholzer 'Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity.' - Charles Mingus Athletics: http://athleticalgorithm.wordpress.com/ Science: http://robertwb.wordpress.com/ Wine: http://reesvineyard.wordpress.com/

--

Robert W. Burgholzer 'Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity.' - Charles Mingus Athletics: http://athleticalgorithm.wordpress.com/ Science: http://robertwb.wordpress.com/ Wine: http://reesvineyard.wordpress.com/

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HARPgroup/r-dh-ecohydro/issues/38#issuecomment-367312249, or mute the thread https://github.com/notifications/unsubscribe-auth/AgIeBR_vc-mUwjzof_1LsrcIbZb5Yw5Tks5tXA1-gaJpZM4SDqdJ .

rburghol commented 6 years ago

That could be the problem, but I think since token is not found, rather than being no good, suggests that it's a problem with the authentication functions not being available -- which maybe means that the rest.private is missing, or perhaps another path issue -- i.e. it can't find the function that finds the rest token. Elaina -- can you provide some more details on the error messages?

passeroe commented 6 years ago

When I downloaded the master branch yesterday, I had a file named rest.private.example, so I changed

source(paste(fxn_locations,"rest.private", sep = "")); #load rest username and password, contained in rest.private file

to

source(paste(fxn_locations,"rest.private.example", sep = "")); #load rest username and password, contained in rest.private file

Before I made the change I got the following errors:

> source(paste(fxn_locations,"rest.private", sep = ""));         #load rest username and password, contained in rest.private file
Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'C:\Users\passeroe\Documents\HARP\r-dh-ecohydro-master\ELFGEN\internal\rest.private': No such file or directory
> token <- rest_token(site, token, rest_uname, rest_upass);
Error in rest_token(site, token, rest_uname, rest_upass) : 
  object 'rest_upass' not found

After I fixed the file name, I still got the following errors:

Error in rest_token(site, token, rest_uname, rest_upass) : 
  object 'rest_upass' not found

Both times I ran it, I also had these errors:

Error: object 'token' not found
> 
> #------------------------------------------------------------------------------------------------
> elf_retrieve_data (inputs) 
Error in elf_retrieve_data(inputs) : object 'inputs' not found
jdkleiner commented 6 years ago

Just merged a pull request- make a fresh pull of the master Elaina and try again (there was a typeo on that line that should be "rest_token(site, token, rest_uname, rest_pw)"

passeroe commented 6 years ago

Awesome. Thank you!

jdkleiner commented 6 years ago

Another note- you should be keeping the "line source(paste(fxn_locations,"rest.private", sep = ""));" as-is, the idea is that you'll have a file on your local machine named rest.private containing the actual rest authentication username and password (this is set up to NOT get pushed to GitHub with your commits), rest.private.example is simply in there to show the format you need to use in your "rest.private" file

passeroe commented 6 years ago

So what exactly do I need to do to be able to run this scripts? I tried changing the basepath and local directory paths in config.local.private, but I cannot make it past the first 13 lines of the script.

My initial run:

> #----FOR RUNNING LOCALLY:
> basepath='C:\\Users\\passeroe\\Documents\\HARP\\r-dh-ecohydro-master\\ELFGEN\\internal\\';
> # set your local directory paths in config.local.private located in filepath above
> # this file will NOT be sent to git, so it should persist
> # so, edit config.local.private once and you should be good to go
> source(paste(basepath,'config.local.private',sep='/'));
Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'C:\Users\passeroe\Documents\HARP\r-dh-ecohydro-master\ELFGEN\internal\/config.local.private': No such file or directory

I changed the sep = to see if that would fix the file path, but it did not change anything:

> #----FOR RUNNING LOCALLY:
> basepath='C:\\Users\\passeroe\\Documents\\HARP\\r-dh-ecohydro-master\\ELFGEN\\internal\\';
> # set your local directory paths in config.local.private located in filepath above
> # this file will NOT be sent to git, so it should persist
> # so, edit config.local.private once and you should be good to go
> source(paste(basepath,'config.local.private',sep=''));
Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'C:\Users\passeroe\Documents\HARP\r-dh-ecohydro-master\ELFGEN\internal\config.local.private': No such file or directory
rburghol commented 6 years ago

So I am guessing that this file does not exist? C:\Users\passeroe\Documents\HARP\r-dh-ecohydro-master\ELFGEN\internal\config.local.private Are you 100% sure there is no errors in that path?

passeroe commented 6 years ago

The file is there and I opened that file and edited the pathways. I tried changing it to source(paste(basepath, 'config.local.private.example', sep='')) and got rid of the error, but now I am getting the same error for rest.private. I have a rest.private file in the correct location, but I'm not sure what is supposed to go in it or if I need to add a file extension to that as well.

Update when I added the .example extension to the rest.private file my script ran without anymore hiccups as far as I can tell.

jdkleiner commented 6 years ago

Hey Elaina, you just need to make sure you're not editing or calling rest.private.example or config.local.private.example.

You need to have your own copies of these 2 files simply named rest.private (with the rest un and pw) and config.local.private (with your local file paths)

anything that ends in ".private" will never get sent to GitHub, and we need to be sure we're not ever saving the rest auth information in the rest.private.example file

Let me know if this doesn't make sense and we can get a call in, thanks.

passeroe commented 6 years ago

I am really confused. Am I supposed to make text files with same name instead of editing them?

jdkleiner commented 6 years ago

Yeah exactly, you'll be making a rest.private and a config.local.private file instead of editing those .example files, feel free to set up a webex right now and I'll walk you through if you're still confused

passeroe commented 6 years ago

That's okay. I think I have it working correctly now. Thanks for your help.

jenniferRapp commented 6 years ago

Each time we do a new pull do we have to re-create these files, or will they remain on our system if we did this once?

Jennifer Lynn Rapp, Biogeographer and GIS Specialist jrapp@usgs.gov U.S. Geological Survey Virginia and West Virginia Water Science Center 1730 East Parham Road Richmond, VA 23228 w. 804-261-2635

On Wed, Feb 21, 2018 at 1:58 PM, Joey Kleiner notifications@github.com wrote:

Yeah exactly, you'll be making a rest.private and a config.local.private file instead of editing those .example files, feel free to set up a webex right now and I'll walk you through if you're still confused

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HARPgroup/r-dh-ecohydro/issues/38#issuecomment-367432953, or mute the thread https://github.com/notifications/unsubscribe-auth/AgIeBdtiX-aRkIWTMdKs8snnd1TEzlwwks5tXGdkgaJpZM4SDqdJ .

jdkleiner commented 6 years ago

Nope, you'll just need to create them once and they'll remain! (the beauty of using this method)