Compare commits

...

7 Commits
v1.31 ... main

Author SHA1 Message Date
Frédéric Péters a3753c9bd2 misc: remove metadata cache as django-mellon has that now (#88579)
gitea/authentic2-auth-fedict/pipeline/head This commit looks good Details
2024-03-23 18:20:26 +01:00
Daniel Muyshond e257c5551d update beid/itsme images with improved better versions (#81401)
gitea/authentic2-auth-fedict/pipeline/head This commit looks good Details
2023-10-05 09:18:12 +02:00
Frédéric Péters 563762da8a ci: keep on using pylint 2 while pylint-django is not ready (#81905)
gitea/authentic2-auth-fedict/pipeline/head This commit looks good Details
2023-10-03 06:25:43 +02:00
Valentin Deniaud fe520f541f misc: update git-blame-ignore-revs to ignore quote changes (#79788)
gitea/authentic2-auth-fedict/pipeline/head This commit looks good Details
2023-08-16 10:12:20 +02:00
Valentin Deniaud cc93edc608 misc: apply double-quote-string-fixer (#79788) 2023-08-16 10:12:20 +02:00
Valentin Deniaud 8a0ccd8303 misc: add pre commit hook to force single quotes (#79788) 2023-08-16 10:12:20 +02:00
Frédéric Péters d78e9129ec ci: build deb package for bookworm (#78968)
gitea/authentic2-auth-fedict/pipeline/head This commit looks good Details
2023-06-23 17:02:50 +02:00
11 changed files with 26 additions and 55 deletions

View File

@ -2,3 +2,5 @@
7a234d5fe7ae6bee3ba1d0f688967e8e6cf209e3
# trivial: apply isort & pyupgrade
1abbbadd9469a3f2ff7eafb0ec6956c2b1c6763c
# misc: apply double-quote-string-fixer (#79788)
cc93edc60807663edcaa50f439364fbb6a449252

View File

@ -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:

4
Jenkinsfile vendored
View File

@ -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}"
}
}
}

View File

@ -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',

View File

@ -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

View File

@ -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

View File

@ -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',)

View File

@ -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

View File

@ -63,7 +63,8 @@ deps =
https://git.entrouvert.org/entrouvert/authentic/archive/main.tar.gz
Django<3.3
psycopg2-binary
pylint
pylint<3
astroid<3
pylint-django
commands =
./getlasso3.sh