django-drf-keycloak-auth


Namedjango-drf-keycloak-auth JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/xiaobitipao/django-drf-keycloak-auth
SummaryDjango app for Keycloak OAuth2 authentication with DRF.
upload_time2025-10-20 03:16:12
maintainerNone
docs_urlNone
authorxiaobitipao
requires_python>=3.11
licenseMIT
keywords keycloak django djangorestframework oauth2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-drf-keycloak-auth

When using `Django`, `DRF`, and `Keycloak` for authentication and permission management, `django-drf-keycloak-auth` can make your work easier.

## Getting Started

```bash
pip install django-drf-keycloak-auth

OR

uv add django-drf-keycloak-auth
```

## Usage

1. Add `django-drf-keycloak-auth` to `requirements.txt`

    ```bash
    django-drf-keycloak-auth==0.1.0
    ```

    > You need to create your own `nonce` and `state` on the client side and then pass that `nonce` and `state` along with the `redirect_uri` to the server side. `code` and `state` are returned after successful authentication. You need to use the `code` to obtain token information.

2. Set environment variables

    Refer to the `.env.template` in [django-drf-keycloak-auth-example-back-end](https://github.com/xiaobitipao/django-drf-keycloak-auth-example-back-end).

## Examples

There is a full example in the [django-drf-keycloak-auth-example-front-end](https://github.com/xiaobitipao/django-drf-keycloak-auth-example-front-end) and [django-drf-keycloak-auth-example-back-end](https://github.com/xiaobitipao/django-drf-keycloak-auth-example-back-end) that can be run directly.

You can start from the example to learn how to use `django-drf-keycloak-auth`.

## Deploy project(memo for developer)

### setuptools version

The latest `setuptools`(version 80.9.0) produces `.whl` files with a `METADATA` version of `2.4`. You can check this by running:

```bash
unzip -p dist/*.whl '*/METADATA' | sed -n '1,160p'
```

Note that `TestPyPI` and  `TestPyPI` only supports `METADATA` versions `1.0–2.2`. Therefore, if you plan to publish your package to `TestPyPI` or  `TestPyPI`, you should not use the latest `setuptools`.

### Deploy to TestPyPI

> Depending on the network environment, you may need to use a proxy.

```bash
# https://test.pypi.org/
expect interactive_deploy_test.expect
```

> Install `django-drf-keycloak-auth` from TestPyPI.
>
> ```bash
> uv pip uninstall django-drf-keycloak-auth
> 
> uv pip install --no-cache-dir \
>   --index-url https://pypi.org/simple \
>   --extra-index-url https://test.pypi.org/simple \
>   --index-strategy unsafe-best-match \
>   django-drf-keycloak-auth==0.0.1
> ```
>
> OR
>
> `uv pip install --index-url https://test.pypi.org/simple django-drf-keycloak-auth==0.0.1`

### Deploy to PyPI

> Depending on the network environment, you may need to use a proxy.

```bash
# https://pypi.org/
expect interactive_deploy.expect
```

### How to mark a version as yanked

```bash
twine yank <package_name> --version <version> --reason "Reason this release was yanked: Yanked due to <reason>"
```

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.1] - 2025-10-15

-   First commit(Only for test)

## [0.0.2] - 2025-10-17

-   Add drf-spectacular support

-   Update auth api

## [0.1.0] - 2025-10-20

-   Update client state support

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xiaobitipao/django-drf-keycloak-auth",
    "name": "django-drf-keycloak-auth",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "keycloak, django, djangorestframework, oauth2",
    "author": "xiaobitipao",
    "author_email": "xiaobitipao@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/73/e8/af85ebf304c4d10e914c2687cb46ed715241cdf873b45ff4e56369da1d33/django_drf_keycloak_auth-0.1.0.tar.gz",
    "platform": null,
    "description": "# django-drf-keycloak-auth\n\nWhen using `Django`, `DRF`, and `Keycloak` for authentication and permission management, `django-drf-keycloak-auth` can make your work easier.\n\n## Getting Started\n\n```bash\npip install django-drf-keycloak-auth\n\nOR\n\nuv add django-drf-keycloak-auth\n```\n\n## Usage\n\n1. Add `django-drf-keycloak-auth` to `requirements.txt`\n\n    ```bash\n    django-drf-keycloak-auth==0.1.0\n    ```\n\n    > You need to create your own `nonce` and `state` on the client side and then pass that `nonce` and `state` along with the `redirect_uri` to the server side. `code` and `state` are returned after successful authentication. You need to use the `code` to obtain token information.\n\n2. Set environment variables\n\n    Refer to the `.env.template` in [django-drf-keycloak-auth-example-back-end](https://github.com/xiaobitipao/django-drf-keycloak-auth-example-back-end).\n\n## Examples\n\nThere is a full example in the [django-drf-keycloak-auth-example-front-end](https://github.com/xiaobitipao/django-drf-keycloak-auth-example-front-end) and [django-drf-keycloak-auth-example-back-end](https://github.com/xiaobitipao/django-drf-keycloak-auth-example-back-end) that can be run directly.\n\nYou can start from the example to learn how to use `django-drf-keycloak-auth`.\n\n## Deploy project(memo for developer)\n\n### setuptools version\n\nThe latest `setuptools`(version 80.9.0) produces `.whl` files with a `METADATA` version of `2.4`. You can check this by running:\n\n```bash\nunzip -p dist/*.whl '*/METADATA' | sed -n '1,160p'\n```\n\nNote that `TestPyPI` and  `TestPyPI` only supports `METADATA` versions `1.0\u20132.2`. Therefore, if you plan to publish your package to `TestPyPI` or  `TestPyPI`, you should not use the latest `setuptools`.\n\n### Deploy to TestPyPI\n\n> Depending on the network environment, you may need to use a proxy.\n\n```bash\n# https://test.pypi.org/\nexpect interactive_deploy_test.expect\n```\n\n> Install `django-drf-keycloak-auth` from TestPyPI.\n>\n> ```bash\n> uv pip uninstall django-drf-keycloak-auth\n> \n> uv pip install --no-cache-dir \\\n>   --index-url https://pypi.org/simple \\\n>   --extra-index-url https://test.pypi.org/simple \\\n>   --index-strategy unsafe-best-match \\\n>   django-drf-keycloak-auth==0.0.1\n> ```\n>\n> OR\n>\n> `uv pip install --index-url https://test.pypi.org/simple django-drf-keycloak-auth==0.0.1`\n\n### Deploy to PyPI\n\n> Depending on the network environment, you may need to use a proxy.\n\n```bash\n# https://pypi.org/\nexpect interactive_deploy.expect\n```\n\n### How to mark a version as yanked\n\n```bash\ntwine yank <package_name> --version <version> --reason \"Reason this release was yanked: Yanked due to <reason>\"\n```\n\n# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this\nproject adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [0.0.1] - 2025-10-15\n\n-   First commit(Only for test)\n\n## [0.0.2] - 2025-10-17\n\n-   Add drf-spectacular support\n\n-   Update auth api\n\n## [0.1.0] - 2025-10-20\n\n-   Update client state support\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django app for Keycloak OAuth2 authentication with DRF.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/xiaobitipao/django-drf-keycloak-auth"
    },
    "split_keywords": [
        "keycloak",
        " django",
        " djangorestframework",
        " oauth2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43a099ec50a416c6090143fbc6cd27269fd6d3c6db1212bbe4abb222f6cf87be",
                "md5": "70027d8e8b400af71d55c4590c4bd678",
                "sha256": "4017c179c525d83bc1f28844b921433058cb40ceb065a220cc741a47f2d8174d"
            },
            "downloads": -1,
            "filename": "django_drf_keycloak_auth-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70027d8e8b400af71d55c4590c4bd678",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 13374,
            "upload_time": "2025-10-20T03:16:11",
            "upload_time_iso_8601": "2025-10-20T03:16:11.880258Z",
            "url": "https://files.pythonhosted.org/packages/43/a0/99ec50a416c6090143fbc6cd27269fd6d3c6db1212bbe4abb222f6cf87be/django_drf_keycloak_auth-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73e8af85ebf304c4d10e914c2687cb46ed715241cdf873b45ff4e56369da1d33",
                "md5": "7b047ca6786f1402c7053facc1bf19b3",
                "sha256": "ed5cfa42edfbca7e3a8c7e4952a4dca2581542e21f65d51273e98d904597d37e"
            },
            "downloads": -1,
            "filename": "django_drf_keycloak_auth-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7b047ca6786f1402c7053facc1bf19b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 12866,
            "upload_time": "2025-10-20T03:16:12",
            "upload_time_iso_8601": "2025-10-20T03:16:12.853378Z",
            "url": "https://files.pythonhosted.org/packages/73/e8/af85ebf304c4d10e914c2687cb46ed715241cdf873b45ff4e56369da1d33/django_drf_keycloak_auth-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 03:16:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xiaobitipao",
    "github_project": "django-drf-keycloak-auth",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-drf-keycloak-auth"
}
        
Elapsed time: 2.14377s