-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,500 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# .coveragerc to control coverage.py | ||
[coverage:run] | ||
branch = True | ||
source = src/djangosaml2_spid/ | ||
omit = | ||
*manage.py | ||
*/distutils/* | ||
tests/* | ||
*/apps/* | ||
*/migrations/* | ||
*/site-packages/* | ||
*/tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "spid-compliant-certificates"] | ||
path = spid-compliant-certificates | ||
url = https://github.com/italia/spid-compliant-certificates.git | ||
[submodule "spid-saml-check"] | ||
path = spid-saml-check | ||
url = ./spid-saml-check | ||
url = https://github.com/italia/spid-saml-check.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Djangosaml2 SPID | ||
================ | ||
SPID Django | ||
|
||
![CI build](https://github.com/italia/spid-django/workflows/spid-django/badge.svg) | ||
![Python version](https://img.shields.io/badge/license-Apache%202-blue.svg) | ||
|
@@ -15,7 +14,7 @@ Introduction | |
This is a Django application that provides a SAML2 Service Provider | ||
for a Single Sign On with SPID, the Italian Digital Identity System. | ||
|
||
This project comes with a demo on a Spid button template with both *spid-testenv2* | ||
This project comes with a demo on a Spid button template with both *spid-testenv2* | ||
and *spid-saml-check* IDP preconfigured. See running the Demo project paragaph for details. | ||
|
||
The technical documentation on SPID and SAML is available at [Docs Italia](https://docs.italia.it/italia/spid/spid-regole-tecniche/it/34.1.1/index.html) | ||
|
@@ -26,7 +25,7 @@ The technical documentation on SPID and SAML is available at [Docs Italia](https | |
Dependencies | ||
------------ | ||
|
||
These libraries are required on your operating system environment | ||
These libraries are required on your operating system environment | ||
in order to compile external modules of some dependencies: | ||
|
||
- xmlsec | ||
|
@@ -39,7 +38,7 @@ in order to compile external modules of some dependencies: | |
Running the Demo project | ||
------------------------ | ||
|
||
The demo project is configured within `example/` subdirectory. | ||
The demo project is configured within `example/` subdirectory. | ||
This project uses **spid-saml-check** and **spid-testenv2** as | ||
additional IDPs configured in a demo SPID button. | ||
|
||
|
@@ -51,28 +50,28 @@ source env/bin/activate | |
pip install -r ../requirements.txt | ||
```` | ||
|
||
Your example saml2 configuration is in `spid_config/spid_settings.py`. | ||
Your example saml2 configuration is in `spid_config/spid_settings.py`. | ||
See djangosaml2 or pysaml2 official docs for clarifications. | ||
|
||
To run the demo project: | ||
- create the database `./manage.py migrate` | ||
- run `./manage.py runserver 0.0.0.0:8000` | ||
|
||
or execute the run.sh script with these environment settings: | ||
|
||
```` | ||
SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE=True SPID_TESTENV2_REMOTE_METADATA_ACTIVE=True bash run.sh | ||
```` | ||
|
||
If you choosed to use *spid-testenv2*, fefore starting it, you just have to save the | ||
If you choosed to use *spid-testenv2*, fefore starting it, you just have to save the | ||
current demo metadata in *spid-testenv2* configuration, this way: | ||
|
||
```` | ||
# cd into spid-testenv2/ base dir ... | ||
wget http://localhost:8000/spid/metadata -O conf/sp_metadata.xml | ||
```` | ||
|
||
Finally, start spid-testenv2 and spid-saml-check (docker is suggested) and | ||
Finally, start spid-testenv2 and spid-saml-check (docker is suggested) and | ||
then open 'http://localhost:8000' in your browser. | ||
|
||
|
||
|
@@ -90,14 +89,14 @@ then use `docker-compose --env-file docker-compose.env up` (the process takes so | |
under `./example/configs/` to match the new configurations, changing only `./docker-compose.env` will not suffice. | ||
|
||
|
||
Setup for an existing project | ||
Setup for an existing project | ||
----------------------------- | ||
|
||
djangosaml2_spid uses a pySAML2 fork. | ||
|
||
* `pip install git+https://github.com/peppelinux/[email protected]` | ||
* `pip install git+https://github.com/italia/spid-django` | ||
* Copy the `example/spid_config/` to your project base dir | ||
* Copy the `example/spid_config/` to your project base dir | ||
* Import SAML2 entity configuration in your project settings file: `from spid_config.spid_settings import *` | ||
* Add in `settings.INSTALLED_APPS` the following | ||
``` | ||
|
@@ -135,15 +134,32 @@ SAML_ATTRIBUTE_MAPPING = { | |
} | ||
```` | ||
|
||
Download identity providers metadata | ||
----------------------------------- | ||
|
||
To update the list of entity providers use the custom django command `update_idps`. | ||
In the example project you can do it as follows: | ||
|
||
```` | ||
cd example/ | ||
python ./manage.py update_idps | ||
```` | ||
|
||
Running tests (only for developers) | ||
----------------------------------- | ||
|
||
Tests are integrated into the demo project and are intended for use | ||
Tests are integrated into the demo project and are intended for use | ||
only by developers. | ||
|
||
To test the application: | ||
```` | ||
pip install -r requirements-dev.txt | ||
python runtests.py | ||
```` | ||
|
||
For running tests using the settings of the Demo project: | ||
```` | ||
pip install requirements-dev.txt | ||
pip install -r requirements-dev.txt | ||
cd example/ | ||
coverage erase | ||
coverage run ./manage.py test djangosaml2_spid.tests | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ | |
|
||
'djangosaml2', | ||
'djangosaml2_spid', | ||
'spid_config' | ||
'spid_config', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,11 @@ | ||
"""example URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/3.1/topics/http/urls/ | ||
Examples: | ||
Function views | ||
1. Add an import: from my_app import views | ||
2. Add a URL to urlpatterns: path('', views.home, name='home') | ||
Class-based views | ||
1. Add an import: from other_app.views import Home | ||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | ||
Including another URLconf | ||
1. Import the include() function: from django.urls import include, path | ||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | ||
""" | ||
from django.conf import settings | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
from django.views.generic.base import RedirectView | ||
import djangosaml2_spid.urls | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('', include((djangosaml2_spid.urls, 'djangosaml2_spid',))), | ||
path('', RedirectView.as_view(url=settings.SPID_BASE_URL), name='example-index') | ||
] | ||
|
||
if 'djangosaml2_spid' in settings.INSTALLED_APPS: | ||
import djangosaml2_spid.urls | ||
|
||
urlpatterns.extend([ | ||
path('', include((djangosaml2_spid.urls, 'djangosaml2_spid',))) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ def main(): | |
|
||
|
||
if __name__ == '__main__': | ||
__spec__ = None | ||
main() |
Oops, something went wrong.