From f4f90e06287804dc56b41456d8fb4777cfbd9941 Mon Sep 17 00:00:00 2001 From: Lasse Yledahl Date: Wed, 9 Oct 2024 14:23:52 +0000 Subject: [PATCH] use new StrEnum The old way has a different string representation in python 3.11 See https://tsak.dev/posts/python-enum/ --- src/eduid/common/config/base.py | 6 +++--- src/eduid/common/models/amapi_user.py | 6 +++--- src/eduid/common/models/bearer_token.py | 4 ++-- src/eduid/common/models/gnap_models.py | 6 +++--- src/eduid/common/models/jose_models.py | 14 +++++++------- src/eduid/common/models/saml2.py | 4 ++-- src/eduid/common/models/scim_base.py | 10 +++++----- src/eduid/common/rpc/msg_relay.py | 6 +++--- src/eduid/userdb/authninfo.py | 4 ++-- src/eduid/userdb/credentials/base.py | 4 ++-- src/eduid/userdb/credentials/external.py | 4 ++-- src/eduid/userdb/group_management/state.py | 4 ++-- src/eduid/userdb/identity.py | 12 ++++++------ src/eduid/userdb/idp/user.py | 4 ++-- src/eduid/userdb/meta.py | 4 ++-- src/eduid/userdb/user.py | 4 ++-- src/eduid/vccs/server/db.py | 10 +++++----- src/eduid/vccs/server/endpoints/misc.py | 4 ++-- src/eduid/webapp/common/api/errors.py | 4 ++-- src/eduid/webapp/common/authn/acs_enums.py | 8 ++++---- src/eduid/webapp/common/session/namespaces.py | 6 +++--- src/eduid/webapp/freja_eid/callback_enums.py | 4 ++-- src/eduid/webapp/idp/assurance_data.py | 8 ++++---- src/eduid/webapp/idp/helpers.py | 4 ++-- src/eduid/webapp/idp/other_device/data.py | 4 ++-- src/eduid/webapp/idp/util.py | 4 ++-- src/eduid/webapp/security/webauthn_proofing.py | 4 ++-- src/eduid/webapp/signup/helpers.py | 4 ++-- src/eduid/webapp/svipe_id/callback_enums.py | 4 ++-- src/eduid/workers/amapi/config.py | 4 ++-- 30 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/eduid/common/config/base.py b/src/eduid/common/config/base.py index 3998ee761..5d36abbec 100644 --- a/src/eduid/common/config/base.py +++ b/src/eduid/common/config/base.py @@ -6,7 +6,7 @@ from collections.abc import Iterable, Mapping, Sequence from datetime import timedelta -from enum import Enum, unique +from enum import Enum, StrEnum, unique from pathlib import Path from re import Pattern from typing import IO, Annotated, Any, TypeVar @@ -69,7 +69,7 @@ class CookieConfig(BaseModel): TRootConfigSubclass = TypeVar("TRootConfigSubclass", bound="RootConfig") -class EduidEnvironment(str, Enum): +class EduidEnvironment(StrEnum): dev = "dev" staging = "staging" production = "production" @@ -89,7 +89,7 @@ class RootConfig(BaseModel): TEduIDBaseAppConfigSubclass = TypeVar("TEduIDBaseAppConfigSubclass", bound="EduIDBaseAppConfig") -class LoggingFilters(str, Enum): +class LoggingFilters(StrEnum): """Identifiers to coherently map elements in LocalContext.filters to filter classes in logging dictConfig.""" DEBUG_TRUE: str = "require_debug_true" diff --git a/src/eduid/common/models/amapi_user.py b/src/eduid/common/models/amapi_user.py index 176305e32..98f50d6ef 100644 --- a/src/eduid/common/models/amapi_user.py +++ b/src/eduid/common/models/amapi_user.py @@ -1,5 +1,5 @@ from datetime import datetime -from enum import Enum +from enum import StrEnum from pydantic import BaseModel, Field @@ -10,7 +10,7 @@ __author__ = "masv" -class Reason(str, Enum): +class Reason(StrEnum): USER_DECEASED = "user_deceased" USER_DEREGISTERED = "user_deregistered" NAME_CHANGED = "name_changed" @@ -19,7 +19,7 @@ class Reason(str, Enum): TEST = "test" -class Source(str, Enum): +class Source(StrEnum): SKV_NAVET_V2 = "swedish_tax_agency_navet_v2" NO_SOURCE = "no_source" TEST = "test" diff --git a/src/eduid/common/models/bearer_token.py b/src/eduid/common/models/bearer_token.py index 50e20dcd8..cfe5b82e9 100644 --- a/src/eduid/common/models/bearer_token.py +++ b/src/eduid/common/models/bearer_token.py @@ -1,7 +1,7 @@ import logging from collections.abc import Mapping from copy import copy -from enum import Enum +from enum import StrEnum from typing import Any from pydantic import BaseModel, Field, StrictInt, field_validator, model_validator @@ -11,7 +11,7 @@ from eduid.userdb.scimapi.groupdb import ScimApiGroupDB -class AuthSource(str, Enum): +class AuthSource(StrEnum): INTERACTION = "interaction" CONFIG = "config" MDQ = "mdq" diff --git a/src/eduid/common/models/gnap_models.py b/src/eduid/common/models/gnap_models.py index 115739bba..56daff884 100644 --- a/src/eduid/common/models/gnap_models.py +++ b/src/eduid/common/models/gnap_models.py @@ -1,5 +1,5 @@ from datetime import datetime -from enum import Enum +from enum import StrEnum from typing import Any from pydantic import AnyUrl, BaseModel, ConfigDict, Field, field_validator @@ -21,7 +21,7 @@ class GnapBaseModel(BaseModel): model_config = ConfigDict(populate_by_name=True) -class ProofMethod(str, Enum): +class ProofMethod(StrEnum): DPOP = "dpop" HTTPSIGN = "httpsign" JWSD = "jwsd" @@ -51,7 +51,7 @@ def expand_proof(cls, v: str | dict[str, Any]) -> dict[str, Any]: return v -class AccessTokenFlags(str, Enum): +class AccessTokenFlags(StrEnum): BEARER = "bearer" DURABLE = "durable" diff --git a/src/eduid/common/models/jose_models.py b/src/eduid/common/models/jose_models.py index bf3eb91e3..be56dbbf9 100644 --- a/src/eduid/common/models/jose_models.py +++ b/src/eduid/common/models/jose_models.py @@ -1,5 +1,5 @@ import datetime -from enum import Enum +from enum import StrEnum from typing import Any from pydantic import AnyUrl, BaseModel, Field @@ -9,18 +9,18 @@ __author__ = "lundberg" -class KeyType(str, Enum): +class KeyType(StrEnum): EC = "EC" RSA = "RSA" OCT = "oct" -class KeyUse(str, Enum): +class KeyUse(StrEnum): SIGN = "sig" ENCRYPT = "enc" -class KeyOptions(str, Enum): +class KeyOptions(StrEnum): SIGN = "sign" VERIFY = "verify" ENCRYPT = "encrypt" @@ -31,13 +31,13 @@ class KeyOptions(str, Enum): DERIVE_BITS = "deriveBits" -class SupportedAlgorithms(str, Enum): +class SupportedAlgorithms(StrEnum): RS256 = "RS256" ES256 = "ES256" ES384 = "ES384" -class SupportedHTTPMethods(str, Enum): +class SupportedHTTPMethods(StrEnum): POST = "POST" @@ -84,7 +84,7 @@ class JWKS(BaseModel): keys: list[ECJWK | RSAJWK | SymmetricJWK] -class SupportedJWSType(str, Enum): +class SupportedJWSType(StrEnum): JWS = "gnap-binding+jws" JWSD = "gnap-binding+jwsd" diff --git a/src/eduid/common/models/saml2.py b/src/eduid/common/models/saml2.py index 50e3647b1..1ed1a2cfd 100644 --- a/src/eduid/common/models/saml2.py +++ b/src/eduid/common/models/saml2.py @@ -1,10 +1,10 @@ -from enum import Enum, unique +from enum import StrEnum, unique __author__ = "lundberg" @unique -class EduidAuthnContextClass(str, Enum): +class EduidAuthnContextClass(StrEnum): DIGG_LOA2 = "http://id.elegnamnden.se/loa/1.0/loa2" REFEDS_MFA = "https://refeds.org/profile/mfa" REFEDS_SFA = "https://refeds.org/profile/sfa" diff --git a/src/eduid/common/models/scim_base.py b/src/eduid/common/models/scim_base.py index c2040b4c7..f526cdd29 100644 --- a/src/eduid/common/models/scim_base.py +++ b/src/eduid/common/models/scim_base.py @@ -1,5 +1,5 @@ from datetime import datetime -from enum import Enum +from enum import StrEnum from typing import Annotated, Any, Self from uuid import UUID @@ -57,7 +57,7 @@ ScimDatetime = Annotated[datetime, PlainSerializer(serialize_xml_datetime)] -class SCIMSchema(str, Enum): +class SCIMSchema(StrEnum): CORE_20_USER = "urn:ietf:params:scim:schemas:core:2.0:User" CORE_20_GROUP = "urn:ietf:params:scim:schemas:core:2.0:Group" API_MESSAGES_20_SEARCH_REQUEST = "urn:ietf:params:scim:api:messages:2.0:SearchRequest" @@ -72,20 +72,20 @@ class SCIMSchema(str, Enum): DEBUG_V1 = "https://scim.eduid.se/schema/nutid-DEBUG/v1" -class SCIMResourceType(str, Enum): +class SCIMResourceType(StrEnum): USER = "User" GROUP = "Group" INVITE = "Invite" EVENT = "Event" -class EmailType(str, Enum): +class EmailType(StrEnum): HOME = "home" WORK = "work" OTHER = "other" -class PhoneNumberType(str, Enum): +class PhoneNumberType(StrEnum): HOME = "home" WORK = "work" OTHER = "other" diff --git a/src/eduid/common/rpc/msg_relay.py b/src/eduid/common/rpc/msg_relay.py index 7c2a0ed12..bcc604a8e 100644 --- a/src/eduid/common/rpc/msg_relay.py +++ b/src/eduid/common/rpc/msg_relay.py @@ -1,5 +1,5 @@ import logging -from enum import Enum +from enum import StrEnum from pydantic import BaseModel, ConfigDict, Field, ValidationError @@ -70,7 +70,7 @@ class RelationId(NavetModelConfig): birth_time_number: str | None = Field(default=None, alias="BirthTimeNumber") -class RelationType(str, Enum): +class RelationType(StrEnum): CHILD = "B" MOTHER = "MO" FATHER = "FA" @@ -94,7 +94,7 @@ class PostalAddresses(NavetModelConfig): official_address: OfficialAddress = Field(alias="OfficialAddress") -class DeregisteredCauseCode(str, Enum): +class DeregisteredCauseCode(StrEnum): DECEASED = "AV" EMIGRATED = "UV" OLD_NIN = "GN" diff --git a/src/eduid/userdb/authninfo.py b/src/eduid/userdb/authninfo.py index 56ebcef5d..3ba727397 100644 --- a/src/eduid/userdb/authninfo.py +++ b/src/eduid/userdb/authninfo.py @@ -2,7 +2,7 @@ from collections.abc import Mapping from dataclasses import dataclass from datetime import datetime -from enum import Enum +from enum import StrEnum from eduid.userdb import User from eduid.userdb.credentials import U2F, Password, Webauthn @@ -14,7 +14,7 @@ __author__ = "eperez" -class AuthnCredType(str, Enum): +class AuthnCredType(StrEnum): password = "security.password_credential_type" u2f = "security.u2f_credential_type" unknown = "security.unknown_credential_type" diff --git a/src/eduid/userdb/credentials/base.py b/src/eduid/userdb/credentials/base.py index baf48d484..8cc45d830 100644 --- a/src/eduid/userdb/credentials/base.py +++ b/src/eduid/userdb/credentials/base.py @@ -1,6 +1,6 @@ from __future__ import annotations -from enum import Enum +from enum import StrEnum from typing import Any from eduid.userdb.element import TVerifiedElementSubclass, VerifiedElement @@ -9,7 +9,7 @@ # well-known proofing methods -class CredentialProofingMethod(str, Enum): +class CredentialProofingMethod(StrEnum): SWAMID_AL2_MFA_HI = "SWAMID_AL2_MFA_HI" # deprecated and replaced by SWAMID_AL3_MFA SWAMID_AL3_MFA = "SWAMID_AL3_MFA" diff --git a/src/eduid/userdb/credentials/external.py b/src/eduid/userdb/credentials/external.py index b39042ba2..a3be65d8a 100644 --- a/src/eduid/userdb/credentials/external.py +++ b/src/eduid/userdb/credentials/external.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections.abc import Mapping -from enum import Enum +from enum import StrEnum from typing import Any, Literal from bson import ObjectId @@ -12,7 +12,7 @@ from eduid.userdb.util import objectid_str -class TrustFramework(str, Enum): +class TrustFramework(StrEnum): SWECONN = "SWECONN" EIDAS = "EIDAS" SVIPE = "SVIPE" diff --git a/src/eduid/userdb/group_management/state.py b/src/eduid/userdb/group_management/state.py index b15bd9045..c43b9085a 100644 --- a/src/eduid/userdb/group_management/state.py +++ b/src/eduid/userdb/group_management/state.py @@ -4,7 +4,7 @@ import datetime from collections.abc import Mapping from dataclasses import asdict, dataclass, field, fields -from enum import Enum, unique +from enum import StrEnum, unique from typing import Any import bson @@ -16,7 +16,7 @@ @unique -class GroupRole(str, Enum): +class GroupRole(StrEnum): OWNER = "owner" MEMBER = "member" diff --git a/src/eduid/userdb/identity.py b/src/eduid/userdb/identity.py index a9ea2fe0f..140894926 100644 --- a/src/eduid/userdb/identity.py +++ b/src/eduid/userdb/identity.py @@ -3,7 +3,7 @@ import logging from abc import ABC from datetime import datetime -from enum import Enum +from enum import StrEnum from typing import Any, Literal from pydantic import Field @@ -15,14 +15,14 @@ logger = logging.getLogger(__name__) -class IdentityType(str, Enum): +class IdentityType(StrEnum): NIN = "nin" EIDAS = "eidas" SVIPE = "svipe" FREJA = "freja" -class IdentityProofingMethod(str, Enum): +class IdentityProofingMethod(StrEnum): # difference in capitalization/underscore/hyphen is intentional as to follow existing proofing log entries SVIPE_ID = "svipe_id" LETTER = "letter" @@ -124,13 +124,13 @@ class ForeignIdentityElement(IdentityElement, ABC): date_of_birth: datetime -class PridPersistence(str, Enum): +class PridPersistence(StrEnum): A = "A" # Persistence over time is expected to be comparable or better than a Swedish nin B = "B" # Persistence over time is expected to be relatively stable, but lower than a Swedish nin C = "C" # No expectations regarding persistence over time -class EIDASLoa(str, Enum): +class EIDASLoa(StrEnum): NF_LOW = "eidas-nf-low" NF_SUBSTANTIAL = "eidas-nf-sub" NF_HIGH = "eidas-nf-high" @@ -188,7 +188,7 @@ def unique_value(self) -> str: return self.svipe_id -class FrejaRegistrationLevel(str, Enum): +class FrejaRegistrationLevel(StrEnum): EXTENDED = "EXTENDED" PLUS = "PLUS" diff --git a/src/eduid/userdb/idp/user.py b/src/eduid/userdb/idp/user.py index f3dfda78a..f40f5eff9 100644 --- a/src/eduid/userdb/idp/user.py +++ b/src/eduid/userdb/idp/user.py @@ -4,7 +4,7 @@ import logging from dataclasses import dataclass -from enum import Enum, unique +from enum import StrEnum, unique from typing import Any from eduid.common.models.saml2 import EduidAuthnContextClass @@ -52,7 +52,7 @@ class SAMLAttributeSettings: @unique -class SubjectIDRequest(str, Enum): +class SubjectIDRequest(StrEnum): ANY = "any" NONE = "none" PAIRWISE_ID = "pairwise-id" diff --git a/src/eduid/userdb/meta.py b/src/eduid/userdb/meta.py index b963a9fc0..472c509ed 100644 --- a/src/eduid/userdb/meta.py +++ b/src/eduid/userdb/meta.py @@ -1,5 +1,5 @@ from datetime import datetime -from enum import Enum +from enum import StrEnum from typing import Annotated from bson import ObjectId @@ -10,7 +10,7 @@ __author__ = "lundberg" -class CleanerType(str, Enum): +class CleanerType(StrEnum): SKV = "skatteverket" TELE = "teleadress" LADOK = "ladok" diff --git a/src/eduid/userdb/user.py b/src/eduid/userdb/user.py index 2ca547c02..9fb08b73e 100644 --- a/src/eduid/userdb/user.py +++ b/src/eduid/userdb/user.py @@ -3,7 +3,7 @@ import copy import logging from datetime import datetime -from enum import Enum, unique +from enum import StrEnum, unique from operator import itemgetter from typing import Any, Self, TypeVar, cast @@ -31,7 +31,7 @@ @unique -class SubjectType(str, Enum): +class SubjectType(StrEnum): PERSON = "physical person" diff --git a/src/eduid/vccs/server/db.py b/src/eduid/vccs/server/db.py index 429ee83d5..e9e7ad4f8 100644 --- a/src/eduid/vccs/server/db.py +++ b/src/eduid/vccs/server/db.py @@ -3,7 +3,7 @@ import builtins from collections.abc import Mapping from dataclasses import asdict, field -from enum import Enum, unique +from enum import Enum, StrEnum, unique from typing import Any, cast from bson import ObjectId @@ -15,22 +15,22 @@ @unique -class Status(str, Enum): +class Status(StrEnum): ACTIVE: str = "active" DISABLED: str = "disabled" @unique -class Version(str, Enum): +class Version(StrEnum): NDNv1: str = "NDNv1" @unique -class KDF(str, Enum): +class KDF(StrEnum): PBKDF2_HMAC_SHA512: str = "PBKDF2-HMAC-SHA512" -class CredType(str, Enum): +class CredType(StrEnum): PASSWORD: str = "password" REVOKED: str = "revoked" diff --git a/src/eduid/vccs/server/endpoints/misc.py b/src/eduid/vccs/server/endpoints/misc.py index 210fa0e15..1848b1426 100644 --- a/src/eduid/vccs/server/endpoints/misc.py +++ b/src/eduid/vccs/server/endpoints/misc.py @@ -1,4 +1,4 @@ -from enum import Enum, unique +from enum import StrEnum, unique from fastapi import APIRouter, Request from pydantic.main import BaseModel @@ -7,7 +7,7 @@ @unique -class Status(str, Enum): +class Status(StrEnum): # STATUS_x_ is less ambiguous when pattern matching than just 'x' OK: str = "STATUS_OK_" FAIL: str = "STATUS_FAIL_" diff --git a/src/eduid/webapp/common/api/errors.py b/src/eduid/webapp/common/api/errors.py index 7f99e177a..b389de095 100644 --- a/src/eduid/webapp/common/api/errors.py +++ b/src/eduid/webapp/common/api/errors.py @@ -1,5 +1,5 @@ from datetime import datetime -from enum import Enum +from enum import StrEnum from flask import redirect from werkzeug.wrappers import Response as WerkzeugResponse @@ -7,7 +7,7 @@ from eduid.common.misc.timeutil import utc_now -class EduidErrorsContext(str, Enum): +class EduidErrorsContext(StrEnum): SAML_RESPONSE_FAIL = "saml_response_fail" SAML_REQUEST_MISSING_IDP = "saml_request_missing_idp" SAML_MISSING_ATTRIBUTE = "saml_missing_attribute" diff --git a/src/eduid/webapp/common/authn/acs_enums.py b/src/eduid/webapp/common/authn/acs_enums.py index e91b5ed6f..0a2ecde02 100644 --- a/src/eduid/webapp/common/authn/acs_enums.py +++ b/src/eduid/webapp/common/authn/acs_enums.py @@ -1,10 +1,10 @@ # Solve circular imports of these by having them in a 'leaf' file :/ -from enum import Enum, unique +from enum import StrEnum, unique @unique -class AuthnAcsAction(str, Enum): +class AuthnAcsAction(StrEnum): login = "login-action" change_password = "change-password-action" terminate_account = "terminate-account-action" @@ -12,14 +12,14 @@ class AuthnAcsAction(str, Enum): @unique -class EidasAcsAction(str, Enum): +class EidasAcsAction(StrEnum): verify_identity = "verify-identity-action" verify_credential = "verify-credential-action" mfa_authenticate = "mfa-authenticate-action" @unique -class BankIDAcsAction(str, Enum): +class BankIDAcsAction(StrEnum): verify_identity = "verify-identity-action" verify_credential = "verify-credential-action" mfa_authenticate = "mfa-authenticate-action" diff --git a/src/eduid/webapp/common/session/namespaces.py b/src/eduid/webapp/common/session/namespaces.py index 0ca6bfba9..a18ae245a 100644 --- a/src/eduid/webapp/common/session/namespaces.py +++ b/src/eduid/webapp/common/session/namespaces.py @@ -5,7 +5,7 @@ from collections.abc import Mapping from copy import deepcopy from datetime import datetime -from enum import Enum, unique +from enum import StrEnum, unique from typing import Any, NewType, TypeVar, cast from uuid import uuid4 @@ -64,7 +64,7 @@ def clear(self) -> None: @unique -class LoginApplication(str, Enum): +class LoginApplication(StrEnum): idp = "idp" authn = "authn" signup = "signup" @@ -184,7 +184,7 @@ class Phone(SessionNSBase): RequestRef = NewType("RequestRef", str) -class OnetimeCredType(str, Enum): +class OnetimeCredType(StrEnum): external_mfa = "ext_mfa" diff --git a/src/eduid/webapp/freja_eid/callback_enums.py b/src/eduid/webapp/freja_eid/callback_enums.py index fc4b1d36c..37745b44c 100644 --- a/src/eduid/webapp/freja_eid/callback_enums.py +++ b/src/eduid/webapp/freja_eid/callback_enums.py @@ -1,8 +1,8 @@ -from enum import Enum, unique +from enum import StrEnum, unique __author__ = "lundberg" @unique -class FrejaEIDAction(str, Enum): +class FrejaEIDAction(StrEnum): verify_identity = "verify-identity-action" diff --git a/src/eduid/webapp/idp/assurance_data.py b/src/eduid/webapp/idp/assurance_data.py index cb7e2de72..7ebb5e6c8 100644 --- a/src/eduid/webapp/idp/assurance_data.py +++ b/src/eduid/webapp/idp/assurance_data.py @@ -3,7 +3,7 @@ """ from datetime import datetime -from enum import Enum +from enum import StrEnum from typing import Any from pydantic import BaseModel @@ -12,7 +12,7 @@ from eduid.userdb.element import ElementKey -class SwamidAssurance(str, Enum): +class SwamidAssurance(StrEnum): SWAMID_AL1 = "http://www.swamid.se/policy/assurance/al1" SWAMID_AL2 = "http://www.swamid.se/policy/assurance/al2" SWAMID_AL3 = "http://www.swamid.se/policy/assurance/al3" @@ -26,7 +26,7 @@ class SwamidAssurance(str, Enum): REFEDS_PROFILE_ESPRESSO = "https://refeds.org/assurance/profile/espresso" -class SwedenConnectAssurance(str, Enum): +class SwedenConnectAssurance(StrEnum): LOA2 = "http://id.elegnamnden.se/loa/1.0/loa2" LOA3 = "http://id.elegnamnden.se/loa/1.0/loa3" UNCERTIFIED_LOA3 = "http://id.swedenconnect.se/loa/1.0/uncertified-loa3" @@ -46,7 +46,7 @@ def __str__(self) -> str: ) -class UsedWhere(str, Enum): +class UsedWhere(StrEnum): REQUEST = "request" SSO = "SSO session" diff --git a/src/eduid/webapp/idp/helpers.py b/src/eduid/webapp/idp/helpers.py index 2da6d407b..062acac04 100644 --- a/src/eduid/webapp/idp/helpers.py +++ b/src/eduid/webapp/idp/helpers.py @@ -1,4 +1,4 @@ -from enum import Enum, unique +from enum import StrEnum, unique from typing import Any from saml2 import BINDING_HTTP_POST @@ -46,7 +46,7 @@ class IdPMsg(str, TranslatableMsg): @unique -class IdPAction(str, Enum): +class IdPAction(StrEnum): NEW_DEVICE = "NEW_DEVICE" OTHER_DEVICE = "OTHER_DEVICE" PWAUTH = "USERNAMEPASSWORD" diff --git a/src/eduid/webapp/idp/other_device/data.py b/src/eduid/webapp/idp/other_device/data.py index 7f59a90cc..20f8f9453 100644 --- a/src/eduid/webapp/idp/other_device/data.py +++ b/src/eduid/webapp/idp/other_device/data.py @@ -2,11 +2,11 @@ Some data structures that causes import loops if they are defined in db.py. """ -from enum import Enum +from enum import StrEnum from typing import NewType -class OtherDeviceState(str, Enum): +class OtherDeviceState(StrEnum): NEW = "NEW" # only used device #1 so far IN_PROGRESS = "IN_PROGRESS" # device #2 has 'grabbed' the request AUTHENTICATED = "AUTHENTICATED" # device #2 is finished with the request (successfully) diff --git a/src/eduid/webapp/idp/util.py b/src/eduid/webapp/idp/util.py index c822b1cc9..b8f280196 100644 --- a/src/eduid/webapp/idp/util.py +++ b/src/eduid/webapp/idp/util.py @@ -3,7 +3,7 @@ import base64 import ipaddress import logging -from enum import Enum +from enum import StrEnum from eduid.userdb.idp import IdPUser @@ -47,7 +47,7 @@ def maybe_xml_to_string(message: str | bytes) -> str: return message -class IPProximity(str, Enum): +class IPProximity(StrEnum): SAME = "SAME" NEAR = "NEAR" FAR = "FAR" diff --git a/src/eduid/webapp/security/webauthn_proofing.py b/src/eduid/webapp/security/webauthn_proofing.py index c195f49b8..1731b34dc 100644 --- a/src/eduid/webapp/security/webauthn_proofing.py +++ b/src/eduid/webapp/security/webauthn_proofing.py @@ -1,6 +1,6 @@ from dataclasses import dataclass, field from datetime import date, datetime, time -from enum import Enum +from enum import StrEnum from uuid import UUID from fido2.utils import websafe_decode @@ -16,7 +16,7 @@ __author__ = "lundberg" -class OtherAuthenticatorStatus(str, Enum): +class OtherAuthenticatorStatus(StrEnum): APPLE = "APPLE" MAGIC_COOKIE = "MAGIC_COOKIE" diff --git a/src/eduid/webapp/signup/helpers.py b/src/eduid/webapp/signup/helpers.py index a2e2e2008..2c4ffb088 100644 --- a/src/eduid/webapp/signup/helpers.py +++ b/src/eduid/webapp/signup/helpers.py @@ -2,7 +2,7 @@ import struct from dataclasses import replace from datetime import datetime -from enum import Enum, unique +from enum import StrEnum, unique import proquint from flask import abort @@ -89,7 +89,7 @@ class SignupMsg(TranslatableMsg): @unique -class EmailStatus(str, Enum): +class EmailStatus(StrEnum): ADDRESS_USED = "address_used" RESEND_CODE = "resend_code" NEW = "new" diff --git a/src/eduid/webapp/svipe_id/callback_enums.py b/src/eduid/webapp/svipe_id/callback_enums.py index f6fe45e4f..f57a75cca 100644 --- a/src/eduid/webapp/svipe_id/callback_enums.py +++ b/src/eduid/webapp/svipe_id/callback_enums.py @@ -1,8 +1,8 @@ -from enum import Enum, unique +from enum import StrEnum, unique __author__ = "lundberg" @unique -class SvipeIDAction(str, Enum): +class SvipeIDAction(StrEnum): verify_identity = "verify-identity-action" diff --git a/src/eduid/workers/amapi/config.py b/src/eduid/workers/amapi/config.py index 4cbcc9db1..f9cc3e2a7 100644 --- a/src/eduid/workers/amapi/config.py +++ b/src/eduid/workers/amapi/config.py @@ -1,5 +1,5 @@ import logging -from enum import Enum +from enum import StrEnum from pathlib import Path from typing import NewType @@ -10,7 +10,7 @@ logger = logging.getLogger(__name__) -class SupportedMethod(str, Enum): +class SupportedMethod(StrEnum): DELETE = "delete" PUT = "put" GET = "get"