Skip to content

Commit ff2245a

Browse files
committed
UA-4672 | Merge branch 'juanifioren-master' into UA-4672-attempt3
2 parents a092422 + 75d4b91 commit ff2245a

36 files changed

+1521
-272
lines changed

.github/workflows/main.yml

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,61 @@
1-
name: Django Tests CI
2-
1+
name: "CI"
32
on:
43
push:
54
branches: ["master", "develop"]
65
pull_request:
7-
branches: ["develop"]
6+
7+
concurrency:
8+
group: check-${{ github.ref }}
9+
cancel-in-progress: true
810

911
jobs:
10-
tests:
12+
formatting:
13+
name: "Check Code Formatting"
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: astral-sh/ruff-action@v3
18+
with:
19+
args: "--version"
20+
- run: "ruff format --check --diff"
21+
22+
linting:
23+
name: "Check Code Linting"
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: astral-sh/ruff-action@v3
28+
with:
29+
args: "--version"
30+
- run: "ruff check --diff"
31+
32+
test_matrix_prep:
33+
name: "Prepare Test Matrix"
34+
runs-on: ubuntu-latest
35+
outputs:
36+
matrix: "${{ steps.set-matrix.outputs.matrix }}"
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: astral-sh/setup-uv@v3
40+
- run: uv tool install tox
41+
- id: set-matrix
42+
run: |
43+
matrix=$(tox -l | jq -Rc 'select(test("^py\\d+.*django\\d+")) | capture("^py(?<python>\\d+).*django(?<django>\\d+)") | {"python": (.python | tostring | .[0:1] + "." + .[1:]), "django": (.django | tostring | .[0:1] + "." + .[1:])}' | jq -sc '{include: .}')
44+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
45+
46+
test:
47+
name: "Test Django ${{ matrix.django }} | Python ${{ matrix.python }}"
48+
needs: test_matrix_prep
1149
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix: ${{ fromJson(needs.test_matrix_prep.outputs.matrix) }}
1253
steps:
13-
- uses: actions/checkout@v3
54+
- uses: actions/checkout@v4
55+
- uses: astral-sh/setup-uv@v3
56+
- run: uv tool install tox
1457
- uses: actions/setup-python@v4
1558
with:
16-
python-version: |
17-
3.8
18-
3.9
19-
3.10
20-
3.11
21-
- name: Install tox
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install tox
59+
python-version: ${{ matrix.python }}
2560
- name: Run tox
26-
run: tox
61+
run: tox run --skip-missing-interpreters=false -e py$(echo "${{ matrix.python }}" | tr -d '.')-django$(echo "${{ matrix.django }}" | tr -d '.')

.vscode/settings.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
"[python]": {
33
"editor.formatOnSave": true,
44
"editor.codeActionsOnSave": {
5-
"source.fixAll": "explicit",
6-
"source.organizeImports": "explicit"
5+
"source.fixAll.ruff": "explicit",
6+
"source.organizeImports.ruff": "explicit"
77
},
88
"editor.defaultFormatter": "charliermarsh.ruff"
9-
}
9+
},
10+
"ruff.enable": true,
11+
"ruff.nativeServer": true,
12+
"python.analysis.ignore": ["*"],
13+
"python.analysis.autoImportCompletions": false,
14+
"pylint.enabled": false
1015
}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Django OpenID Connect Provider
22

33
[![Python Versions](https://img.shields.io/pypi/pyversions/django-oidc-provider.svg)](https://pypi.python.org/pypi/django-oidc-provider)
4-
[![Django Versions](https://img.shields.io/badge/Django-3.2%20%7C%204.2-green)](https://pypi.python.org/pypi/django-oidc-provider)
4+
[![Django Versions](https://img.shields.io/badge/Django-3.2%20%7C%204.2%20%7C%205.2-green)](https://pypi.python.org/pypi/django-oidc-provider)
55
[![PyPI Versions](https://img.shields.io/pypi/v/django-oidc-provider.svg)](https://pypi.python.org/pypi/django-oidc-provider)
66
[![Documentation Status](https://readthedocs.org/projects/django-oidc-provider/badge/?version=master)](http://django-oidc-provider.readthedocs.io/)
77

@@ -18,3 +18,7 @@ Support for Python 3 and latest versions of django.
1818
[Read documentation for more info.](http://django-oidc-provider.readthedocs.org/)
1919

2020
[Do you want to contribute? Please read this.](http://django-oidc-provider.readthedocs.io/en/master/sections/contribute.html)
21+
22+
## Thanks to our sponsors
23+
24+
[![Agilentia](https://avatars.githubusercontent.com/u/1707212?s=60&v=4)](https://github.com/agilentia)

docs/sections/changelog.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,28 @@ All notable changes to this project will be documented in this file.
88
Unreleased
99
==========
1010

11-
None
11+
0.9.0
12+
=====
13+
14+
*2025-09-23*
15+
16+
* Changed: Use PyJWT+cryptography instead of jwkest+Cryptodrome.
17+
* Added: Translation to Russian.
18+
* Changed: Ruff as a fast Python linter and code formatter.
19+
* Fixed: client_id sanitization to prevent database errors.
20+
21+
0.8.4
22+
=====
23+
24+
*2025-05-24*
25+
26+
* Added: test package against Python 3.12 and 3.13.
27+
* Added: test package against Django 5.
28+
* Added: support of max_age parameter on authorization request.
29+
* Added: Passing Request Parameters as JWTs now returning request_not_supported error.
30+
* Added: Simplified chinese translation.
31+
* Changed: ID Token JSON encoder improved using DjangoJSONEncoder.
32+
* Changed: Use unittest.mock in tests. Remove mock library.
1233

1334
0.8.3
1435
=====

docs/sections/contribute.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Improve Documentation
3434

3535
We use `Sphinx <http://www.sphinx-doc.org/>`_ to generate this documentation. If you want to add or modify something just:
3636

37-
* Install Sphinx (``pip install sphinx sphinx_rtd_theme``) and the auto-build tool (``pip install sphinx-autobuild``).
37+
* Install Sphinx and the auto-build tool (``pip install sphinx sphinx_rtd_theme sphinx-autobuild``).
3838
* Move inside the docs folder. ``cd docs/``
3939
* Generate and watch docs by running ``sphinx-autobuild . _build/``.
4040
* Open ``http://127.0.0.1:8000`` in a browser.

docs/sections/installation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Installation
66
Requirements
77
============
88

9-
* Python: ``3.8`` ``3.9`` ``3.10`` ``3.11``
10-
* Django: ``3.2`` ``4.2``
9+
* Python: ``3.8`` ``3.9`` ``3.10`` ``3.11`` ``3.12``
10+
* Django: ``3.2`` ``4.2`` ``5.1``
1111

1212
Quick Installation
1313
==================

docs/sections/templates.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Templates
66
Add your own templates files inside a folder named ``templates/oidc_provider/``.
77
You can copy the sample html files here and customize them with your own style.
88

9-
**authorize.html**::
9+
authorize.html
10+
==============
11+
::
1012

1113
<h1>Request for Permission</h1>
1214

@@ -29,7 +31,9 @@ You can copy the sample html files here and customize them with your own style.
2931

3032
</form>
3133

32-
**error.html**::
34+
error.html
35+
==========
36+
::
3337

3438
<h3>{{ error }}</h3>
3539
<p>{{ description }}</p>
@@ -51,3 +55,18 @@ The following contexts will be passed to the ``authorize`` and ``error`` templat
5155
'error': 'string stating the error',
5256
'description': 'string stating description of the error'
5357
}
58+
59+
end_session_prompt.html
60+
=======================
61+
62+
Read more at :doc:`Session Management > Logout consent prompt </sections/sessionmanagement>` section.
63+
64+
end_session_completed.html
65+
==========================
66+
67+
Read more at :doc:`Session Management > Other scenarios <../sections/sessionmanagement>` section.
68+
69+
end_session_failed.html
70+
=======================
71+
72+
Read more at :doc:`Session Management > Other scenarios <../sections/sessionmanagement>` section.

example/Dockerfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
FROM python:3-onbuild
1+
FROM python:3.11-slim
2+
3+
WORKDIR /usr/src/app
4+
5+
# Copy requirements and install dependencies
6+
COPY requirements.txt .
7+
RUN pip install --upgrade pip && \
8+
pip install --no-cache-dir -r requirements.txt
9+
10+
# Copy application code
11+
COPY . .
212

313
RUN [ "python", "manage.py", "migrate" ]
414
RUN [ "python", "manage.py", "creatersakey" ]
15+
16+
# Create superuser with admin:admin credentials
17+
ENV DJANGO_SUPERUSER_USERNAME=admin
18+
19+
ENV DJANGO_SUPERUSER_PASSWORD=admin
20+
RUN [ "python", "manage.py", "createsuperuser", "--noinput" ]
21+
522
EXPOSE 8000
623
CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]

example/README.md

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,18 @@
11
# Example Project
22

3-
![Example Project](https://s17.postimg.org/4jjj8lavj/Screen_Shot_2016_09_07_at_15_58_43.png)
4-
53
On this example you'll be running your own OIDC provider in a second. This is a Django app with all the necessary things to work with `django-oidc-provider` package.
64

7-
## Setup & Running
8-
9-
- [Manually](#manually)
10-
- [Using Docker](#using-docker)
11-
12-
### Manually
13-
14-
Setup project environment with [virtualenv](https://virtualenv.pypa.io) and [pip](https://pip.pypa.io).
15-
16-
```bash
17-
$ virtualenv -p /usr/bin/python3 project_env
18-
19-
$ source project_env/bin/activate
20-
21-
$ git clone https://github.com/juanifioren/django-oidc-provider.git
22-
$ cd django-oidc-provider/example
23-
$ pip install -r requirements.txt
24-
```
25-
26-
Run your provider.
27-
28-
```bash
29-
$ python manage.py migrate
30-
$ python manage.py creatersakey
31-
$ python manage.py createsuperuser
32-
$ python manage.py runserver
33-
```
34-
35-
Open your browser and go to `http://localhost:8000`. Voilà!
36-
37-
### Using Docker
5+
## Setup & running using Docker
386

397
Build and run the container.
408

419
```bash
4210
$ docker build -t django-oidc-provider .
43-
$ docker run -d -p 8000:8000 django-oidc-provider
11+
$ docker run -p 8000:8000 --name django-oidc-provider-app django-oidc-provider
4412
```
4513

14+
Go to http://localhost:8000/ and create your Client.
15+
4616
## Install package for development
4717

4818
After you run `pip install -r requirements.txt`.

oidc_provider/admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.forms import ModelForm
77
from django.utils.translation import gettext_lazy as _
88

9+
from oidc_provider.lib.utils.sanitization import sanitize_client_id
910
from oidc_provider.models import Client
1011
from oidc_provider.models import Code
1112
from oidc_provider.models import RSAKey
@@ -23,12 +24,15 @@ def __init__(self, *args, **kwargs):
2324
self.fields["client_id"].widget.attrs["disabled"] = "true"
2425
self.fields["client_secret"].required = False
2526
self.fields["client_secret"].widget.attrs["disabled"] = "true"
27+
self.fields["jwt_alg"].required = False
2628

2729
def clean_client_id(self):
2830
instance = getattr(self, "instance", None)
2931
if instance and instance.pk:
30-
return instance.client_id
32+
# Sanitize existing client_id to remove any problematic characters
33+
return sanitize_client_id(instance.client_id)
3134
else:
35+
# Generate new client_id (digits only)
3236
return str(randint(1, 999999)).zfill(6)
3337

3438
def clean_client_secret(self):

0 commit comments

Comments
 (0)