# ZMP Authentication Provider
A Python library for authentication using Basic Auth and OIDC (OpenID Connect).
## Description
This library provides authentication functionality using both Basic Authentication and OpenID Connect protocols. It's designed to be flexible and easy to integrate into your Python applications.
## Installation
```bash
pip install zmp-authentication-provider
```
## Requirements
- Python >= 3.12, < 4.0
## Dependencies
- pydantic >= 2.10.6
- pydantic-settings >= 2.9.1, < 3.0.0
- fastapi >= 0.115.11, < 0.116.0
- python-dotenv >= 1.0.1, < 2.0.0
- pyjwt >= 2.10.1, < 3.0.0
- requests >= 2.32.3, < 3.0.0
- cryptography >= 42.0.0, < 45.0
- pymongo >= 4.12.0, < 5.0.0
- motor >= 3.7.0, < 4.0.0
## Usage
```python
# FastAPI main.py
from zmp_authentication_provider.routes.auth import router as auth_router
from zmp_authentication_provider.service.auth_service import AuthService
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Lifespan for the FastAPI app."""
try:
# 8. Initialize AIOps Service
app.state.aiops_service = AIOpsService.initialize(database=database)
logger.info("AIOps Service initialized")
yield
finally:
...
app = FastAPI(
# root_path=f"{application_settings.root_path}",
title=f"{application_settings.title}",
description=f"{application_settings.description}",
version=f"{application_settings.version}",
docs_url=f"{application_settings.docs_url}",
openapi_url=f"{application_settings.openapi_url}",
redoc_url=f"{application_settings.redoc_url}",
default_response_class=JSONResponse,
debug=True,
# servers=server,
root_path_in_servers=True,
lifespan=lifespan,
)
app.include_router(auth_router, tags=["auth"], prefix=application_settings.root_path)
# router.py
from zmp_authentication_provider.auth.oauth2_keycloak import (
TokenData,
get_current_user,
)
@router.put(
"/jobs/{job_id}",
summary="Update job details",
description="Update the details of an existing job. Only the provided fields will be updated.",
response_description="The updated job information.",
response_class=JSONResponse,
response_model=Job,
response_model_by_alias=False,
response_model_exclude_none=False,
)
async def update_job(
job_update_request: JobUpdateRequest,
job_id: str = Path(..., description="The ID of the job to update"),
service: AIOpsService = Depends(_get_aiops_service),
oauth_user: TokenData = Depends(get_current_user),
):
"""Update a job's information."""
job = Job(
id=job_id,
updated_by=oauth_user.username,
**job_update_request.model_dump(exclude_unset=True),
)
return await service.modify_job(job=job)
```
### Environment Configuration
Put the below value into the`.env` file in your project root:
```env
# Authentication default configuration
AUTH_HTTP_CLIENT_SSL_VERIFY="True"
AUTH_APPLICATION_ENDPOINT="${AIOPS_API_ENDPOINT}"
# Keycloak configuration
KEYCLOAK_SERVER_URL="https://keycloak.ags.cloudzcp.net/auth"
KEYCLOAK_REALM="ags"
KEYCLOAK_CLIENT_ID="zmp-client"
KEYCLOAK_CLIENT_SECRET="p4W697V2t9WXSh3kCnCfSCt4MHK4myYG"
KEYCLOAK_REDIRECT_URI="${AUTH_APPLICATION_ENDPOINT}/oauth2/callback"
KEYCLOAK_ALGORITHM="RS256"
```
## Development
### Development Dependencies
```bash
pip install pytest pytest-cov pytest-watcher pytest-asyncio certifi ruff
```
### Quality Tools
```bash
pip install pre-commit
```
## Project Structure
The main package is located in the `src/zmp_authentication_provider` directory.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the terms of the license included in the repository.
## Author
- Kilsoo Kang (kilsoo75@gmail.com)
## Links
- [Homepage](https://github.com/cloudz-mp)
- [Repository](https://github.com/cloudz-mp/zmp-authentication-provider)
- [Documentation](https://github.com/cloudz-mp/zmp-authentication-provider)
- [Issue Tracker](https://github.com/cloudz-mp/zmp-authentication-provider/issues)
Raw data
{
"_id": null,
"home_page": "https://github.com/cloudz-mp",
"name": "zmp-authentication-provider",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": null,
"keywords": null,
"author": "Kilsoo Kang",
"author_email": "kilsoo75@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5b/36/7f61390fc6392f544bf9d01ddc6dd8e640d085e522dd8f7236d76720b85b/zmp_authentication_provider-0.1.28.tar.gz",
"platform": null,
"description": "# ZMP Authentication Provider\n\nA Python library for authentication using Basic Auth and OIDC (OpenID Connect).\n\n## Description\n\nThis library provides authentication functionality using both Basic Authentication and OpenID Connect protocols. It's designed to be flexible and easy to integrate into your Python applications.\n\n## Installation\n\n```bash\npip install zmp-authentication-provider\n```\n\n## Requirements\n\n- Python >= 3.12, < 4.0\n\n## Dependencies\n\n- pydantic >= 2.10.6\n- pydantic-settings >= 2.9.1, < 3.0.0\n- fastapi >= 0.115.11, < 0.116.0\n- python-dotenv >= 1.0.1, < 2.0.0\n- pyjwt >= 2.10.1, < 3.0.0\n- requests >= 2.32.3, < 3.0.0\n- cryptography >= 42.0.0, < 45.0\n- pymongo >= 4.12.0, < 5.0.0\n- motor >= 3.7.0, < 4.0.0\n\n## Usage\n\n```python\n# FastAPI main.py\nfrom zmp_authentication_provider.routes.auth import router as auth_router\nfrom zmp_authentication_provider.service.auth_service import AuthService\n\n@asynccontextmanager\nasync def lifespan(app: FastAPI):\n \"\"\"Lifespan for the FastAPI app.\"\"\"\n try:\n # 8. Initialize AIOps Service\n app.state.aiops_service = AIOpsService.initialize(database=database)\n logger.info(\"AIOps Service initialized\")\n\n yield\n\n finally:\n ...\n\napp = FastAPI(\n # root_path=f\"{application_settings.root_path}\",\n title=f\"{application_settings.title}\",\n description=f\"{application_settings.description}\",\n version=f\"{application_settings.version}\",\n docs_url=f\"{application_settings.docs_url}\",\n openapi_url=f\"{application_settings.openapi_url}\",\n redoc_url=f\"{application_settings.redoc_url}\",\n default_response_class=JSONResponse,\n debug=True,\n # servers=server,\n root_path_in_servers=True,\n lifespan=lifespan,\n)\n\n\napp.include_router(auth_router, tags=[\"auth\"], prefix=application_settings.root_path)\n\n\n# router.py\nfrom zmp_authentication_provider.auth.oauth2_keycloak import (\n TokenData,\n get_current_user,\n)\n\n\n@router.put(\n \"/jobs/{job_id}\",\n summary=\"Update job details\",\n description=\"Update the details of an existing job. Only the provided fields will be updated.\",\n response_description=\"The updated job information.\",\n response_class=JSONResponse,\n response_model=Job,\n response_model_by_alias=False,\n response_model_exclude_none=False,\n)\nasync def update_job(\n job_update_request: JobUpdateRequest,\n job_id: str = Path(..., description=\"The ID of the job to update\"),\n service: AIOpsService = Depends(_get_aiops_service),\n oauth_user: TokenData = Depends(get_current_user),\n):\n \"\"\"Update a job's information.\"\"\"\n job = Job(\n id=job_id,\n updated_by=oauth_user.username,\n **job_update_request.model_dump(exclude_unset=True),\n )\n return await service.modify_job(job=job)\n\n```\n\n### Environment Configuration\n\nPut the below value into the`.env` file in your project root:\n\n```env\n# Authentication default configuration\nAUTH_HTTP_CLIENT_SSL_VERIFY=\"True\"\nAUTH_APPLICATION_ENDPOINT=\"${AIOPS_API_ENDPOINT}\"\n\n# Keycloak configuration\nKEYCLOAK_SERVER_URL=\"https://keycloak.ags.cloudzcp.net/auth\"\nKEYCLOAK_REALM=\"ags\"\nKEYCLOAK_CLIENT_ID=\"zmp-client\"\nKEYCLOAK_CLIENT_SECRET=\"p4W697V2t9WXSh3kCnCfSCt4MHK4myYG\"\nKEYCLOAK_REDIRECT_URI=\"${AUTH_APPLICATION_ENDPOINT}/oauth2/callback\"\nKEYCLOAK_ALGORITHM=\"RS256\"\n```\n\n## Development\n\n### Development Dependencies\n\n```bash\npip install pytest pytest-cov pytest-watcher pytest-asyncio certifi ruff\n```\n\n### Quality Tools\n\n```bash\npip install pre-commit\n```\n\n## Project Structure\n\nThe main package is located in the `src/zmp_authentication_provider` directory.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the terms of the license included in the repository.\n\n## Author\n\n- Kilsoo Kang (kilsoo75@gmail.com)\n\n## Links\n\n- [Homepage](https://github.com/cloudz-mp)\n- [Repository](https://github.com/cloudz-mp/zmp-authentication-provider)\n- [Documentation](https://github.com/cloudz-mp/zmp-authentication-provider)\n- [Issue Tracker](https://github.com/cloudz-mp/zmp-authentication-provider/issues)\n",
"bugtrack_url": null,
"license": null,
"summary": "This is a library project for the authentication using the basic auth and oidc",
"version": "0.1.28",
"project_urls": {
"Bug Tracker": "https://github.com/cloudz-mp/zmp-authentication-provider/issues",
"Documentation": "https://github.com/cloudz-mp/zmp-authentication-provider",
"Homepage": "https://github.com/cloudz-mp",
"Repository": "https://github.com/cloudz-mp/zmp-authentication-provider"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0a14cbf390514343799a509ff423e693aee8ff78cc0f4dcc189e534aa2171bf7",
"md5": "2d3b00243a8a1fe3870d80e1acc092bc",
"sha256": "33d88cae5a693e658c6b336e277254955e236801cb25a3c00447458158c13739"
},
"downloads": -1,
"filename": "zmp_authentication_provider-0.1.28-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2d3b00243a8a1fe3870d80e1acc092bc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 18309,
"upload_time": "2025-07-09T17:35:19",
"upload_time_iso_8601": "2025-07-09T17:35:19.286182Z",
"url": "https://files.pythonhosted.org/packages/0a/14/cbf390514343799a509ff423e693aee8ff78cc0f4dcc189e534aa2171bf7/zmp_authentication_provider-0.1.28-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5b367f61390fc6392f544bf9d01ddc6dd8e640d085e522dd8f7236d76720b85b",
"md5": "4361ead7e7a5441d69db7e2b4674a38c",
"sha256": "525d78dd9794bd821dea83827754b6203ef963773ebdedccb787ac82fc56ca7e"
},
"downloads": -1,
"filename": "zmp_authentication_provider-0.1.28.tar.gz",
"has_sig": false,
"md5_digest": "4361ead7e7a5441d69db7e2b4674a38c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 14386,
"upload_time": "2025-07-09T17:35:20",
"upload_time_iso_8601": "2025-07-09T17:35:20.642120Z",
"url": "https://files.pythonhosted.org/packages/5b/36/7f61390fc6392f544bf9d01ddc6dd8e640d085e522dd8f7236d76720b85b/zmp_authentication_provider-0.1.28.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-09 17:35:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cloudz-mp",
"github_project": "zmp-authentication-provider",
"github_not_found": true,
"lcname": "zmp-authentication-provider"
}