Read the signed ShinyHub identity a Shiny/Streamlit/Dash app receives, in one call.
Project description
shinyhub-identity
Read the signed identity ShinyHub forwards to your app, in one call. No per-app JWT plumbing.
ShinyHub injects a short-lived, per-app HS256 JWT
(X-Shinyhub-Identity-Token) into every request it proxies, and hands your app
its verification key via SHINYHUB_IDENTITY_KEY and SHINYHUB_APP_SLUG. This
package verifies that token and returns the identity.
pip install shinyhub-identity
# or: uv add shinyhub-identity
Use it
from shinyhub_identity import current_user
def server(input, output, session):
user = current_user(session.http_conn.headers) # None when anonymous
if user is None:
... # logged-out visitor
elif "platform-admins" in user.groups:
... # gate admin features on the VERIFIED groups
current_user(headers) returns an Identity (user_id, username, role,
email, groups, groups_truncated, and the raw claims) or None. email
is "" unless the deployment's forward-auth SSO asserts one. It works with any
header mapping - Shiny for Python's session.http_conn.headers, a
Starlette/Flask request's headers, or a plain dict.
Every failure is anonymous, never a crash. No token, bad signature, wrong
audience/issuer, an expired token, or no ShinyHub in front at all (running the
app locally) all return None, so your app stays testable without SSO.
current_user reads SHINYHUB_IDENTITY_KEY/SHINYHUB_APP_SLUG from the
environment by default; pass key=/slug= explicitly for tests.
Why verify, not just read the plain headers?
ShinyHub also forwards convenience plain headers (X-Shinyhub-User, -Role,
-Groups, ...) and strips any client-supplied ones. But app processes listen on
host-local ports, so a co-located process can bypass the proxy and forge plain
headers. Anything that gates access must verify the token - which is exactly
what this package does. See ShinyHub's docs/identity.md for the full trust
model.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shinyhub_identity-0.1.0.tar.gz.
File metadata
- Download URL: shinyhub_identity-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b3ab8bb164079840b19b0a0e9f023de89b08a792402f17abea1e9e8c04e874
|
|
| MD5 |
dc6be916c7b488536e2aacceb19e111a
|
|
| BLAKE2b-256 |
f8c7278dac08cf1022dc279acade3dbf45a79469dde4e471d991c22bb3e8f5eb
|
Provenance
The following attestation bundles were made for shinyhub_identity-0.1.0.tar.gz:
Publisher:
release.yml on rvben/shinyhub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shinyhub_identity-0.1.0.tar.gz -
Subject digest:
60b3ab8bb164079840b19b0a0e9f023de89b08a792402f17abea1e9e8c04e874 - Sigstore transparency entry: 2113331171
- Sigstore integration time:
-
Permalink:
rvben/shinyhub@0b0bd144881c9a5ab048abdf17bce2165c66ec91 -
Branch / Tag:
refs/tags/v0.9.6 - Owner: https://github.com/rvben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0b0bd144881c9a5ab048abdf17bce2165c66ec91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file shinyhub_identity-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shinyhub_identity-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25fd107b23825584392012a0a31988feb25c51675a7ff565517306e4a996c08c
|
|
| MD5 |
07699f13a52636c9ddb915cfc6b2a88c
|
|
| BLAKE2b-256 |
720a1f4f5e6c1ebb948529047e57e802b3aee70cf0ebb3868be3b3cf2ba8c7eb
|
Provenance
The following attestation bundles were made for shinyhub_identity-0.1.0-py3-none-any.whl:
Publisher:
release.yml on rvben/shinyhub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shinyhub_identity-0.1.0-py3-none-any.whl -
Subject digest:
25fd107b23825584392012a0a31988feb25c51675a7ff565517306e4a996c08c - Sigstore transparency entry: 2113331241
- Sigstore integration time:
-
Permalink:
rvben/shinyhub@0b0bd144881c9a5ab048abdf17bce2165c66ec91 -
Branch / Tag:
refs/tags/v0.9.6 - Owner: https://github.com/rvben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0b0bd144881c9a5ab048abdf17bce2165c66ec91 -
Trigger Event:
push
-
Statement type: