Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Frédéric Péters | a3753c9bd2 | |
Daniel Muyshond | e257c5551d | |
Frédéric Péters | 563762da8a | |
Valentin Deniaud | fe520f541f | |
Valentin Deniaud | cc93edc608 | |
Valentin Deniaud | 8a0ccd8303 | |
Frédéric Péters | d78e9129ec |
|
@ -2,3 +2,5 @@
|
|||
7a234d5fe7ae6bee3ba1d0f688967e8e6cf209e3
|
||||
# trivial: apply isort & pyupgrade
|
||||
1abbbadd9469a3f2ff7eafb0ec6956c2b1c6763c
|
||||
# misc: apply double-quote-string-fixer (#79788)
|
||||
cc93edc60807663edcaa50f439364fbb6a449252
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: double-quote-string-fixer
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.3.0
|
||||
hooks:
|
||||
|
|
|
@ -35,9 +35,9 @@ pipeline {
|
|||
'''
|
||||
).trim()
|
||||
if (env.GIT_BRANCH == 'main' || env.GIT_BRANCH == 'origin/main') {
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d bullseye ${SHORT_JOB_NAME}"
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d bullseye,bookworm ${SHORT_JOB_NAME}"
|
||||
} else if (env.GIT_BRANCH.startsWith('hotfix/')) {
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d bullseye --branch ${env.GIT_BRANCH} --hotfix ${SHORT_JOB_NAME}"
|
||||
sh "sudo -H -u eobuilder /usr/local/bin/eobuilder -d bullseye,bookworm --branch ${env.GIT_BRANCH} --hotfix ${SHORT_JOB_NAME}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
setup.py
2
setup.py
|
@ -89,7 +89,7 @@ setup(
|
|||
description='Authentic2 Fedict plugin',
|
||||
author="Entr'ouvert",
|
||||
url='https://repos.entrouvert.org/authentic2-auth-fedict.git',
|
||||
author_email="info@entrouvert.com",
|
||||
author_email='info@entrouvert.com',
|
||||
packages=find_packages('src'),
|
||||
package_dir={
|
||||
'': 'src',
|
||||
|
|
|
@ -15,20 +15,14 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import lasso
|
||||
import mellon.utils as mellon_utils
|
||||
import requests
|
||||
from authentic2.a2_rbac.utils import get_default_ou
|
||||
from authentic2.models import Attribute
|
||||
from django.conf import settings
|
||||
from django.core.files.storage import default_storage
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from mellon.adapters import DefaultAdapter, app_settings
|
||||
from mellon.adapters import DefaultAdapter
|
||||
|
||||
try:
|
||||
import authentic2.utils.misc as a2_utils_misc
|
||||
|
@ -54,36 +48,6 @@ class AuthenticAdapter(DefaultAdapter):
|
|||
def auth_login(self, request, user):
|
||||
a2_utils_misc.login(request, user, 'fedict')
|
||||
|
||||
def get_identity_providers_setting(self):
|
||||
providers = app_settings.IDENTITY_PROVIDERS
|
||||
cache_path = default_storage.path('fedict-cache')
|
||||
if not os.path.exists(cache_path):
|
||||
os.makedirs(cache_path)
|
||||
for idp in providers:
|
||||
if 'METADATA_URL' in idp and 'METADATA' not in idp:
|
||||
url_hash = hashlib.sha1(force_bytes(idp['METADATA_URL'])).hexdigest()
|
||||
metadata_cache_filename = os.path.join(cache_path, url_hash)
|
||||
if os.path.exists(metadata_cache_filename):
|
||||
stat_info = os.stat(metadata_cache_filename)
|
||||
if stat_info.st_size and stat_info.st_mtime > (time.time() - 86400):
|
||||
with open(metadata_cache_filename) as fd:
|
||||
idp['METADATA'] = force_text(fd.read())
|
||||
continue
|
||||
verify_ssl_certificate = mellon_utils.get_setting(idp, 'VERIFY_SSL_CERTIFICATE')
|
||||
try:
|
||||
response = requests.get(idp['METADATA_URL'], verify=verify_ssl_certificate, timeout=30)
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.RequestException:
|
||||
if os.path.exists(metadata_cache_filename):
|
||||
# accept older cache in case of error
|
||||
with open(metadata_cache_filename) as fd:
|
||||
idp['METADATA'] = force_text(fd.read())
|
||||
continue
|
||||
idp['METADATA'] = response.text
|
||||
with open(metadata_cache_filename, 'wb') as fd:
|
||||
fd.write(response.content)
|
||||
return providers
|
||||
|
||||
def lookup_user(self, idp, saml_attributes):
|
||||
if 'email' in saml_attributes:
|
||||
# XXX: remove email from received attributes for now, this
|
||||
|
|
|
@ -137,7 +137,7 @@ class NumHouseField(forms.CharField):
|
|||
if not value:
|
||||
return
|
||||
try:
|
||||
if not re.match("^[1-9][0-9]*$", value):
|
||||
if not re.match('^[1-9][0-9]*$', value):
|
||||
raise ValueError()
|
||||
except ValueError:
|
||||
raise forms.ValidationError(getattr(settings, 'A2_NUMHOUSE_ERROR_MESSAGE', _('Invalid format')))
|
||||
|
@ -149,7 +149,7 @@ class NumPhoneField(forms.CharField):
|
|||
if not value:
|
||||
return
|
||||
try:
|
||||
if not re.match("^(0|\\+|00)(\\d{8,})", value):
|
||||
if not re.match('^(0|\\+|00)(\\d{8,})', value):
|
||||
raise ValueError()
|
||||
except ValueError:
|
||||
raise forms.ValidationError(getattr(settings, 'A2_NUMPHONE_ERROR_MESSAGE', _('Invalid format')))
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 35 KiB |
Binary file not shown.
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 27 KiB |
|
@ -19,21 +19,21 @@ if 'postgres' in DATABASES['default']['ENGINE']:
|
|||
LANGUAGE_CODE = 'en'
|
||||
A2_AUTH_SAML_ENABLE = False
|
||||
|
||||
MELLON_ADAPTER = ["authentic2_auth_fedict.adapters.AuthenticAdapter"]
|
||||
MELLON_LOGIN_URL = "fedict-login"
|
||||
MELLON_PUBLIC_KEYS = ["./tests/saml.crt"]
|
||||
MELLON_PRIVATE_KEY = "./tests/saml.key"
|
||||
MELLON_ADAPTER = ['authentic2_auth_fedict.adapters.AuthenticAdapter']
|
||||
MELLON_LOGIN_URL = 'fedict-login'
|
||||
MELLON_PUBLIC_KEYS = ['./tests/saml.crt']
|
||||
MELLON_PRIVATE_KEY = './tests/saml.key'
|
||||
MELLON_IDENTITY_PROVIDERS = [
|
||||
{
|
||||
"METADATA": open("./tests/metadata.xml").read(),
|
||||
"ENTITY_ID": "https://idp.com/",
|
||||
"SLUG": "idp",
|
||||
'METADATA': open('./tests/metadata.xml').read(),
|
||||
'ENTITY_ID': 'https://idp.com/',
|
||||
'SLUG': 'idp',
|
||||
},
|
||||
]
|
||||
|
||||
MELLON_ATTRIBUTE_MAPPING = {
|
||||
"last_name": "{attributes[surname][0]}",
|
||||
"first_name": "{attri,butes[givenName][0]}",
|
||||
'last_name': '{attributes[surname][0]}',
|
||||
'first_name': '{attri,butes[givenName][0]}',
|
||||
}
|
||||
|
||||
INSTALLED_APPS += ('authentic2_auth_fedict',)
|
||||
|
|
|
@ -194,11 +194,11 @@ def test_eid_unlink(app, settings, issuer, user, authenticator):
|
|||
)
|
||||
|
||||
response = login(app, user, path='/accounts/', password=user.username)
|
||||
assert "Unlink my account" in response.text
|
||||
assert 'Unlink my account' in response.text
|
||||
app.get('/accounts/fedict/unlink/').follow()
|
||||
|
||||
response = app.get('/accounts/')
|
||||
assert "Link my account to my eID card" in response.text
|
||||
assert 'Link my account to my eID card' in response.text
|
||||
|
||||
|
||||
def test_provision_new_attributes_verified(app, settings, issuer, user):
|
||||
|
@ -347,7 +347,7 @@ def test_fedict_authenticator_data_migration(settings):
|
|||
FedictAuthenticator = old_apps.get_model(app, 'FedictAuthenticator')
|
||||
|
||||
settings.AUTH_FRONTENDS_KWARGS = {
|
||||
"fedict": {"priority": 3, "show_condition": "'backoffice' not in login_hint"}
|
||||
'fedict': {'priority': 3, 'show_condition': "'backoffice' not in login_hint"}
|
||||
}
|
||||
settings.A2_AUTH_FEDICT_ENABLE = True
|
||||
|
||||
|
|
Loading…
Reference in New Issue