Skip to content

Commit

Permalink
Refactor ICMS to use govuk_onelogin_django.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattHolmes123 committed Jan 8, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 88ea813 commit 0f22736
Showing 31 changed files with 25 additions and 831 deletions.
6 changes: 4 additions & 2 deletions config/settings.py
Original file line number Diff line number Diff line change
@@ -20,9 +20,9 @@
from dbt_copilot_python.utility import is_copilot
from django.forms import Field
from django_log_formatter_asim import ASIMFormatter
from govuk_onelogin_django import types as one_login_types

from config.env import env
from web.one_login import types as one_login_types
from web.utils.sentry import init_sentry

# Build paths inside the project like this: BASE_DIR / "subdir".
@@ -62,6 +62,8 @@
"django.contrib.sites",
# STAFF-SSO client app
"authbroker_client",
# GOV.OK One Login Client app
"govuk_onelogin_django",
]

MIDDLEWARE = [
@@ -464,7 +466,7 @@

# Used to change one login auth level (remove 2FA in non-production)
if env.gov_uk_one_login_authentication_level_override:
GOV_UK_ONE_LOGIN_AUTHENTICATION_LEVEL = env.gov_uk_one_login_authentication_level_override # type: ignore[assignment]
GOV_UK_ONE_LOGIN_AUTHENTICATION_LEVEL = env.gov_uk_one_login_authentication_level_override

# Site URL management
CASEWORKER_SITE_URL = env.caseworker_site_url
1 change: 1 addition & 0 deletions pii-ner-exclude.txt
Original file line number Diff line number Diff line change
@@ -5231,3 +5231,4 @@ v3.19.1
José João Caminhão Cachaçaria Pêssegó
Jose Joao Caminhao
Cachacaria Pessego
GOV.OK One Login Client
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -76,6 +76,8 @@ module = [
"endesive.*",
"PIL.*",
"reportlab.*",
# TODO: Add types package.
"govuk_onelogin_django.*"
]
ignore_missing_imports = true

4 changes: 2 additions & 2 deletions web/auth/backends.py
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@
from authbroker_client.backends import AuthbrokerBackend
from django.contrib.auth.backends import ModelBackend
from django.http import HttpRequest
from govuk_onelogin_django.backends import OneLoginBackend
from govuk_onelogin_django.types import UserInfo as OneLoginUserInfo
from guardian.backends import check_support
from guardian.conf import settings as guardian_settings
from guardian.ctypes import get_content_type
from guardian.exceptions import WrongAppError

from web.mail.emails import send_new_user_welcome_email
from web.models import User
from web.one_login.backends import OneLoginBackend
from web.one_login.types import UserInfo as OneLoginUserInfo
from web.sites import is_caseworker_site

from .types import STAFF_SSO_ID, StaffSSOProfile, StaffSSOUserCreateData
2 changes: 1 addition & 1 deletion web/auth/utils.py
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@
from django.db import transaction
from django.http import HttpRequest
from django.utils import timezone
from govuk_onelogin_django.types import UserCreateData as OneLoginUserCreateData

from web.models import Email as UserEmail
from web.models import User
from web.one_login.types import UserCreateData as OneLoginUserCreateData
from web.sites import is_exporter_site, is_importer_site

from .types import StaffSSOUserCreateData
2 changes: 1 addition & 1 deletion web/domains/user/forms.py
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@
from django.forms.widgets import EmailInput, Select, Textarea
from django.utils.translation import gettext_lazy as _
from django_filters import CharFilter, ChoiceFilter, FilterSet
from govuk_onelogin_django.constants import ONE_LOGIN_UNSET_NAME

from web.forms.fields import JqueryDateField, PhoneNumberField
from web.forms.widgets import ICMSModelSelect2Widget, YesNoRadioSelectInline
from web.models import Email, Exporter, Importer, PhoneNumber, User
from web.one_login.constants import ONE_LOGIN_UNSET_NAME


class OneLoginNewUserUpdateForm(forms.ModelForm):
3 changes: 1 addition & 2 deletions web/domains/user/models.py
Original file line number Diff line number Diff line change
@@ -4,11 +4,10 @@
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.urls import reverse
from govuk_onelogin_django.constants import ONE_LOGIN_UNSET_NAME
from guardian.core import ObjectPermissionChecker
from guardian.mixins import GuardianUserMixin

from web.one_login.constants import ONE_LOGIN_UNSET_NAME


class User(GuardianUserMixin, AbstractUser):
def __init__(self, *args, **kwargs):
3 changes: 1 addition & 2 deletions web/mail/types.py
Original file line number Diff line number Diff line change
@@ -2,8 +2,7 @@
from typing import Any, TypedDict

from django.conf import settings

from web.one_login.constants import ONE_LOGIN_UNSET_NAME
from govuk_onelogin_django.constants import ONE_LOGIN_UNSET_NAME

from .constants import DEFAULT_APPLICANT_GREETING

2 changes: 1 addition & 1 deletion web/middleware/one_login.py
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect
from django.urls import resolve, reverse
from govuk_onelogin_django.constants import ONE_LOGIN_UNSET_NAME

from web.models import User
from web.one_login.constants import ONE_LOGIN_UNSET_NAME


class UserFullyRegisteredMiddleware:
Empty file removed web/one_login/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions web/one_login/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions web/one_login/apps.py

This file was deleted.

73 changes: 0 additions & 73 deletions web/one_login/backends.py

This file was deleted.

3 changes: 0 additions & 3 deletions web/one_login/constants.py

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion web/one_login/models.py

This file was deleted.

Empty file removed web/one_login/tests/__init__.py
Empty file.
115 changes: 0 additions & 115 deletions web/one_login/tests/test_backends.py

This file was deleted.

25 changes: 0 additions & 25 deletions web/one_login/tests/test_utils.py

This file was deleted.

Loading

0 comments on commit 0f22736

Please sign in to comment.