Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "1.5.0+261122"
current_version = "1.6.0+261123"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)\\+(?P<build>\\d+)"
serialize = ["{major}.{minor}.{patch}+{build}"]
search = "{current_version}"
Expand Down
14 changes: 6 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ An MDM fits, for managed Android phones, if an operator can do five things in it
2. Send each phone's certificate request to Deploy App's SCEP URL with one challenge, the same
for every phone of an enrolment window.
3. Put a value that can be set for each phone into the certificate subject: the callsign, as the
common name.
common name, and nothing else.
4. Take a new challenge for each enrolment window.
5. Ask one phone for its certificate again and leave the others alone.

Expand Down Expand Up @@ -555,17 +555,15 @@ a deployment installs, and give your copy as the template.

The certificate subject is the contract with the deployment. Its common name becomes the callsign:
3 to 32 letters, digits or hyphens, no hyphen at either end. It is the name ``name`` gives the
phone, optionally followed by Fleet's id for the host::
phone, and the subject holds nothing else::

CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, OU=$FLEET_VAR_HOST_UUID
CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART

The tool refuses any other subject; it takes ``$FLEET_VAR_HOST_END_USER_IDP_USERNAME`` in place of
the ``_LOCAL_PART`` form, which is the same text for a callsign. The shipped template uses the
first: the id travels in the certificate request, so the deployment can tell later which device a
callsign was issued to. A subject cannot change on a team that has phones, since replacing the
certificate template removes every phone's certificate, so a team set up without the id keeps the
second form in a template of its own.
the ``_LOCAL_PART`` form, which is the same text for a callsign. Deploy App refuses a request
whose subject holds more than the callsign. Version 1.5 put Fleet's id for the host after it, as
``OU``: a team set up that way needs a new team, because a subject cannot change on a team that
has phones, since replacing the certificate template removes every phone's certificate.

A name the phone supplies, such as its serial number, would make a leaked enrolment link enough
for an identity.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "odmdm-connector"
version = "1.5.0+261122"
version = "1.6.0+261123"
description = "Connects an MDM, FleetDM built in, to an OpenDefence deployment's SCEP device enrolment"
authors = [
{ name = "Benjam", email = "benjam@opendefence.fi" },
Expand Down
2 changes: 1 addition & 1 deletion src/odmdm_connector/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Connects an MDM, FleetDM built in, to an OpenDefence deployment's SCEP device enrolment"""

__version__ = "1.5.0+261122" # NOTE Use `bump-my-version` to bump versions correctly
__version__ = "1.6.0+261123" # NOTE Use `bump-my-version` to bump versions correctly
7 changes: 3 additions & 4 deletions src/odmdm_connector/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@
"The template Fleet fills in per phone. Its common name becomes the phone's callsign: 3-32",
"letters, digits or inner hyphens. This is the name `odmdm-connector name` gives a phone, and",
"the connector refuses any other common name: one the phone supplies, such as its serial",
"number, would make a leaked enrolment link enough for an identity. Fleet's id for the phone",
"follows it as OU, so the deployment can tell later which device a callsign was issued to;",
"leave the OU out only for a team that already has phones under a subject without it.",
"number, would make a leaked enrolment link enough for an identity. The subject is that name",
"and nothing else: the deployment refuses a request whose subject holds anything more.",
"The name becomes the Android keystore alias, so it is per deployment.",
"No certificate authority is named: the connector finds this Deploy App's in the MDM by the",
"address it serves, and makes one when there is none, called ODMDM_ and the first part of the",
"Deploy App's host name.",
"So one MDM can serve several Deploy Apps. \"authority\": \"NAME\" here gives a new one that name."
],
"name": "{key_alias}",
"subject": "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, OU=$FLEET_VAR_HOST_UUID"
"subject": "CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART"
},
"link_app": {
"_comment": "A launcher icon so nobody has to know where the server lives. It is a browser shortcut, so it only works alongside the browser and the certificate.",
Expand Down
13 changes: 7 additions & 6 deletions src/odmdm_connector/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class TemplateError(ValueError):
"""The document is not something we can act on"""


#: The callsign as the common name, from the name the operator gives the phone, and optionally the
#: MDM's own device id beside it. Anything the phone or the enrolment link supplies, a serial
#: number for one, would let whoever holds a leaked enrolment link pick an identity.
SUBJECT = re.compile(r"CN=\$FLEET_VAR_HOST_END_USER_IDP_USERNAME(_LOCAL_PART)?(\s*,\s*OU=\$FLEET_VAR_HOST_UUID)?")
#: The callsign as the common name, from the name the operator gives the phone, and nothing else:
#: the deployment refuses a request whose subject holds more. Anything the phone or the enrolment
#: link supplies, a serial number for one, would let whoever holds a leaked enrolment link pick
#: an identity.
SUBJECT = re.compile(r"CN=\$FLEET_VAR_HOST_END_USER_IDP_USERNAME(_LOCAL_PART)?")


def _unsafe(policy: dict[str, Any], certificate: dict[str, Any] | None) -> str:
Expand All @@ -46,8 +47,8 @@ def _unsafe(policy: dict[str, Any], certificate: dict[str, Any] | None) -> str:
"""
if certificate is not None and not SUBJECT.fullmatch(str(certificate.get("subject", ""))):
return (
"the certificate subject must be CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, optionally "
"followed by OU=$FLEET_VAR_HOST_UUID, so the callsign is the name the operator gave the phone"
"the certificate subject must be CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART and nothing "
"else, so the callsign is the name the operator gave the phone and the deployment takes the request"
)
rules = policy.get("choosePrivateKeyRules", [])
if not isinstance(rules, list):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_odmdm_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

def test_version() -> None:
"""Make sure version matches expected"""
assert __version__ == "1.5.0+261122"
assert __version__ == "1.6.0+261123"
9 changes: 4 additions & 5 deletions tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ def _with(policy: dict[str, object] | None = None, subject: str = NAMED) -> dict
[
NAMED,
"CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME",
"CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME_LOCAL_PART, OU=$FLEET_VAR_HOST_UUID",
"CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME,OU=$FLEET_VAR_HOST_UUID",
],
)
def test_the_callsign_is_the_name_the_operator_gave(tmp_path: Path, subject: str) -> None:
Expand All @@ -96,6 +94,7 @@ def test_the_callsign_is_the_name_the_operator_gave(tmp_path: Path, subject: str
(_with(subject="CN=$FLEET_VAR_HOST_HARDWARE_SERIAL"), "certificate subject must be CN="),
(_with(subject="CN=OTTER1"), "certificate subject must be CN="),
(_with(subject=NAMED + ", OU=$FLEET_VAR_HOST_HARDWARE_SERIAL"), "certificate subject must be CN="),
(_with(subject=NAMED + ", OU=$FLEET_VAR_HOST_UUID"), "certificate subject must be CN="),
(_with(subject="OU=$FLEET_VAR_HOST_UUID, " + NAMED), "certificate subject must be CN="),
(
_with({"choosePrivateKeyRules": [{"urlPattern": "x", "privateKeyAlias": "rmscep"}]}),
Expand Down Expand Up @@ -194,9 +193,9 @@ def test_a_template_may_name_its_authority(tmp_path: Path) -> None:
assert template.certificate is not None and template.certificate.authority == "RMSCEP"


def test_the_shipped_subject_carries_the_device_id() -> None:
"""A subject cannot change once a team has phones, so the id is there from the first template"""
def test_the_shipped_subject_is_the_callsign_alone() -> None:
"""The deployment refuses a request whose subject holds more than the callsign"""
template = load(EXAMPLE, domain="example.fi", key_alias="rmscep")

assert template.certificate is not None
assert template.certificate.subject == f"{NAMED}, OU=$FLEET_VAR_HOST_UUID"
assert template.certificate.subject == NAMED
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading