Skip to content

Commit

Permalink
✨ [#4863] Allow authentication with employee_id
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Dec 18, 2024
1 parent 06125b4 commit e70fab7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/openforms/authentication/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
DigiDMachtigenContext,
EHerkenningContext,
EHerkenningMachtigenContext,
EmployeeContext,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -254,6 +255,7 @@ def to_auth_context_data(
| DigiDMachtigenContext
| EHerkenningContext
| EHerkenningMachtigenContext
| EmployeeContext
):
if self.attribute_hashed:
logger.debug(
Expand Down Expand Up @@ -347,6 +349,21 @@ def to_auth_context_data(
"branchNumber"
] = branch_number
return ehm_context

# Experimental feature that is different from the defined authentication context.
# This will have to be re-worked and re-thought-out, and will most definitely change.
# This is a fix for #4863
case (AuthAttribute.employee_id, ""):
employee_context: EmployeeContext = {
"source": "custom",
"levelOfAssurance": self.loa,
"representee": {
"identifierType": "employee_id",
"identifier": self.value,
},
}
return employee_context

case _: # pragma: no cover
raise RuntimeError(f"Unknown attribute: {self.attribute}")

Expand Down
12 changes: 12 additions & 0 deletions src/openforms/authentication/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ class EHMandate(TypedDict):
class EHerkenningMachtigenContext(EHerkenningContext):
representee: EHRepresenteeEntity
mandate: EHMandate


class EmployeeRepresenteeEntity(TypedDict):
identifierType: Literal["employee_id"]
identifier: str


# This type definition is highly experimental, and will most definitely change
class EmployeeContext(TypedDict):
source: Literal["custom"]
levelOfAssurance: None
representee: EmployeeRepresenteeEntity

0 comments on commit e70fab7

Please sign in to comment.