Skip to content

Commit

Permalink
v1.0.0 (#74)
Browse files Browse the repository at this point in the history
* chore: removed spid-testenv2

* v1.0.0

- chore: removed spid-testenv2
- feat: added spid-saml-check demo idp
- feat: spid buttons templates (@brunato )

Co-authored-by: Davide Brunato <brunato@sissa.it>
  • Loading branch information
Giuseppe De Marco and brunato authored Jul 4, 2021
1 parent f5254c4 commit 9aff08b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 99 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To run the demo project:
or execute the run.sh script with these environment settings to enable tests idps:

````
SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE=True SPID_TESTENV2_REMOTE_METADATA_ACTIVE=True bash run.sh
SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE=True SPID_SAML_CHECK_DEMO_METADATA_ACTIVE=True bash run.sh
````

If you choosed to use *spid-testenv2*, before starting it, you just have to save the
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ SPID_BASE_SCHEMA_HOST_PORT=http://hostnet:8000
SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE=True
SPID_SAML_CHECK_METADATA_URL=http://hostnet:8080/metadata.xml

SPID_TESTENV2_REMOTE_METADATA_ACTIVE=True
SPID_TESTENV2_METADATA_URL=http://hostnet:8088/metadata
SPID_SAML_CHECK_DEMO_REMOTE_METADATA_ACTIVE=True
SPID_SAML_CHECK_DEMO_METADATA_URL=http://hostnet:8080/idp/metadata.xml
45 changes: 0 additions & 45 deletions example/configs/spid-testenv2/config.yaml

This file was deleted.

32 changes: 0 additions & 32 deletions example/configs/spid-testenv2/users.json

This file was deleted.

4 changes: 2 additions & 2 deletions example/spid_config/spid_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE = os.environ.get('SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE', 'False') == 'True'
SPID_SAML_CHECK_METADATA_URL = os.environ.get('SPID_SAML_CHECK_METADATA_URL', 'http://localhost:8080/metadata.xml')

SPID_TESTENV2_REMOTE_METADATA_ACTIVE = os.environ.get('SPID_TESTENV2_REMOTE_METADATA_ACTIVE', 'False') == 'True'
SPID_TESTENV2_METADATA_URL = os.environ.get('SPID_TESTENV2_METADATA_URL', 'http://localhost:8088/metadata')
SPID_SAML_CHECK_DEMO_REMOTE_METADATA_ACTIVE = os.environ.get('SPID_SAML_CHECK_DEMO_REMOTE_METADATA_ACTIVE', 'False') == 'True'
SPID_SAML_CHECK_DEMO_METADATA_URL = os.environ.get('SPID_SAML_CHECK_DEMO_METADATA_URL', 'http://localhost:8080/demo/metadata.xml')

# Avviso 29v3
SPID_PREFIXES = dict(
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="djangosaml2-spid",
version='0.9.1',
version='1.0.0',
description="Djangosaml2 SPID Service Provider",
long_description=README,
long_description_content_type='text/markdown',
Expand All @@ -23,7 +23,7 @@
package_dir={'': 'src'},
include_package_data=True,
classifiers=[
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
Expand Down
21 changes: 11 additions & 10 deletions src/djangosaml2_spid/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@
os.environ.get('SPID_SAML_CHECK_METADATA_URL', 'http://localhost:8080/metadata.xml')
)

settings.SPID_TESTENV2_REMOTE_METADATA_ACTIVE = getattr(
settings.SPID_SAML_CHECK_DEMO_REMOTE_METADATA_ACTIVE = getattr(
settings,
'SPID_TESTENV2_REMOTE_METADATA_ACTIVE',
os.environ.get('SPID_TESTENV2_REMOTE_METADATA_ACTIVE', 'False') == 'True'
'SPID_SAML_CHECK_DEMO_REMOTE_METADATA_ACTIVE',
os.environ.get('SPID_SAML_CHECK_DEMO_REMOTE_METADATA_ACTIVE', 'False') == 'True'
)

settings.SPID_TESTENV2_METADATA_URL = getattr(
settings.SPID_SAML_CHECK_DEMO_METADATA_URL = getattr(
settings,
'SPID_TESTENV2_METADATA_URL',
os.environ.get('SPID_TESTENV2_METADATA_URL', 'http://localhost:8088/metadata')
'SPID_SAML_CHECK_DEMO_METADATA_URL',
os.environ.get('SPID_SAML_CHECK_DEMO_METADATA_URL', 'http://localhost:8080/demo/metadata.xml')
)

# Avviso 29v3
Expand Down Expand Up @@ -183,6 +183,7 @@
'dateOfBirth': ('birth_date',),
})


# Attributes that this project need to identify a user
settings.SPID_REQUIRED_ATTRIBUTES = getattr(settings, 'SPID_REQUIRED_ATTRIBUTES', [
'spidCode',
Expand All @@ -208,7 +209,6 @@
'expirationDate',
])


def config_settings_loader(request: Optional[HttpRequest] = None) -> SPConfig:
conf = SPConfig()
if request is None or not request.path.lstrip('/').startswith(settings.SPID_URLS_PREFIX):
Expand Down Expand Up @@ -246,9 +246,10 @@ def config_settings_loader(request: Optional[HttpRequest] = None) -> SPConfig:
'force_authn': False, # SPID
'name_id_format_allow_create': False,

# Required and optional attributes
# attributes that this project need to identify a user
'required_attributes': settings.SPID_REQUIRED_ATTRIBUTES,
'optional_attributes': settings.SPID_OPTIONAL_ATTRIBUTES,

'requested_attribute_name_format': saml2.saml.NAME_FORMAT_BASIC,
'name_format': saml2.saml.NAME_FORMAT_BASIC,

Expand Down Expand Up @@ -312,9 +313,9 @@ def config_settings_loader(request: Optional[HttpRequest] = None) -> SPConfig:
{'url': settings.SPID_SAML_CHECK_METADATA_URL}
)

if settings.SPID_TESTENV2_REMOTE_METADATA_ACTIVE:
if settings.SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE:
saml_config['metadata']['remote'].append(
{'url': settings.SPID_TESTENV2_METADATA_URL}
{'url': settings.SPID_SAML_CHECK_REMOTE_METADATA_ACTIVE}
)

logger.debug(f'SAML_CONFIG: {saml_config}')
Expand Down
4 changes: 2 additions & 2 deletions src/djangosaml2_spid/templates/spid_button.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<li class="spid-idp-button-link" id="spid_saml_check" data-idp="spid_saml_check" data-entityid="{% spid_saml_check_url %}">
<a href="#"><span class="spid-sr-only">SPID-saml-check</span><img src="" onerror="this.src=''; this.onerror=null;" alt="Spid saml check"></a>
</li>
<li class="spid-idp-button-link" id="spid_testenv2" data-idp="spid_testenv2" data-entityid="{% spid_testenv2_url %}">
<a href="#"><span class="spid-sr-only">SPID-testenv2</span><img src="" onerror="this.src=''; this.onerror=null;" alt="Spid test env2"></a>
<li class="spid-idp-button-link" id="spid_saml_check_demo_idp" data-idp="spid_saml_check_demo_idp" data-entityid="{% spid_saml_check_demo_url %}">
<a href="#"><span class="spid-sr-only">SPID-saml-check Demo IdP</span><img src="" onerror="this.src=''; this.onerror=null;" alt="Spid saml check demo IdP"></a>
</li>
<li class="spid-idp-button-link" id="spid_validator" data-idp="spid_validator" data-entityid="https://validator.spid.gov.it">
<a href="#"><span class="spid-sr-only">SPID-Validator</span><img src="" onerror="this.src=''; this.onerror=null;" alt="Spid Validator"></a>
Expand Down
6 changes: 3 additions & 3 deletions src/djangosaml2_spid/templatetags/spid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def spid_saml_check_url():


@register.simple_tag()
def spid_testenv2_url():
url = urlparse(settings.SPID_TESTENV2_METADATA_URL)
return f'{url.scheme}://{url.netloc}'
def spid_saml_check_demo_url():
url = urlparse(settings.SPID_SAML_CHECK_DEMO_METADATA_URL)
return f'{url.scheme}://{url.netloc}{url.path.rpartition("/")[0]}'


@register.filter()
Expand Down

0 comments on commit 9aff08b

Please sign in to comment.