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

v3.0.0 #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions oidc_auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def authenticate(self, **kwargs):
id_token = provider.verify_id_token(credentials['id_token'])

oidc_user = OpenIDUser.get_or_create(id_token,
credentials['access_token'],
credentials.get('refresh_token', ''),
provider)
credentials['access_token'],
credentials.get('refresh_token', ''),
provider)

return oidc_user.user
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions oidc_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def generate(cls, redirect_url, issuer, length=oidc_settings.NONCE_LENGTH):
"""This method generates and returns a nonce, an unique generated
string. If the maximum of retries is exceeded, it returns None.
"""
CHARS = string.letters + string.digits
CHARS = string.ascii_letters + string.digits

for i in range(5):
_hash = ''.join(random.choice(CHARS) for n in range(length))
Expand Down Expand Up @@ -147,7 +147,7 @@ def verify_id_token(self, token):

id_token = JWS().verify_compact(token, self.signing_keys)
log.debug('Token verified, %s' % id_token)
return json.loads(id_token)
return id_token

@staticmethod
def _get_issuer(token):
Expand Down
6 changes: 3 additions & 3 deletions oidc_auth/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.urls import path

from . import views
from oidc_auth import views

urlpatterns = [
path(r'^login/$', views.login_begin, name='oidc-login'),
path(r'^complete/$', views.login_complete, name='oidc-complete'),
path('login/', views.login_begin, name='oidc-login'),
path('complete/', views.login_complete, name='oidc-complete'),
]
7 changes: 4 additions & 3 deletions oidc_auth/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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.contrib.auth import REDIRECT_FIELD_NAME, login as django_login
from django.urls import reverse
from django.shortcuts import render, redirect
import requests

from . import errors
from . import utils
from .auth import OpenIDConnectBackend
from .utils import log
from .settings import oidc_settings
from .forms import OpenIDConnectForm
Expand Down Expand Up @@ -91,8 +92,8 @@ def login_complete(request, login_complete_view='oidc-complete',
log.debug('Token exchange done, proceeding authentication')
credentials = response.json()
credentials['provider'] = provider
user = authenticate(credentials=credentials)
django_login(request, user)
user = OpenIDConnectBackend().authenticate(credentials=credentials)
django_login(request, user, backend='oidc_auth.auth.OpenIDConnectBackend')

return redirect(nonce.redirect_url)

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Production requirements
Django>1.9
pyjwkest==0.6.2
requests==2.2.1
Django>=3.0
pyjwkest>=1.1.5
requests>=2.22.0
South==1.0.2

# Test requirements
Expand Down
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

setup(
name='django-oidc-auth',
version='2.0.0',
version='3.0.0',
description='OpenID Connect client for Django applications',
long_description='WIP',
author='Lucas S. Magalhães, Daniel Pimentel',
author_email='lucas.sampaio@intelie.com.br, danielpimentel@lccv.ufal.br',
author='Lucas S. Magalhães, Daniel Pimentel, João Paulo de Araújo, Romero Malaquias',
author_email='lucas.sampaio@intelie.com.br, danielpimentel@lccv.ufal.br, joaopna@lccv.ufal.br, '
'romero.malaquias@edge.ufal.br',
packages=find_packages(exclude=['*.tests']),
include_package_data=True,
install_requires=[
'Django>=4.2.8',
'pyjwkest==1.4.2',
'requests==2.31.0',
'Django>=3.0',
'South>=1.0.2',
'pyjwkest>=1.1.5',
'requests>=2.22.0',
],
zip_safe=True
)