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

update #1

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions oidc_auth/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.apps import AppConfig


class OidcAuthConfig(AppConfig):
name = 'oidc_auth'
7 changes: 5 additions & 2 deletions oidc_auth/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
],
),
]
14 changes: 10 additions & 4 deletions oidc_auth/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions oidc_auth/urls.py
Original file line number Diff line number Diff line change
@@ -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'),
]
4 changes: 2 additions & 2 deletions oidc_auth/views.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
12 changes: 6 additions & 6 deletions urls.py
Original file line number Diff line number Diff line change
@@ -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)),
]