|
| 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 | + |
0 commit comments