|
| 1 | +## Context |
| 2 | + |
| 3 | +The login UI runs "Bring Your Own SSO" when its setting `BYOSSO_ENABLED` is on. With the feature, the login UI calls the Tenant Service and the SSO Service over gRPC. It also decides itself when a sign-in needs MFA. The login UI refuses to start when the feature is on and something that the feature needs is absent. |
| 4 | + |
| 5 | +The charm already has 2 of the relations that the feature needs. The `tenant-service-info` relation gives the address of the Tenant Service, and the `kratos-info` relation gives the settings of Kratos. The charm also gives its endpoint URLs to other charms in `ui-endpoint-info`. The Kratos charm is one of the charms that read that relation. |
| 6 | + |
| 7 | +In this document, to plan the workload is to give Pebble the layer of the service and to start or replan the service. |
| 8 | + |
| 9 | +## Goals / Non-Goals |
| 10 | + |
| 11 | +**Goals:** |
| 12 | + |
| 13 | +- One option turns the feature on. The charm gets all other values from its relations. |
| 14 | +- The unit status tells the operator what the feature needs. |
| 15 | +- The charm leaves a workload that runs the feature as it is when a relation goes away. |
| 16 | + |
| 17 | +**Non-Goals:** |
| 18 | + |
| 19 | +- The configuration of Kratos for the feature. The Kratos charm does that work. |
| 20 | +- Credentials for the calls to the Tenant Service and the SSO Service. The login UI makes these calls with no token. |
| 21 | +- A check that the workload image has the feature. |
| 22 | + |
| 23 | +## Decisions |
| 24 | + |
| 25 | +### 1. The charm plans nothing while a check fails |
| 26 | + |
| 27 | +**Decision:** While the option is on and a check of the feature fails, the charm sets its status and stops before the plan. It does not plan the workload with the feature, and it does not plan the workload without the feature. |
| 28 | + |
| 29 | +**Reason:** The login UI refuses to start when `BYOSSO_ENABLED` is on and something that it needs is absent. A login UI with the feature off does not enforce the sign-in policies of the tenants. Thus the 2 possible plans are both wrong, and the charm leaves the workload as it is. |
| 30 | + |
| 31 | +**Alternatives that we turned down:** |
| 32 | + |
| 33 | +- A plan without the feature until all the checks pass. With such a plan, a relation that goes away stops the enforcement of the sign-in policies of the tenants. |
| 34 | +- A plan with the feature. The service does not start with such a plan. |
| 35 | + |
| 36 | +### 2. The checks include 2 settings of Kratos |
| 37 | + |
| 38 | +**Decision:** The charm blocks the feature when Kratos runs with OIDC-WebAuthn sequencing, and when Kratos runs without verification. The charm reads both settings from `kratos-info`. |
| 39 | + |
| 40 | +**Reason:** The charm relies on the Kratos charm to block on the same 2 settings. Without these checks, the login UI runs the feature while Kratos is not configured for the feature. |
| 41 | + |
| 42 | +### 3. The charm tells Kratos in ui-endpoint-info, and takes the value from its option |
| 43 | + |
| 44 | +**Decision:** The leader writes `byosso_enabled` in `ui-endpoint-info`. The value is the text `true` or the text `false`, as the option says. The leader writes the field after each plan that succeeds, and together with the endpoint URLs. It does not write the field while a check of the feature fails. |
| 45 | + |
| 46 | +**Reason:** There are 2 reasons: |
| 47 | + |
| 48 | +- Kratos must change its configuration only for a login UI that the charm plans with the feature. |
| 49 | +- While a check fails, the workload stays as it is. Thus the value that Kratos has must also stay as it is. If the charm writes `false` at that time, Kratos and a workload that runs the feature disagree. |
| 50 | + |
| 51 | +**Alternative that we turned down:** A value that the charm reads from the Pebble plan and from the state of the service. That value needs calls to Pebble in each hook. The option and the checks give the charm its answer without those calls. |
| 52 | + |
| 53 | +### 4. The age of a privileged session comes from kratos-info |
| 54 | + |
| 55 | +**Decision:** The charm passes the `privileged_session_max_age` of `kratos-info` to the workload as `KRATOS_PRIVILEGED_SESSION_MAX_AGE`. The charm has no option for this value. When `kratos-info` does not have the field, the charm blocks the feature and tells the operator to refresh the Kratos charm. |
| 56 | + |
| 57 | +**Reason:** The login UI must apply the same age as Kratos. Kratos knows the age that it runs with, so the charm takes the value from there. |
| 58 | + |
| 59 | +**Alternative that we turned down:** An option of this charm. Such an option is a second copy of the value, and the operator must keep the 2 copies equal. |
| 60 | + |
| 61 | +The status for an absent field is blocked and not waiting. The field does not arrive until the operator refreshes the Kratos charm, and the message says so. |
| 62 | + |
| 63 | +### 5. The sso_service_info library is a Python package from git |
| 64 | + |
| 65 | +**Decision:** The charm installs the library as the Python package `sso-service-info`. The package comes from a commit of the repository of the SSO Service charm, from its directory `interfaces/sso_service_info`. The pin is in `pyproject.toml` and in `uv.lock`, and `git` is in the build packages of the charm. |
| 66 | + |
| 67 | +**Reason:** Charmhub takes no new libraries. Thus `charmcraft fetch-lib` cannot get this library. |
| 68 | + |
| 69 | +## Risks / Trade-offs |
| 70 | + |
| 71 | +- **A new container while a check fails.** The charm adds no layer to a workload container that starts while a check fails. The charm does not start the service there until all the checks pass. The unit status shows the check that fails. |
| 72 | +- **The value in ui-endpoint-info can be ahead of the workload.** The leader writes the field with the endpoint URLs when a `ui-endpoint-info` relation is created. That write can come before the first plan, and after a plan that failed. The charm does not read the workload, so the text `true` does not prove that the service runs. |
| 73 | +- **The 2 charms act in different hooks.** After the operator changes the option, this charm plans the workload first. The Kratos charm changes Kratos later, in a hook of its own. Between the 2 hooks, Kratos and the login UI can disagree about the feature. |
| 74 | +- **An older revision of the charm.** A revision from before this change does not write `byosso_enabled`. After a refresh to such a revision, the last value stays in the relation data. Turn the option off before such a refresh. |
| 75 | +- **The build needs the repository of the SSO Service charm.** The build of the charm gets the library with `git`. The commit in `pyproject.toml` and in `uv.lock` must exist in that repository. |
| 76 | +- **The charm checks relation data only.** The charm does not check that the Tenant Service and the SSO Service answer at their addresses. |
0 commit comments