Skip to content

Commit e8c2d9c

Browse files
committed
no message
1 parent 46f9b83 commit e8c2d9c

22 files changed

+298
-441
lines changed

.github/workflows/python-package.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.6, 3.7, 3.8]
19+
django-version: ["2.2", "3.0", "master"]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v1
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies and testing utilities
28+
run: |
29+
sudo apt-get update && sudo apt-get install xmlsec1
30+
python -m pip install --upgrade pip tox rstcheck setuptools codecov
31+
- name: Readme check
32+
if: ${{ matrix.python-version }} == 3.8 && ${{ matrix.django-version }} == "3.0"
33+
run: rstcheck README.rst
34+
- name: Tests
35+
run: tox -e py${{ matrix.python-version }}-django${{ matrix.django-version }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@
44
*.sqp
55
build/
66
dist/
7+
_build/
8+
.pytest_cache
9+
.env
10+
env/
11+
venv
12+
tags
13+
.idea/
14+
.vscode/

.hgignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

README.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,24 @@ setting::
315315
SAML_CONFIG_LOADER = 'python.path.to.your.callable'
316316

317317

318+
Custom error handler
319+
....................
320+
321+
When an error occurs during the authentication flow, djangosaml2 will render
322+
a simple error page with an error message and status code. You can customize
323+
this behaviour by specifying the path to your own error handler in the settings:
324+
325+
SAML_ACS_FAILURE_RESPONSE_FUNCTION = 'python.path.to.your.view'
326+
327+
This should be a view which takes a request, optional exception which occured
328+
and status code, and returns a response to serve the user. E.g. The default
329+
implementation looks like this::
330+
331+
def template_failure(request, exception=None, **kwargs):
332+
""" Renders a simple template with an error message. """
333+
return render(request, 'djangosaml2/login_error.html', {'exception': exception}, status=kwargs.get('status', 403))
334+
335+
318336
User attributes
319337
---------------
320338

djangosaml2/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default_app_config = 'djangosaml2.apps.DjangoSaml2Config'

djangosaml2/acs_failures.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,10 @@
33
# This module defines a set of useful ACS failure functions that are used to
44
# produce an output suitable for end user in case of SAML failure.
55
#
6-
from __future__ import unicode_literals
76

8-
from django.core.exceptions import PermissionDenied
97
from django.shortcuts import render
108

119

12-
def template_failure(request, status=403, **kwargs):
13-
""" Renders a SAML-specific template with general authentication error description. """
14-
return render(request, 'djangosaml2/login_error.html', status=status)
15-
16-
17-
def exception_failure(request, exc_class=PermissionDenied, **kwargs):
18-
""" Rather than using a custom SAML specific template that is rendered on failure,
19-
this makes use of a standard exception handling machinery present in Django
20-
and thus ends up rendering a project-wide error page for Permission Denied exceptions.
21-
"""
22-
raise exc_class
10+
def template_failure(request, exception=None, **kwargs):
11+
""" Renders a simple template with an error message. """
12+
return render(request, 'djangosaml2/login_error.html', {'exception': exception}, status=kwargs.get('status', 403))

djangosaml2/apps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.apps import AppConfig
2+
3+
4+
class DjangoSaml2Config(AppConfig):
5+
name = 'djangosaml2'
6+
verbose_name = "DjangoSAML2"
7+
8+
def ready(self):
9+
from . import signals # noqa

0 commit comments

Comments
 (0)