- Notifications
You must be signed in to change notification settings - Fork1.5k
What is the best way to retrieve username and password to compare with user input?#2340
-
Using PyScript I created a simple HTML form for user input for username and password, however, I don't know what is the best way to compare user input to the actual username and password that PyScript supports. In my Java language that would be done via system environmental variables (System.getEnv('USERNAME'), System.getEnv('PASSWORD')), but that's inaccessible for me with my PyScript project, and external files are either insecure or unavailable. What do you recommend? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 7 replies
-
usually credentials are checked via the backend ... any attempt to have these on the client side risks credentials data leaks. PyScript runs on the browser but it can surely reach your backend where you can compare credentials against a database, env variables or other usual means ... but I guess you don't have a backend, only a static page? If that's the case, how do you add/edit/remove users in general? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ok I tried to convert the password into a password hash prior to storing it into the session, however, I am getting this error: AttributeError: module 'hashlib' has no attribute 'pbkdf2_hmac' Here is my code: `def generateKeyDict(username, password, *salt):
Not sure what is going on here, unless hashlib.pbkdf2_hmac is incorrect in spite ofhttps://www.askpython.com/python/examples/storing-retrieving-passwords-securely Also, please ignore the indentations; this editor is creating them in spite of my using tabs to do so in my IDE Thanks |
BetaWas this translation helpful?Give feedback.
All reactions
-
Also, for this particular web portal, for now, there is only one user, and there are no plans for additional ones, hence the session with the password hash and not a database for multiple users |
BetaWas this translation helpful?Give feedback.
All reactions
-
I now keep getting the error No such attribute 'pbkdf2_hmac' Each time I try to use it in PyScript to encode my password securely prior to storing it. I don't know what to do. `def generateKeyDict(username, password, *salt):
|
BetaWas this translation helpful?Give feedback.
All reactions
-
This conversation is not going forward well ... I've asked how you are storing credentials and you are showing me errors unrelated to this project ... how can we help? packages used with PyScript are not provided by PyScript, as example, so if you have any issue withhashlib you should ask details, file issues, or read more wherehashlib is provided, which is likely via thePyodide project. |
BetaWas this translation helpful?Give feedback.
All reactions
-
The conversation isn't going well because of my disability which renders my ability to communicate extremely difficult to understand by many in the outside world, so I humbly apologize for my shortcomings and will try to make this as clear as I possibly can given the circumstances: I am writing my own homemade content management application web portal in PyScript. Currently all it should be able to do is handle login requests and signup requests until further notice. It will reside on my laptop. Only I will use it and no one else. I realize that the easiest and most basic methodology to handle login credentials is to use a database platform with a table that stores usernames, password hashes, salts, emails, etc.; I also realize that PyScript currently has no ability to interact with MySQL (import mysql.connector fails even after "pip install mysql"), so what I did was to build a PHP-based stub on my IIS platform that will perform the MySQL heavy lifting for me and return a JSON array string with the data I need (again, password hash). So now I have my PyScript front-end that needs to do a fetch onto the PHP side on IIS, all on my laptop (PyScript is "http://localhost:8000"; PHP is "http://localhost/cma"). The fetch fails due to CORS errors. I have tried everything I can think of, including creating an API Proxy on PyScript.com, but I don't know how to tellhttp://localhost:8000 to go to the API Proxy on PyScript.com to tell it to pass the football ontohttp://localhost/cma. This is the code I am using that fails: `import asyncio, logging '''
''' def getLoginCredz(username):
async def getUrlBody(url):
|
BetaWas this translation helpful?Give feedback.
All reactions
-
And I figured it out on my own:
So that's as far as I have so far been able to go |
BetaWas this translation helpful?Give feedback.
All reactions
-
may I ask why are you using Pyscript .com to communicate with your own localhost based infrastructure? Wouldn't it be better to simply host your solution within your network boundaries, i.e. via your device IP address? I am struggling to see the whole picture here, what are the end points, where are these endpoints, but most importantly, how you expect a public site (PyScript .com or any other) to directly interact with your local environment and I know you can do that but it needs you registering your own domain and point that domain at your own internal (and static) IP address within your network (plus the port, if different from 80) but it looks like you are trying to do things that are not meant to be done in a secure way and when that happens, the browsers and the Web standards will fight you back at any move (rightly so, it's a secure platform, after all, non-secure things should bever be easy to happen). That being said, this discussion is rather a request for help creating your own application but it doesn't provide pages and files or a way to setup and test or help you forward so I strongly suggest you to create a GitHub repository anyone can clone and try with, eventually, a counter Pyscript .com page/link/app one can test/try once the whole thing starts/runs or it's nearly impossible to follow issues or help this way and it's not a PyScript strictly related discussion neither so I am not sure what we could do here to help. |
BetaWas this translation helpful?Give feedback.
All reactions
-
P.S. one thing I've recently learned if you fetch |
BetaWas this translation helpful?Give feedback.