{"id":21515035,"url":"https://github.com/nathanchen198/streamlit-rsa-auth-ui","last_synced_at":"2025-04-09T20:12:04.502Z","repository":{"id":226939102,"uuid":"769612913","full_name":"NathanChen198/streamlit-rsa-auth-ui","owner":"NathanChen198","description":"Encryption on Authenticate widget data from client to server.","archived":false,"fork":false,"pushed_at":"2024-04-08T11:27:41.000Z","size":612,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T20:11:58.085Z","etag":null,"topics":["python","react","streamlit-component"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NathanChen198.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-09T15:14:11.000Z","updated_at":"2025-03-14T16:44:31.000Z","dependencies_parsed_at":"2024-11-23T23:53:58.650Z","dependency_job_id":"75c43dbe-c44d-4cd6-a2df-fec9087b6e26","html_url":"https://github.com/NathanChen198/streamlit-rsa-auth-ui","commit_stats":null,"previous_names":["nathanchen198/streamlit-ssl-auth-ui","nathanchen198/streamlit-rsa-auth-ui"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanChen198%2Fstreamlit-rsa-auth-ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanChen198%2Fstreamlit-rsa-auth-ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanChen198%2Fstreamlit-rsa-auth-ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanChen198%2Fstreamlit-rsa-auth-ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NathanChen198","download_url":"https://codeload.github.com/NathanChen198/streamlit-rsa-auth-ui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","react","streamlit-component"],"created_at":"2024-11-23T23:53:55.602Z","updated_at":"2025-04-09T20:12:04.455Z","avatar_url":"https://github.com/NathanChen198.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to Streamlit RSA Authenticator UI 🔐\n\n[![PyPI][pypi_badge]][pypi_link]\n[![Download][pypi_download_badge]][pypi_link]\n[![GitHub][github_badge]][github_link]\n[![GitHub license][license_badge]][license_link]\n[![GitHub issues][issue_badge]][issue_link]\n[![GitHub pull requests][pull_badge]][pull_link]\n\nEncryption on Authenticate widget data from client to server.\n\n## What is Streamlit RSA Authenticator UI?\n\n### What is Http protocol\n\nHttp is the information transfer protocol between networked devices. However, all the requests and responses are in plaintext, which means that anyone can read them.\n\nIf you want to deploy streamlit server using http protocol (not https protocol) and you add the user authentication, user password can be read by anyone in the network as it is the plaintext for http protocol.\n\n`streamlit-rsa-auth-ui` correct it by encrypting user information including password at the client browser before transmit to streamlit server using [RSA algorithm](https://www.techtarget.com/searchsecurity/definition/RSA)\n\n### What is RSA algorithm\n\nIt is [asymmetric cryptography](https://www.techtarget.com/searchsecurity/definition/asymmetric-cryptography), uses two different but mathematically linked [keys](https://www.techtarget.com/searchsecurity/definition/key)\n\n- [Public key](https://www.techtarget.com/searchsecurity/definition/public-key) that can be share with everyone\n- [Private key](https://www.techtarget.com/searchsecurity/definition/private-key) must be kept secret\n\n## Installation\n\nOpen a terminal and run:\n\n```terminal\npip install streamlit-rsa-auth-ui\n```\n\n## Quickstart\n\n### Gnerate RSA Key Pair\n\nCreate a new file generateKeys.py\n\n```python\nfrom streamlit_rsa_auth_ui import Encryptor\n\nencryptor = Encryptor.generateNew(2048)\nencryptor.save('rsa', 'authkey')\n```\n\nRun `generateKeys.py` python script\n\n```terminal\npython generateKeys.py\n```\n\nthis will create a private key and public key pair\n\n- private key with the file name `authkey`\n- public key with the file name `authkey.pub`\n\n```md\n├── rsa\n│ ├── authkey\n│ │ authkey.pub\n```\n\n### Create streamlit page\n\nCreate a new file example.py\n\n```python\nimport streamlit as st\nfrom streamlit_rsa_auth_ui import Encryptor, authUI, SigninEvent, SigninFormConfig, getEvent\nss = st.session_state\n\nencryptor = Encryptor.load('rsa', 'authkey')\nui = authUI('login_ui_result', encryptor.publicKeyPem)\n\ndef checkAuth(username: str, password: str):\n    return username == 'test' and password == 'New.Prog'\n\ndef login():\n    if 'event' in ss and type(ss.event) is SigninEvent: return True\n    result = ui.signinForm(default={'remember': True}, configs=SigninFormConfig(remember=\"Rememeber Me\"))\n    if result is None: return None\n\n    _dict = encryptor.decrypt(result)\n    event = getEvent(_dict)\n    if type(event) is not SigninEvent or not checkAuth(event.username, event.password): return False\n    ss['event'] = event\n    st.rerun()\n\ndef logout():\n    result = ui.signoutForm()\n    if result is None: return False\n    _dict = encryptor.decrypt(result)\n    event = getEvent(_dict)\n    ss['event'] = event\n    return True\n\nif not login(): st.stop()\nwith st.sidebar:\n    if logout(): st.rerun()\n\nst.title('Streamlit Rsa Auth UI Test')\nbutton = st.button('test')\nbutton\n```\n\nRun the streamlit app\n\n```terminal\nstreamlit run example.py\n```\n\n## Change Log\n\n### Version 0.0.1\n\n- Initial release\n\n### Version 0.0.2\n\n- Fix missing frontend issue\n\n### Version 0.0.3\n\n- Optional 'cancel' button to signoutform\n- Minor bug fixed\n- Remove bootstrap.min.css warning\n\n### Version 0.0.4\n\n- Remove location setting(seem redundunt as if you want to add to any container/sidebar you can call with syntax)\n- Add in classname to frontend so that easier to add in custom styling if needed\n- Remove off the unnecessary excess height of streamlit\n\n### Version 1.0.0\n\n- More customizable UI\n- Add inline mode\n- Add ChangePassword UI\n\n### Version 1.1.0\n\n- Add id property in event if no public key is provided\n- Add AuthUI class\n- Add Configs class\n\n### Version 1.1.1\n\n- Fix 'no remember in signinevent' when remember option is disabled\n\n[pypi_badge]: https://img.shields.io/pypi/v/streamlit-rsa-auth-ui.svg\n[pypi_link]: https://pypi.org/project/streamlit-rsa-auth-ui\n[pypi_download_badge]: https://static.pepy.tech/badge/streamlit-rsa-auth-ui\n[github_badge]: https://badgen.net/badge/icon/GitHub?icon=github\u0026color=black\u0026label\n[github_link]: https://github.com/NathanChen198/streamlit-rsa-auth-ui\n[license_badge]: https://img.shields.io/badge/Licence-MIT-gr.svg\n[license_link]: https://github.com/NathanChen198/streamlit-rsa-auth-ui/blob/main/LICENSE\n[issue_badge]: https://img.shields.io/github/issues/NathanChen198/streamlit-rsa-auth-ui\n[issue_link]: https://github.com/NathanChen198/streamlit-rsa-auth-ui/issues\n[pull_badge]: https://img.shields.io/github/issues-pr/NathanChen198/streamlit-rsa-auth-ui\n[pull_link]: https://github.com/NathanChen198/streamlit-rsa-auth-ui/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanchen198%2Fstreamlit-rsa-auth-ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanchen198%2Fstreamlit-rsa-auth-ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanchen198%2Fstreamlit-rsa-auth-ui/lists"}