Skim milk. Gummy bears. Pure genius.
Project description
Skim milk. Gummy bears. Pure genius.
Quick Start
> python -c "import sdsu; sdsu.main()"
Note that, for Tornado-based servers, Windows users stop the service using CRTL + PAUSE/BREAK.
Overview
The Secure, Dual-use Server Utility, or SDSU, provides:
A preconfigured, multi-handler, Tornado-based web server
Static file hosting from the /static subdirectory
SSL encryption using the certificates stored in /security
Login protection (including address whitelisting) from the credentials in /security
Secure WebSocket exchange on the same port service as static file hosting, using the /wss path.
The sdsu.main() method takes three parameters that allow users to customize the configuration of a SDSU server before it launches: securityRoot, staticRoot, and wssHandlerCls.
securityRoot
By default, the /security subdirectory contains three files:
certificate.pem defines the server’s SSL certificate
credentials.csv defines the user table. Each user is defined by an email address (“email”), password (“password”), and whitelist mask (CIDR-style, IPv6 preferred but IPv4 will be translated automatically with a “2002:” prefix.) Password and whitelist mask will be used by the SplashHandler.post() method when verifying credential submissions.
key.pem defines the server’s private SSL key.
Users can customize security configurations by creating a new copy of this directory, modifying it’s contents, and passing the new absolute path to sdsu.main() as the securityRoot parameter. For example, you are strongly encouraged to use your own certificates.
staticRoot
The /static subdirectory contains static files that will be served to satisfy HTTP requests. Except for splash.html, all static files are protected by authentication restrictions. Default contents of /static include:
index.css, a stylesheet used by index.html and placed here to demonstrate and verify protection of static file contents.
index.html, the default landing page for authenticated users.
splash.html, which defines the login page for users that have not yet been authenticated. This also serves as a logout page, as upon accessing this resource any existing sessions are cleared.
Users can customize static file contents (and therefore the bulk of their web applications) by creating a new copy of this directory, modifying it’s contents, and passing the new absolute path to sdsu.main() as the staticRoot parameter.
wssHandlerCls
The class sdsu.WssHandler defines the default behavior for secure WebSocket interaction mounted by the server to the path “/wss”. Users can customize WebSocket behaviors by inheriting from this class, then pass the new child class to sdsu.main() as the wssHandlerCls parameter. Typical usage will override one or more of the following methods:
on_open()
on_message() (by default, simply echoes the message back to the client)
on_close()
See class method documentation for more details, including method signatures. Keep in mind that each instance of the WebSocker handler class is unique to a specific client connection; state is not shared between clients.
WebSocket Client
Once a server is running, connection via WebSocket is trivial:
> var wss = new WebSocket("wss://" + window.location.host + "/wss");
> wss.addEventListener("message", console.log);
> wss.send("0");
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
File details
Details for the file sdsu-1.0.0.tar.gz
.
File metadata
- Download URL: sdsu-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c9658e577c1fc57a31131dc9723fd639dfbcea6863ed4433b687bef59cf5a08 |
|
MD5 | 583e8d4c9cd85de9b6e1db226240a914 |
|
BLAKE2b-256 | f3f3889c4749ee9725bec5d40bf551c27fe51c9c0848edd099d058fef23060eb |
File details
Details for the file sdsu-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: sdsu-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 341fc4089f5824400d46f209f0a9d8af0566e8101411b0f6efa1ac4b92b5e72e |
|
MD5 | 1b0a701e458b4a719f059d1cf2d087a3 |
|
BLAKE2b-256 | a95879d5aa3258dda0c760db4ebe71f7a09e40de4672511ccd9b848f212d59fd |