Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/update from main library #2

Merged
merged 88 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
b1eb3ae
Fix flake W605.
juanifioren Dec 3, 2018
0636c8e
support Django 2.1 in an exmaple project
yuta1024 Dec 6, 2018
1177d4c
Fix example in docs for translatable scopes
stefanfoulis Nov 30, 2018
53f86a8
Add OIDC_CLIENT_MODEL setting to enable client model swapping
eirsyl Jan 12, 2018
3cc27bd
Fix test setup for client model swapping
stefanfoulis Dec 7, 2018
5ac1cdf
Merge pull request #300 from stefanfoulis/patch-2
juanifioren Dec 9, 2018
2d5c11c
Merge pull request #305 from stefanfoulis/feature/swappable-models
juanifioren Dec 9, 2018
b96c09d
Update changelog.rst
juanifioren Dec 9, 2018
a0db261
Merge pull request #303 from yuta1024/fix/exmaple
juanifioren Dec 12, 2018
272b1ae
Update changelog.rst
juanifioren Dec 12, 2018
e93ed56
Add .coverage* to .gitignore
stefanfoulis Dec 17, 2018
90cd711
Consistently use endpoint class set on views
stefanfoulis Dec 14, 2018
3fdc226
Merge pull request #309 from stefanfoulis/patch-3
juanifioren Dec 19, 2018
628def9
Merge pull request #306 from stefanfoulis/feature/consistent-view-end…
juanifioren Dec 19, 2018
c4960d3
Set up with tox-travis
kevin-brown Jan 5, 2019
feff5e2
Use standard Python definition for test matrix
kevin-brown Jan 5, 2019
836f275
Test on Python 3.7
kevin-brown Jan 5, 2019
f8c073b
Revert "Add OIDC_CLIENT_MODEL setting to enable client model swapping…
juanifioren Jan 10, 2019
4bed6a4
Merge pull request #312 from juanifioren/revert-305-feature/swappable…
juanifioren Jan 10, 2019
a7b07e2
Update changelog.rst
juanifioren Jan 10, 2019
8a15137
Fixes #328
EvgeniGordeev Jul 1, 2019
1238b85
fix tests for python 2.7 and 3.5 - f strings not supported.
EvgeniGordeev Jul 1, 2019
3bf9116
Merge pull request #329 from EvgeniGordeev/feature-optional-scope-sup…
juanifioren Jul 6, 2019
fba4dc8
Update changelog.rst
juanifioren Jul 6, 2019
269cc0d
Update installation.rst
juanifioren Jul 6, 2019
53293f0
Merge pull request #311 from kevin-brown/travis-matrix
juanifioren Jul 6, 2019
55b3a0a
Add raw_id_fields[user] for token and code.
Jul 6, 2019
85611ef
Use static instead of deprecated staticfiles template tag
bbkgh Dec 14, 2020
3c61863
Update tox.ini
bbkgh Dec 14, 2020
c00e4ed
Update .travis.yml
bbkgh Dec 14, 2020
42f0d42
Update .travis.yml
bbkgh Dec 14, 2020
cde3618
Merge branch 'develop' into patch-1
juanifioren Dec 17, 2020
dc4b0c4
Merge pull request #382 from bbkgh/patch-1
juanifioren Dec 17, 2020
f68b049
Update changelog.rst
juanifioren Dec 17, 2020
da3a552
Added support for django 3.0, django 3.1 and django 3.2 and python 3.9
avallbona Dec 1, 2021
e6a1e52
Merge branch 'develop' into upgrade-to-django-3.2
avallbona Dec 2, 2021
2c4983d
Merge pull request #393 from avallbona/upgrade-to-django-3.2
juanifioren Dec 2, 2021
a33bb40
Clean travis + fix tox versions + remove Signal parameter.
juanifioren May 4, 2023
997c219
Bump version v0.8.0.
juanifioren May 5, 2023
ad30543
Update README.md
juanifioren May 5, 2023
2665798
Update docs with Django 4.
juanifioren May 6, 2023
d2c56b4
Create main.yml
juanifioren May 11, 2023
aaa3763
Update main.yml
juanifioren May 11, 2023
86e9596
Update main.yml
juanifioren May 11, 2023
57b09f0
Update main.yml
juanifioren May 11, 2023
8278a62
Update main.yml
juanifioren May 11, 2023
61504d4
Modify tox file.
juanifioren May 11, 2023
eeebb8c
Fix flake8.
juanifioren May 11, 2023
e28fbb6
Fix tox.
juanifioren May 11, 2023
608bd62
Update docs.
juanifioren May 12, 2023
2a0b846
Remove extra backticks in doc
charleswhchan Oct 8, 2019
516e3d3
Update main.yml
juanifioren May 15, 2023
5c1f68c
Update main.yml
juanifioren May 15, 2023
514e60c
Update main.yml
juanifioren May 15, 2023
742041a
Update main.yml
juanifioren May 15, 2023
b6fb866
Update main.yml
juanifioren May 15, 2023
14d4e6e
Update main.yml
juanifioren May 15, 2023
48e9e71
Update main.yml
juanifioren May 15, 2023
f7afb00
Update main.yml
juanifioren May 15, 2023
a1c7d87
Update main.yml
juanifioren May 15, 2023
7a1a474
Update main.yml
juanifioren May 15, 2023
03d41fa
Update contribute.rst
juanifioren May 16, 2023
6c33e8f
Update contribute.rst
juanifioren May 16, 2023
c786f81
Update contribute.rst
juanifioren May 16, 2023
3c5e05f
Extract token creations to their own methods
mikkokeskinen Apr 30, 2021
da7a00c
Update changelog.rst
juanifioren May 23, 2023
dd6fdbf
Extract "is consent skip allowed" decision from the view to the endpoint
mikkokeskinen Jun 4, 2021
d5f06f1
Update changelog.rst
juanifioren May 31, 2023
3203ce7
Create FUNDING.yml
juanifioren Sep 22, 2023
03dad41
avoid race condition on code exchange for token (fixes #410)
jpaniagualaconich Oct 8, 2020
e67826c
Update token.py
juanifioren Sep 23, 2023
6627e33
Update changelog.rst
juanifioren Sep 23, 2023
efc90a6
Fix UTC warning.
juanifioren Oct 22, 2023
b72435a
Bump version 0.8.1.
juanifioren Oct 22, 2023
4eb8e3c
ReadTheDocs new configuration file.
juanifioren Oct 23, 2023
bed4d9a
Update README.md
juanifioren Oct 25, 2023
fe9b031
Fix ResponseType data migration
Urth Oct 21, 2020
935c90d
Update changelog.rst
juanifioren Dec 14, 2023
8bfcd47
Correctly verify PKCE secret in token endpoint
Jan 27, 2020
0f236e8
Improve happy path test assertion
Feb 12, 2020
b2a22e1
Update changelog.rst
juanifioren Dec 14, 2023
90b9f54
Update contribute.rst
juanifioren Dec 15, 2023
5d4980a
Add Discovery endpoint response caching.
juanifioren Dec 15, 2023
87c4dc9
Update changelog.rst
juanifioren Dec 15, 2023
65e7c17
Bump version 0.8.2.
juanifioren Dec 15, 2023
0a0bcf2
Merge tag 'v0.8.2' into task/update-from-main-library
freddygcala Feb 29, 2024
c0bf815
build: remove .github folder
freddygcala Mar 1, 2024
068b29c
build: revert change in version file
freddygcala Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docs/_build/
.eggs/
.python-version
.pytest_cache/
.coverage*
24 changes: 24 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.10"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf

# Python requirements required to build your documentation
python:
install:
- requirements: docs/requirements.txt
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Django OpenID Connect Provider

[![Python Versions](https://img.shields.io/pypi/pyversions/django-oidc-provider.svg)](https://pypi.python.org/pypi/django-oidc-provider)
[![Django Versions](https://img.shields.io/badge/Django-3.2%20%7C%204.2-green)](https://pypi.python.org/pypi/django-oidc-provider)
[![PyPI Versions](https://img.shields.io/pypi/v/django-oidc-provider.svg)](https://pypi.python.org/pypi/django-oidc-provider)
[![Documentation Status](https://readthedocs.org/projects/django-oidc-provider/badge/?version=master)](http://django-oidc-provider.readthedocs.io/)
[![Travis](https://travis-ci.org/juanifioren/django-oidc-provider.svg?branch=master)](https://travis-ci.org/juanifioren/django-oidc-provider)

## About OpenID

Expand All @@ -13,8 +13,8 @@ OpenID Connect is a simple identity layer on top of the OAuth 2.0 protocol, whic

`django-oidc-provider` can help you providing out of the box all the endpoints, data and logic needed to add OpenID Connect (and OAuth2) capabilities to your Django projects.

Support for Python 3 and 2. Also latest versions of django.
Support for Python 3 and latest versions of django.

[Read documentation for more info.](http://django-oidc-provider.readthedocs.org/)

[Do you want to contribute? Please read this.](http://django-oidc-provider.readthedocs.io/en/latest/sections/contribute.html)
[Do you want to contribute? Please read this.](http://django-oidc-provider.readthedocs.io/en/master/sections/contribute.html)
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@

# General information about the project.
project = u'django-oidc-provider'
copyright = u'2016, Juan Ignacio Fiorentino'
copyright = u'2023, Juan Ignacio Fiorentino'
author = u'Juan Ignacio Fiorentino'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.5'
version = u'0.8'
# The full version, including alpha/beta/rc tags.
release = u'0.5.x'
release = u'0.8.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx
sphinx_rtd_theme
30 changes: 30 additions & 0 deletions docs/sections/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ All notable changes to this project will be documented in this file.
Unreleased
==========


0.8.2
=====

*2023-12-15*

* Added: Discovery endpoint response caching. Introducing OIDC_DISCOVERY_CACHE_ENABLE.
* Fixed: ResponseType data migration.
* Fixed: correctly verify PKCE secret in token endpoint.

0.8.1
=====

*2023-10-22*

* Changed: create_token and create_code are now methods on base classes to enable customization.
* Changed: extract "is consent skip allowed" decision from the view to the endpoint.
* Fixed: race condition in authorization code, parallel requests may reuse same token.

0.8.0
=====

*2023-05-05*

* Changed: now supporting latest versions of Django.
* Changed: drop support for Python 2 and Django lower than 3.2.
* Added: scope on token and introspection endpoints.
* Changed: Use static instead of deprecated staticfiles template tag.
* Fixed: example in docs for translatable scopes (ugettext).

0.7.0
=====

Expand Down
14 changes: 7 additions & 7 deletions docs/sections/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ We love contributions, so please feel free to fix bugs, improve things, provide

* Create an issue and explain your feature/bugfix.
* Wait collaborators comments.
* Fork the project and create new branch from `develop`.
* Fork the project and create new branch from ``develop``.
* Make your feature addition or bug fix.
* Add tests and documentation if needed.
* Create pull request for the issue to the `develop` branch.
* Create pull request for the issue to the ``develop`` branch.
* Wait collaborators reviews.

Running Tests
Expand All @@ -21,18 +21,18 @@ Use `tox <https://pypi.python.org/pypi/tox>`_ for running tests in each of the e
# Run all tests.
$ tox

# Run with Python 3.5 and Django 2.0.
$ tox -e py35-django20
# Run with Python 3.11 and Django 4.2.
$ tox -e py311-django42

# Run single test file on specific environment.
$ tox -e py35-django20 tests/cases/test_authorize_endpoint.py
$ tox -e py311-django42 -- tests/cases/test_authorize_endpoint.py

We also use `travis <https://travis-ci.org/juanifioren/django-oidc-provider/>`_ to automatically test every commit to the project.
We use `Github Actions <https://github.com/juanifioren/django-oidc-provider/actions>`_ to automatically test every commit to the project.

Improve Documentation
=====================

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

* Install Sphinx (``pip install sphinx``) and the auto-build tool (``pip install sphinx-autobuild``).
* Move inside the docs folder. ``cd docs/``
Expand Down
21 changes: 8 additions & 13 deletions docs/sections/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Installation
Requirements
============

* Python: ``2.7`` ``3.4`` ``3.5`` ``3.6``
* Django: ``1.8`` ``1.9`` ``1.10`` ``1.11`` ``2.0``
* Python: ``3.8`` ``3.9`` ``3.10`` ``3.11``
* Django: ``3.2`` ``4.2``

Quick Installation
==================
Expand All @@ -20,24 +20,19 @@ Install the package using pip::

Add it to your apps in your project's django settings::

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
INSTALLED_APPS = [
# ...
'oidc_provider',
# ...
)
]

Include our urls to your project's ``urls.py``::

urlpatterns = patterns('',
urlpatterns = [
# ...
url(r'^openid/', include('oidc_provider.urls', namespace='oidc_provider')),
path('openid/', include('oidc_provider.urls', namespace='oidc_provider')),
# ...
)
]

Run the migrations and generate a server RSA key::

Expand Down
2 changes: 1 addition & 1 deletion docs/sections/relyingparties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Properties
* ``client_type``: Values are ``confidential`` and ``public``.
* ``client_id``: Client unique identifier.
* ``client_secret``: Client secret for confidential applications.
* ``response_types``: The flows and associated ```response_type``` values that can be used by the client.
* ``response_types``: The flows and associated ``response_type`` values that can be used by the client.
* ``jwt_alg``: Clients can choose which algorithm will be used to sign id_tokens. Values are ``HS256`` and ``RS256``.
* ``date_created``: Date automatically added when created.
* ``redirect_uris``: List of redirect URIs.
Expand Down
2 changes: 1 addition & 1 deletion docs/sections/scopesclaims.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Somewhere in your Django ``settings.py``::

Inside your oidc_provider_settings.py file add the following class::

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
from oidc_provider.lib.claims import ScopeClaims

class CustomScopeClaims(ScopeClaims):
Expand Down
25 changes: 25 additions & 0 deletions docs/sections/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ OPTIONAL. ``int``. Code object expiration after been delivered.

Expressed in seconds. Default is ``60*10``.

OIDC_DISCOVERY_CACHE_ENABLE
================

OPTIONAL. ``bool``. Enable caching the response on the discovery endpoint, by using default cache. Cache key will be a combination of site URL and types supported by the provider, changing any of these will invalidate stored value.

Default is ``False``.

OIDC_DISCOVERY_CACHE_EXPIRE
================

OPTIONAL. ``int``. Discovery endpoint cache expiration time expressed in seconds.

Expressed in seconds. Default is ``60*10``.

OIDC_EXTRA_SCOPE_CLAIMS
=======================

Expand Down Expand Up @@ -234,3 +248,14 @@ Default is::
See the :ref:`templates` section.

The templates that are not specified here will use the default ones.

OIDC_INTROSPECTION_RESPONSE_SCOPE_ENABLE
==========================================

OPTIONAL ``bool``

A flag which toggles whether the scope is returned with successful response on introspection request.

Must be ``True`` to include ``scope`` into the successful response

Default is ``False``.
4 changes: 2 additions & 2 deletions example/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'),
url(r'^accounts/login/$', auth_views.login, {'template_name': 'login.html'}, name='login'),
url(r'^accounts/logout/$', auth_views.logout, {'next_page': '/'}, name='logout'),
url(r'^accounts/login/$', auth_views.LoginView.as_view(template_name='login.html'), name='login'), # noqa
url(r'^accounts/logout/$', auth_views.LogoutView.as_view(next_page='/'), name='logout'),
url(r'^', include('oidc_provider.urls', namespace='oidc_provider')),
url(r'^admin/', admin.site.urls),
]
6 changes: 5 additions & 1 deletion oidc_provider/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.forms import ModelForm
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from oidc_provider.models import Client, Code, Token, RSAKey, RefreshToken

Expand Down Expand Up @@ -75,13 +75,17 @@ class ClientAdmin(admin.ModelAdmin):
@admin.register(Code)
class CodeAdmin(admin.ModelAdmin):

raw_id_fields = ['user']

def has_add_permission(self, request):
return False


@admin.register(Token)
class TokenAdmin(admin.ModelAdmin):

raw_id_fields = ['user']

def has_add_permission(self, request):
return False

Expand Down
2 changes: 1 addition & 1 deletion oidc_provider/lib/claims.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import copy

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from oidc_provider import settings

Expand Down
44 changes: 31 additions & 13 deletions oidc_provider/lib/endpoints/authorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,31 +126,42 @@ def validate_params(self):
raise AuthorizeError(
self.params['redirect_uri'], 'invalid_request', self.grant_type)

def create_code(self):
code = create_code(
user=self.request.user,
client=self.client,
scope=self.params['scope'],
nonce=self.params['nonce'],
is_authentication=self.is_authentication,
code_challenge=self.params['code_challenge'],
code_challenge_method=self.params['code_challenge_method'],
)

return code

def create_token(self):
token = create_token(
user=self.request.user,
client=self.client,
scope=self.params['scope'],
)

return token

def create_response_uri(self):
uri = urlsplit(self.params['redirect_uri'])
query_params = parse_qs(uri.query)
query_fragment = {}

try:
if self.grant_type in ['authorization_code', 'hybrid']:
code = create_code(
user=self.request.user,
client=self.client,
scope=self.params['scope'],
nonce=self.params['nonce'],
is_authentication=self.is_authentication,
code_challenge=self.params['code_challenge'],
code_challenge_method=self.params['code_challenge_method'])
code = self.create_code()
code.save()

if self.grant_type == 'authorization_code':
query_params['code'] = code.code
query_params['state'] = self.params['state'] if self.params['state'] else ''
elif self.grant_type in ['implicit', 'hybrid']:
token = create_token(
user=self.request.user,
client=self.client,
scope=self.params['scope'])
token = self.create_token()

# Check if response_type must include access_token in the response.
if (self.params['response_type'] in
Expand Down Expand Up @@ -261,6 +272,13 @@ def client_has_user_consent(self):

return value

def is_client_allowed_to_skip_consent(self):
implicit_flow_resp_types = {'id_token', 'id_token token'}
return (
self.client.client_type != 'public' or
self.params['response_type'] in implicit_flow_resp_types
)

def get_scopes_information(self):
"""
Return a list with the description of all the scopes requested.
Expand Down
Loading