Skip to main content

Streamlit RSA Authenticator UI

Reason this release was yanked:

Fronend build was missing. please use version 0.0.2

Project description

Welcome to Streamlit RSA Authenticator UI 🔐

PyPI Download GitHub GitHub license GitHub issues GitHub pull requests

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-rsa-auth-ui-0.0.1.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

streamlit_rsa_auth_ui-0.0.1-py3-none-any.whl (6.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page