mushroom-magic-campus-auth
Magic Campus authentication provider for MushroomAgent server auth.
It validates an incoming token by calling Magic Campus:
GET /api/v1/accounts/getUserInfo
Authorization: Bearer <AccessToken>
Expected response:
{
"code": 200,
"msg": "ok",
"data": {
"userId": 123,
"nickname": "Alice",
"avatarUrl": "https://example.test/avatar.png",
"phone": "13800000000",
"email": "alice@example.test"
}
}
Install For Local Development
From this directory:
pip install -e .
Or install it into the same Python environment that runs mushroom-agent.
After publishing to PyPI:
pip install mushroom-magic-campus-auth
MushroomAgent Config
Add this provider to ~/.mushroom_agent/config.yaml:
server:
auth:
providers:
- type: import
path: mushroom_magic_campus_auth:create_provider
config:
base_url: "https://magic-campus.example.com"
timeout_seconds: 3
# Optional fallback to existing MushroomAgent accesskeys.
- type: accesskey
If you do not include type: accesskey, only Magic Campus tokens will be accepted.
Token Sources
MushroomAgent extracts token candidates from:
Authorization: Bearer <token>- query parameters:
accesskey,token,auth_token - cookie:
mushroom_server_auth
This means the provider works for:
- HTTP API
- WebUI login
/ws/v1/chat/ws/v1/node
Config Options
config:
base_url: "https://magic-campus.example.com" # required
user_info_path: "/api/v1/accounts/getUserInfo" # optional
timeout_seconds: 3 # optional
expected_code: 200 # optional
issue_cookie: false # optional
headers: # optional extra headers
X-App-Id: "mushroom-agent"
issue_cookie: true asks MushroomAgent to set the accepted token as the auth cookie after WebUI login.
Try With curl
curl -X POST "http://127.0.0.1:7860/i/chat/api/messages" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <MagicCampusAccessToken>" \
-d '{"text":"hello"}'
Development
pip install -e ".[dev]"
pytest
Build And Publish To PyPI
Install build tools:
pip install -e ".[dev]"
Build source and wheel distributions:
python -m build
Validate package metadata:
twine check dist/*
Upload to TestPyPI first:
twine upload --repository testpypi dist/*
Upload to PyPI:
twine upload dist/*
Use a PyPI API token when prompted for the password. The username is usually __token__.
Metadata
Release files for mushroom-magic-campus-auth 0.1.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 |
|---|---|---|---|---|
| mushroom_magic_campus_auth-0.1.0.tar.gz | 4.9 kB | Without provenance | Details for mushroom_magic_campus_auth-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mushroom_magic_campus_auth-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mushroom_magic_campus_auth-0.1.0-py3-none-any.whl |
Total release size: 10.1 kB
Release files / mushroom_magic_campus_auth-0.1.0.tar.gz
| Download URL | mushroom_magic_campus_auth-0.1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
732a866b3a7b31883c8ac2e2ba79ac3f07db7b9db8da626f1d58d25116485c37
|
|
BLAKE2b-256 checksum How to use checksums |
ff0dfdb2e50e0fd2ff8ad7f5e199f8da1c48d16f63be10bd56f3c9ca45d77947
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / mushroom_magic_campus_auth-0.1.0-py3-none-any.whl
| Download URL | mushroom_magic_campus_auth-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a0e5d7f1eb017f0a2fed9b8656c8bd6747cab04ca7047c61945b450b16a9d37
|
|
BLAKE2b-256 checksum How to use checksums |
7e7c0501b36e9e52f94e40905ea3dd2ea561cc360bf5e920a1f9cc0222b47b24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for mushroom-magic-campus-auth 0.1.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.