Streamlit RSA Authenticator UI
Project description
Welcome to Streamlit RSA Authenticator UI 🔐
Encryption on Authenticate widget data from client to server.
What is Streamlit RSA Authenticator UI?
What is Http protocol
Http is the information transfer protocol between networked devices. However, all the requests and responses are in plaintext, which means that anyone can read them.
If 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.
streamlit-rsa-auth-ui
correct it by encrypting user information including password at the client browser before transmit to streamlit server using RSA algorithm
What is RSA algorithm
It is asymmetric cryptography, uses two different but mathematically linked keys
- Public key that can be share with everyone
- Private key must be kept secret
Installation
Open a terminal and run:
pip install streamlit-rsa-auth-ui
Quickstart
Gnerate RSA Key Pair
Create a new file generateKeys.py
from streamlit_rsa_auth_ui import Encryptor
encryptor = Encryptor.generateNew(2048)
encryptor.save('rsa', 'authkey')
Run generateKeys.py
python script
python generateKeys.py
this will create a private key and public key pair
- private key with the file name
authkey
- public key with the file name
authkey.pub
├── rsa
│ ├── authkey
│ │ authkey.pub
Create streamlit page
Create a new file example.py
import streamlit as st
from streamlit_rsa_auth_ui import Encryptor, SigninEvent, getEvent, signinForm, signoutForm
ss = st.session_state
encryptor = Encryptor.load('rsa', 'authkey')
def checkAuth(username: str, password: str):
return username == 'test' and password == 'New.Prog'
def login():
if 'event' in ss and type(ss.event) is SigninEvent: return True
result = signinForm(encryptor.publicKeyPem, default={'remember': True}, configs={'remember': {}})
if result is None: return False
if 'result' in ss and ss['result'] == result: return False
ss['result'] = result
_dict = encryptor.decrypt(result)
event = getEvent(_dict)
if type(event) is not SigninEvent or not checkAuth(event.username, event.password): return False
ss['event'] = event
del ss['result']
st.rerun()
def logout():
result = signoutForm(encryptor.publicKeyPem)
if result is None: return False
_dict = encryptor.decrypt(result)
event = getEvent(_dict)
ss['event'] = event
return True
if not login(): st.stop()
if logout(): st.rerun()
st.title('Streamlit Rsa Auth UI Test')
st.button('test')
Run the streamlit app
streamlit run example.py
Change Log
Version 0.0.1
- Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for streamlit-rsa-auth-ui-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee628ace04d2338ce6a48bae17462414050ff320182a468b6ffb50b78f6ed248 |
|
MD5 | 03f03838f10ad9294d7392f10e2d3321 |
|
BLAKE2b-256 | b3ecd0f3206491c3d0028d3567bbe9df818acfe7c7270dba2cc5c4517c149b76 |
Hashes for streamlit_rsa_auth_ui-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | faa0d5d21b6f91a77b4cb8939d037629d1fd36e3c3bf277cf7687469e3f6629e |
|
MD5 | d3b33855e71b587099c0531246de61f2 |
|
BLAKE2b-256 | c0e5e7b42f11d4500a489f952d141bb46bf720a1811da5ff1c584fa522464593 |