Password field in grasshopper definition

Hi everyone,

I’m working with the connection between GH and a PostgreSQL database. I’m composing some definitions to retrieve data from the database that will be shared with other people. As I’m using the Slingshot! component, it’s required that I provide my login and password as input to the query component, what I do by writing directly on a panel. The problem is: every time I have to share some definition with other members of my research team, I have to remember to delete the panels that contain my user data, or else everyone will have access to my superuser password and I would be weakening the security of the database.

So, I’m wondering if there is any way to prepare the definition to ask for this password or at least erase the data from the specific panels everytime the file is opened. Something similar to False Start Toggle component behavior.

I don’t know if I was clear in my question.
Anyway, I appreciate you attention.

Thx!
:slight_smile:

How about using a python component to ask for the user name and password and save it in the sticky dictionary, i.e. just for the session?

I’m not sure how Slingshot component work, but could it be the input login and password are just text inputs?
If yes, you could use some .txt file in your own PC and use grasshopper file loader to get the login/password from them.
2019-02-06%2017_10_19-Window
This should not save the .txt content in the .gh file…
Some confirmation by someone else might be handy.
Also, saving your password in a plain txt file is not that safe, but it’s an idea.

Edit: and if you put this file reader inside a password-protected cluster, nobody is going to know where your plain-text-password is located in your computer…
2019-02-06%2017_13_59-Window
Edit2: you can even do some sort of text editing inside the cluster, so the full password is written nowhere and set up the cluster to give an output only if the file is found (and more tricks can be easily added)

2 Likes

Something like:

import scriptcontext as sc
import rhinoscriptsyntax as rs

if sc.sticky.has_key('Eugeniomoreira'):
    uname, passwd = sc.sticky.get('Eugeniomoreira')

else:
    uname, passwd = ('', '')
    
uname = rs.StringBox('user name?', uname)
passwd = rs.StringBox('Password?', passwd)
sc.sticky['Eugeniomoreira'] = (uname, passwd)
1 Like

Thanks @maje90 and @Dancergraham!

Both replies are very interesting. For now, I’ll use Ricardo’s approach. But I do some tests with the Graham sugestion and I believe that will work as my “final” solution. Actually, I think just the StringBox function will do the job, because I just need the definition asks the user for a input every time the file is open. With the stick dictionarie, if I understand correctly, the last input appears as sugestion in the next session. But I I’ll look more carefully later.

Thank you guys!

Hey!

Just to give a feedback…

I use this script so far:

import rhinoscriptsyntax as rs
 
if connect == True:
    ip = rs.StringBox('insert the IP address', '', 'IP')`
    uname = rs.StringBox('insert your username', '', 'Username')
    passwd = rs.StringBox('insert your password', '', 'Password')

ip = ip
uid = uname
pwd = passwd

And this is the structure of my cluster:

And this is how it looks to the final user:

So, everytime I switch the toggle to “true”, I have three popup windows asking for IP, username and password. Also, this information is not stored in the file when it’s saved. I can share my definitions without fear of accidentally sharing my username / password.

My biggest problem is solved! Thank you!

Now, I have one final question, if you don’t mind. Do you know any function of rhinoscript or another library that allows the generation of the same type of popup window, but with some kind of secure typing? You know, hiding the actual characters on the screen, such as those commonly used in password entries? I speak portuguese and I don’t know the technical term for that, so my googling capacities are very limited in that matter…

2 Likes

Hi, I don’t know if the getpass module is implemented in Ironpython…?

Do Eto forms work in GrassHopper? Apparently there is a passwordform