diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..c904932
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,8 @@
+[run]
+omit =
+ tests/*
+ example_project/*
+ .tox/*
+ setup.py
+ *.egg/*
+ */__main__.py
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..9e6b1fb
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,11 @@
+language: python
+python:
+ - "2.7"
+env:
+ - DJANGO=1.7.8
+ - DJANGO=1.8.2
+install:
+ - pip install -q Django==$DJANGO --use-mirrors
+ - pip install pyjwt==1.1.0 --use-mirrors
+script:
+ - PYTHONPATH=$PYTHONPATH:$PWD django-admin.py test oidc_provider --settings=oidc_provider.tests.test_settings
\ No newline at end of file
diff --git a/README.rst b/README.rst
index cc1baa4..7e0467c 100644
--- a/README.rst
+++ b/README.rst
@@ -1,6 +1,10 @@
Django OIDC Provider
####################
+.. image:: https://api.travis-ci.org/django-py/django-openid-provider.png?branch=master
+ :alt: Build Status
+ :target: http://travis-ci.org/django-py/django-openid-provider
+
Django OIDC Provider can help you providing out of the box all the endpoints, data and logic needed to add OpenID Connect capabilities to your Django projects.
diff --git a/oidc_provider/lib/endpoints/authorize.py b/oidc_provider/lib/endpoints/authorize.py
index 667de5a..2ea3665 100644
--- a/oidc_provider/lib/endpoints/authorize.py
+++ b/oidc_provider/lib/endpoints/authorize.py
@@ -1,13 +1,11 @@
-from datetime import timedelta
-import uuid
-
-from django.utils import timezone
+import logging
from oidc_provider.lib.errors import *
from oidc_provider.lib.utils.params import *
from oidc_provider.lib.utils.token import *
from oidc_provider.models import *
-from oidc_provider import settings
+
+logger = logging.getLogger(__name__)
class AuthorizeEndpoint(object):
@@ -134,6 +132,10 @@ class AuthorizeEndpoint(object):
if self.params.response_type == 'id_token token':
uri += '&access_token={0}'.format(token.access_token)
except:
+ logger.error('Authorization server error, grant_type: %s' %self.grant_type, extra={
+ 'redirect_uri': self.redirect_uri,
+ 'state': self.params.state
+ })
raise AuthorizeError(
self.params.redirect_uri,
'server_error',
diff --git a/oidc_provider/lib/endpoints/token.py b/oidc_provider/lib/endpoints/token.py
index 9c5f9dd..ef05ec4 100644
--- a/oidc_provider/lib/endpoints/token.py
+++ b/oidc_provider/lib/endpoints/token.py
@@ -1,3 +1,4 @@
+import logging
import urllib
from django.http import JsonResponse
@@ -8,6 +9,7 @@ from oidc_provider.lib.utils.token import *
from oidc_provider.models import *
from oidc_provider import settings
+logger = logging.getLogger(__name__)
class TokenEndpoint(object):
@@ -16,6 +18,11 @@ class TokenEndpoint(object):
self.params = Params()
self._extract_params()
+ logger.debug('Request %s', self.request)
+ logger.debug('TokenEndPoint request.POST --> : %s', self.request.POST)
+ logger.debug('TokenEndpoint request.GET --> : %s', self.request.GET)
+ logger.debug('TokenEndPoint extract_params --> : %s', self.params.__dict__)
+
def _extract_params(self):
query_dict = self.request.POST
@@ -29,21 +36,25 @@ class TokenEndpoint(object):
def validate_params(self):
if not (self.params.grant_type == 'authorization_code'):
+ logger.error('Unsupported grant type: --> : %s', self.params.grant_type)
raise TokenError('unsupported_grant_type')
try:
self.client = Client.objects.get(client_id=self.params.client_id)
if not (self.client.client_secret == self.params.client_secret):
+ logger.error('Invalid client, client secret -->: %s', self.params.client_secret)
raise TokenError('invalid_client')
if not (self.params.redirect_uri in self.client.redirect_uris):
+ logger.error('Invalid client, redirect_uri --> : %s', self.params.redirect_uri)
raise TokenError('invalid_client')
self.code = Code.objects.get(code=self.params.code)
if not (self.code.client == self.client) \
or self.code.has_expired():
+ logger.error('Invalid grant, code client --> %s', self.code.client)
raise TokenError('invalid_grant')
except Client.DoesNotExist:
@@ -77,7 +88,7 @@ class TokenEndpoint(object):
'expires_in': settings.get('OIDC_TOKEN_EXPIRE'),
'id_token': id_token,
}
-
+ logger.debug('Response dictionary --> : %s', dic)
return dic
@classmethod
@@ -89,4 +100,6 @@ class TokenEndpoint(object):
response['Cache-Control'] = 'no-store'
response['Pragma'] = 'no-cache'
+ logger.debug('JSON Response --> : %s', response.__dict__)
+
return response
diff --git a/oidc_provider/tests/templates/accounts/login.html b/oidc_provider/tests/templates/accounts/login.html
new file mode 100644
index 0000000..6c24774
--- /dev/null
+++ b/oidc_provider/tests/templates/accounts/login.html
@@ -0,0 +1,24 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/oidc_provider/tests/templates/accounts/logout.html b/oidc_provider/tests/templates/accounts/logout.html
new file mode 100644
index 0000000..25aa0f8
--- /dev/null
+++ b/oidc_provider/tests/templates/accounts/logout.html
@@ -0,0 +1,12 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+
+
+
Bye!
+
Thanks for spending some quality time with the web site today.
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/oidc_provider/tests/templates/base.html b/oidc_provider/tests/templates/base.html
new file mode 100644
index 0000000..6d38b8b
--- /dev/null
+++ b/oidc_provider/tests/templates/base.html
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+ OpenID Provider
+
+
+
+
+
+
+
+
+
+
+
+
+
+
django-oidc-provider
+
+
+ {% block content %}{% endblock %}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/oidc_provider/tests/templates/home.html b/oidc_provider/tests/templates/home.html
new file mode 100644
index 0000000..c79d818
--- /dev/null
+++ b/oidc_provider/tests/templates/home.html
@@ -0,0 +1,11 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+
+
Welcome!
+
Django OIDC Provider can help you providing out of the box all the endpoints, data and logic needed to add OpenID Connect capabilities to your Django projects.