Skip to content

Commit 161d126

Browse files
committed
docs(spec): add and archive the optional-device-flow-urls specification
The change modifies the workload-service capability: the login UI is in place with the login, consent and error URLs, and the charm does not wait for the 2 device-flow URLs. A new capability, login-ui-endpoints, says how the charm writes the URLs of the login UI to Hydra's configuration, with urls.device only for the device-flow URLs that the login UI publishes.
1 parent b518995 commit 161d126

5 files changed

Lines changed: 160 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-10-13
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Why
2+
3+
The charm waits for 5 URLs of the login UI on the relation `ui-endpoint-info` before it takes the login UI as ready. A login UI without the device flow publishes only the login, consent and error URLs. For such a login UI, the charm never writes Hydra's configuration and never starts Hydra.
4+
5+
The SSO Service is such a login UI. In the feature "Bring Your Own SSO", it is the login and consent provider of a second Hydra, and it has no device flow.
6+
7+
## What Changes
8+
9+
- The charm needs only 3 URLs from the login UI: `login_url`, `consent_url` and `oidc_error_url`.
10+
- The 2 device-flow URLs, `device_verification_url` and `post_device_done_url`, become optional.
11+
- The charm writes `urls.device.verification` and `urls.device.success` to Hydra's configuration only for the device-flow URLs that the login UI publishes.
12+
- When the login UI publishes no device-flow URL, Hydra's configuration has no `urls.device` key. Hydra then uses its own fallback pages for the device flow.
13+
14+
A login UI that publishes all 5 URLs gets the same configuration as before.
15+
16+
## Capabilities
17+
18+
### New Capabilities
19+
20+
- `login-ui-endpoints`: the URLs that the charm reads from the login UI, and how it writes them to Hydra's configuration.
21+
22+
### Modified Capabilities
23+
24+
- `workload-service`: which URLs of the login UI the charm needs before it runs Hydra.
25+
26+
## Non-goals
27+
28+
- A check of the URLs. The charm does not validate a URL or make sure that the login UI serves it.
29+
- A switch for the device flow of Hydra. The charm does not turn the device flow off when the login UI publishes no device-flow URL.
30+
- A stop of the workload when the login UI no longer publishes a required URL. The workload continues with its configuration.
31+
32+
## Success Metrics
33+
34+
- With a login UI that publishes no device-flow URL, the unit shows `active` and Hydra runs.
35+
- With a login UI that publishes all 5 URLs, Hydra's configuration does not change.
36+
37+
## Impact
38+
39+
- `src/integrations.py`: `LoginUIEndpointData.is_ready` checks only the 3 required URLs.
40+
- `templates/hydra.yaml.j2`: the key `urls.device` and each of its 2 keys are conditional.
41+
- `tests/unit`: tests of readiness with and without the device-flow URLs, and of the configuration with both, with one and with none of them.
42+
- The library `login_ui_endpoints` does not change. Each field of its provider data is already optional.
43+
- `charmcraft.yaml` and the options of the charm do not change.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## 1. Readiness of the login UI
2+
3+
- [x] 1.1 In `src/integrations.py`, make `LoginUIEndpointData.is_ready` need only `login_url`, `consent_url` and `oidc_error_url`
4+
- [x] 1.2 In `tests/unit/test_integrations.py`, add unit tests of readiness with and without the device-flow URLs, and without each required URL
5+
6+
## 2. Hydra's configuration
7+
8+
- [x] 2.1 Write the key `urls.device` in `templates/hydra.yaml.j2` only when the login UI publishes a device-flow URL
9+
- [x] 2.2 In `templates/hydra.yaml.j2`, write each of `urls.device.verification` and `urls.device.success` only when the login UI publishes its URL
10+
- [x] 2.3 In `tests/unit/test_configs.py`, add unit tests of the configuration with both device-flow URLs, with one and with none
11+
- [x] 2.4 In `tests/unit/test_charm.py`, add unit tests of the charm with a login UI that publishes no device-flow URL
12+
- [x] 2.5 In `tests/unit/test_charm.py`, add unit tests of the charm with a login UI that publishes both device-flow URLs
13+
14+
## 3. Verification suite
15+
16+
- [x] 3.1 Run `tox -e lint`
17+
- [x] 3.2 Run `tox -e unit` and make sure that all tests pass
18+
- [x] 3.3 Run `openspec validate --all --strict`
19+
20+
## 4. Documentation & rollout
21+
22+
- [x] 4.1 Make sure that `README.md` names no URL of the login UI and needs no update
23+
24+
This change needs no rollout step. With a login UI that publishes all 5 URLs, Hydra's configuration does not change.
25+
26+
## Implementation Notes
27+
28+
The implementation follows the plan. There are no deviations.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# login-ui-endpoints Specification
2+
3+
## Purpose
4+
5+
Hydra redirects a browser to a login UI for login, for consent, for an error and for the device flow. In this specification, the login UI is the application that the charm relates to over `ui-endpoint-info`. This capability says which URLs of the login UI the charm reads, and how the charm writes the URLs to Hydra's configuration. The capability `workload-service` says which of these URLs the charm needs before it runs Hydra.
6+
7+
Key decisions:
8+
9+
- **The charm needs only the login, consent and error URLs.** A login UI without the device flow publishes no device-flow URL. Hydra must start with such a login UI. The SSO Service of "Bring Your Own SSO" is an example of such a login UI.
10+
- **The charm leaves out the key of an unpublished device-flow URL.** With an empty URL, that key has no value in Hydra's configuration. The configuration schema of Hydra takes only a text for that key. The charm relies on Hydra to use its own fallback page for a device-flow URL that Hydra's configuration does not have.
11+
12+
Non-goals:
13+
14+
- A check of the URLs. The charm does not validate a URL and does not make sure that the login UI serves it.
15+
- A switch for the device flow of Hydra. The charm does not turn the device flow off when the login UI publishes no device-flow URL.
16+
17+
## Requirements
18+
19+
### Requirement: The login UI URLs in Hydra's configuration
20+
21+
The charm SHALL read the URLs of the login UI from the application data of the relation `ui-endpoint-info`, which has the interface `login_ui_endpoints`. The login UI publishes a URL when the field of that URL has a value that is not empty. The charm SHALL write the URLs of the login UI to Hydra's configuration, the file `/etc/config/hydra.yaml` in the workload container, as this table shows:
22+
23+
| field of `ui-endpoint-info` | key of Hydra's configuration |
24+
|---|---|
25+
| `login_url` | `urls.login` |
26+
| `consent_url` | `urls.consent` |
27+
| `oidc_error_url` | `urls.error` |
28+
| `device_verification_url` | `urls.device.verification` |
29+
| `post_device_done_url` | `urls.device.success` |
30+
31+
The charm does not read the other fields of the relation, for example `error_url`.
32+
33+
The charm SHALL write each of the 2 keys under `urls.device` only when the login UI publishes the URL of that key. The charm SHALL NOT write such a key with an empty value. When the login UI publishes no device-flow URL, the charm SHALL NOT write the key `urls.device`.
34+
35+
For a device-flow URL that Hydra's configuration does not have, Hydra uses its own fallback page. The charm relies on that behaviour of Hydra.
36+
37+
This behaviour is backward compatible. A login UI that publishes all 5 URLs gets the same configuration as it got when the charm needed all 5 URLs.
38+
39+
When the login UI changes the URLs that it publishes, the charm SHALL render Hydra's configuration again from the new set of URLs. When the result differs from the file in the workload container, the charm SHALL write the file and restart the workload. This applies while the requirements of Hydra are met.
40+
41+
#### Scenario: No device-flow URL
42+
43+
- **WHEN** the login UI publishes neither `device_verification_url` nor `post_device_done_url`
44+
- **THEN** Hydra's configuration has the keys `urls.login`, `urls.consent` and `urls.error`
45+
- **AND** Hydra's configuration has no `urls.device` key
46+
47+
#### Scenario: Both device-flow URLs
48+
49+
- **WHEN** the login UI publishes `device_verification_url` and `post_device_done_url`
50+
- **THEN** `urls.device.verification` has the value of `device_verification_url`
51+
- **AND** `urls.device.success` has the value of `post_device_done_url`
52+
53+
#### Scenario: Only one device-flow URL
54+
55+
- **WHEN** the login UI publishes `device_verification_url` and no `post_device_done_url`
56+
- **THEN** `urls.device` has the key `verification` and no key `success`
57+
58+
#### Scenario: The login UI publishes the device-flow URLs later
59+
60+
- **WHEN** the workload runs with a configuration that has no `urls.device` key
61+
- **AND** the login UI then publishes both device-flow URLs
62+
- **THEN** the charm writes Hydra's configuration again, with both keys under `urls.device`
63+
- **AND** the charm restarts the workload
64+

‎openspec/specs/workload-service/spec.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ The charm SHALL keep Hydra running whenever everything it needs is in place:
1313
the database, the public ingress, the login UI, the secrets and a recorded
1414
schema migration.
1515

16+
The login UI is in place when it publishes all of these 3 URLs on the
17+
relation `ui-endpoint-info`: `login_url`, `consent_url` and `oidc_error_url`.
18+
The charm SHALL NOT wait for the 2 device-flow URLs of the login UI,
19+
`device_verification_url` and `post_device_done_url`.
20+
1621
#### Scenario: Stopped workload with an unchanged configuration
1722

1823
- **WHEN** Hydra is stopped, its requirements are met and its configuration
@@ -30,6 +35,24 @@ schema migration.
3035
- **THEN** the charm SHALL leave the restarts to Pebble and SHALL NOT restart
3136
Hydra on each event
3237

38+
#### Scenario: Login UI without the device flow
39+
40+
- **WHEN** the login UI publishes `login_url`, `consent_url` and
41+
`oidc_error_url`, and no device-flow URL
42+
- **AND** the other requirements of Hydra are met
43+
- **THEN** the charm SHALL keep Hydra running
44+
- **AND** the unit SHALL show `active`
45+
46+
#### Scenario: Login UI without a required URL
47+
48+
- **WHEN** the login UI publishes `consent_url` and `oidc_error_url`, and no
49+
`login_url`
50+
- **THEN** the charm SHALL NOT write the configuration of Hydra
51+
- **AND** the charm SHALL NOT start or restart Hydra
52+
- **AND** the charm SHALL NOT stop a Hydra that already runs
53+
- **AND** the unit SHALL show `waiting` with the message
54+
"Waiting for login UI to be ready", unless another status takes priority
55+
3356
### Requirement: Start failures are reported accurately
3457

3558
The unit SHALL show "Failed to start the service" only when the charm expects

0 commit comments

Comments
 (0)