Flask-GSSAPI
HTTP Negotiate (GSSAPI) authentication support for Flask applications. Secure sensitive views with transparent and secure single sign-on to authorize user access using existing access controls within your Microsoft, Samba Active Directory or FreeIPA servers.
Currently the username and ticket are not exposed to your application, however this should be possible. It also does not offer more fine-grained permission systems to user groups, only the host-based and service-based access controls implemented by your authentication server.
Installation
Install the easy way through PyPi:
$ pip install flask-gssapi
Or alternatively download and build yourself:
$ git clone https://github.com/cour4g3/flask-gssapi
$ cd flask-gssapi
$ python setup.py install
Usage
Usage is fairly simple:
from flask import Flask, render_template
from flask_gssapi import GSSAPI
app = Flask(__name__)
gssapi = GSSAPI(app)
# Here, you'll need to be authenticated
@app.route('/secret')
@gssapi.require_auth()
def secret_view():
return render_template('secret.html')
# Here, you'll need to be a specific user
@app.route('/admin')
@gssapi.require_user('admin') # or old-style @gssapi.require_user(user='admin')
def admin_view():
return render_template('admin.html')
# Or a list of users
@app.route('/staff')
@gssapi.require_user('admin', 'michael')
def staff_view():
return render_template('staff.html')
# You can also get the username as a keyword argument
@app.route('/another-secret')
@gssapi.require_auth
def admin_view(username=''):
return render_template('another-secret.html', username=username)
Configuration
For security purposes your application should probably not have read access to the system’s keytab, you should create a new keytab for the application:
$ export KRB5_KTNAME=FILE:/path/to/HTTP.keytab
$ net ads keytab create
$ net ads keytab add HTTP
$ chown httpd:httpd /path/to/HTTP.keytab
The KRB5_KTNAME will point to the correct keytab to use and can be included in your startup script or service file.
The defaults should be sufficient for most purposes, but you may need to be changed under certain circumstances:
Key |
Description |
|---|---|
GSSAPI_SERVICE_NAME |
The service name you want to authenticate against, by default this is HTTP which most browsers use. |
GSSAPI_HOSTNAME |
The hostname you want authenticate against, by default this is acquired from socket.fqdn(). |
Todo
Offer fallback to a login page or Basic authentication if no credentials are provided i.e. non-domain connected device.
Configuration key to protect all views by default with an equivalent no_auth decorator.
License
Licensed under the MIT License.
Metadata
Release files for Flask-GSSAPI 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-GSSAPI-1.5.0.tar.gz | 4.5 kB | Without provenance | Details for Flask-GSSAPI-1.5.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Flask_GSSAPI-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for Flask_GSSAPI-1.5.0-py3-none-any.whl |
| Flask_GSSAPI-1.5.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for Flask_GSSAPI-1.5.0-py2.py3-none-any.whl |
Total release size: 14.2 kB
Release files / Flask-GSSAPI-1.5.0.tar.gz
| Download URL | Flask-GSSAPI-1.5.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd3e945a17f66d644f3d7dd6bf4b1a8907213a71496cd090b0b5c23dab82d13e
|
|
BLAKE2b-256 checksum How to use checksums |
314f0891f75fd07e6fd263aa04241c274acd032c2e2a77875edb181607e785aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Release files / Flask_GSSAPI-1.5.0-py3-none-any.whl
| Download URL | Flask_GSSAPI-1.5.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3b2b69ea44b08570e6f3afaf5472f529d387a4718b1400497302f6847acac1c
|
|
BLAKE2b-256 checksum How to use checksums |
533b51b0bce2dff1c0bf1a016715d3e52fe4f83fb4fb77219e17a15ea237b203
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Release files / Flask_GSSAPI-1.5.0-py2.py3-none-any.whl
| Download URL | Flask_GSSAPI-1.5.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
36ca9efee284703ace9f17e4108cc55b79b4113ca0beb9d4cc26691f91c63e17
|
|
BLAKE2b-256 checksum How to use checksums |
5bb526d09de7592862bdcc8a69a7c834a32535acc6b44dd71592b85dcae2ac3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
|
Security for Flask-GSSAPI 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.