From df055a72b84bb16432b677a550d6152996f8c876 Mon Sep 17 00:00:00 2001 From: d4n1 Date: Tue, 12 Mar 2024 15:07:06 -0300 Subject: [PATCH 1/2] feat#77: add build v2.0.0 --- oidc_auth/apps.py | 8 ++++++++ oidc_auth/models.py | 14 ++++++++++---- oidc_auth/urls.py | 8 ++++---- oidc_auth/views.py | 4 ++-- setup.py | 13 ++++++------- urls.py | 12 ++++++------ 6 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 oidc_auth/apps.py diff --git a/oidc_auth/apps.py b/oidc_auth/apps.py new file mode 100644 index 0000000..b67feb8 --- /dev/null +++ b/oidc_auth/apps.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class OidcAuthConfig(AppConfig): + name = 'oidc_auth' diff --git a/oidc_auth/models.py b/oidc_auth/models.py index b587352..97d0270 100644 --- a/oidc_auth/models.py +++ b/oidc_auth/models.py @@ -1,7 +1,7 @@ import string import random import json -from urlparse import urljoin +from urllib.parse import urljoin import requests from django.db import models, IntegrityError from django.conf import settings @@ -196,9 +196,15 @@ def get_default_provider(): class OpenIDUser(models.Model): sub = models.CharField(max_length=255, unique=True) - issuer = models.ForeignKey(OpenIDProvider) - user = models.OneToOneField(getattr(settings, 'AUTH_USER_MODEL', 'auth.User'), - related_name='oidc_account') + issuer = models.ForeignKey( + OpenIDProvider, + on_delete=models.PROTECT + ) + user = models.OneToOneField( + getattr(settings, 'AUTH_USER_MODEL', 'auth.User'), + related_name='oidc_account', + on_delete=models.PROTECT + ) access_token = models.CharField(max_length=255) refresh_token = models.CharField(max_length=255) diff --git a/oidc_auth/urls.py b/oidc_auth/urls.py index bd32bbb..3bd2755 100644 --- a/oidc_auth/urls.py +++ b/oidc_auth/urls.py @@ -1,8 +1,8 @@ -from django.conf.urls import url +from django.urls import path -import views +from . import views urlpatterns = [ - url(r'^login/$', views.login_begin, name='oidc-login'), - url(r'^complete/$', views.login_complete, name='oidc-complete'), + path(r'^login/$', views.login_begin, name='oidc-login'), + path(r'^complete/$', views.login_complete, name='oidc-complete'), ] diff --git a/oidc_auth/views.py b/oidc_auth/views.py index 85a036e..0013a75 100644 --- a/oidc_auth/views.py +++ b/oidc_auth/views.py @@ -1,8 +1,8 @@ -from urllib import urlencode +from urllib.parse import urlencode from django.conf import settings from django.http import HttpResponseBadRequest from django.contrib.auth import REDIRECT_FIELD_NAME, authenticate, login as django_login -from django.core.urlresolvers import reverse +from django.urls import reverse from django.shortcuts import render, redirect import requests diff --git a/setup.py b/setup.py index c9402e7..acf0add 100644 --- a/setup.py +++ b/setup.py @@ -4,18 +4,17 @@ setup( name='django-oidc-auth', - version='0.0.11', + version='2.0.0', description='OpenID Connect client for Django applications', long_description='WIP', - author='Lucas S. Magalhães', - author_email='lucas.sampaio@intelie.com.br', + author='Lucas S. Magalhães, Daniel Pimentel', + author_email='lucas.sampaio@intelie.com.br, danielpimentel@lccv.ufal.br', packages=find_packages(exclude=['*.tests']), include_package_data=True, install_requires=[ - 'Django>=1.5', - 'South==1.0.2', - 'pyjwkest==0.6.2', - 'requests', + 'Django>=4.2.8', + 'pyjwkest==1.4.2', + 'requests==2.31.0', ], zip_safe=True ) diff --git a/urls.py b/urls.py index 96ac3ee..f5c072d 100644 --- a/urls.py +++ b/urls.py @@ -1,16 +1,16 @@ -from django.conf.urls import url, include +from django.urls import path, include from django.contrib import admin import oidc_auth -import views -from oidc_auth import urls +from . import views +from .oidc_auth import urls admin.autodiscover() urlpatterns = [ - url(r'^$', views.index), - url(r'^oidc/', include(oidc_auth.urls)), - url(r'^admin/', include(admin.site.urls)), + path(r'^$', views.index), + path(r'^oidc/', include(oidc_auth.urls)), + path(r'^admin/', include(admin.site.urls)), ] From 65b4cc5fff7ab4eaad04890f45c8e53607fef3d6 Mon Sep 17 00:00:00 2001 From: d4n1 Date: Fri, 22 Mar 2024 10:12:32 -0300 Subject: [PATCH 2/2] feat#89: fix oidc-auth migrations --- oidc_auth/migrations/0001_initial.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/oidc_auth/migrations/0001_initial.py b/oidc_auth/migrations/0001_initial.py index f14dc8d..2812d4b 100644 --- a/oidc_auth/migrations/0001_initial.py +++ b/oidc_auth/migrations/0001_initial.py @@ -42,8 +42,11 @@ class Migration(migrations.Migration): ('sub', models.CharField(unique=True, max_length=255)), ('access_token', models.CharField(max_length=255)), ('refresh_token', models.CharField(max_length=255)), - ('issuer', models.ForeignKey(to='oidc_auth.OpenIDProvider')), - ('user', models.OneToOneField(related_name='oidc_account', to=settings.AUTH_USER_MODEL)), + ('issuer', models.ForeignKey(to='oidc_auth.OpenIDProvider', + on_delete=models.PROTECT)), + ('user', models.OneToOneField(related_name='oidc_account', + on_delete=models.PROTECT, + to=settings.AUTH_USER_MODEL)), ], ), ]