|
1 | | -federation |
2 | | -========= |
| 1 | +# federation |
3 | 2 |
|
4 | | -This role will setup Openstack for user federation. The keycloak system will be used for the IdP provider. |
| 3 | +This role sets up OpenStack Keystone federation with Keycloak (Red Hat SSO) as the Identity Provider. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The federation role configures: |
| 8 | +- Keycloak realm(s) with test users and groups |
| 9 | +- Keystone Identity Provider and protocol configuration |
| 10 | +- OIDC authentication for OpenStack CLI |
| 11 | +- Comprehensive authentication testing |
| 12 | + |
| 13 | +## Supported OIDC Authentication Methods |
| 14 | + |
| 15 | +This role supports testing all OIDC authentication methods available in keystoneauth1: |
| 16 | + |
| 17 | +| Plugin Name | Description | Status | |
| 18 | +|-------------|-------------|--------| |
| 19 | +| `v3oidcpassword` | Resource Owner Password Credentials flow | ✅ Supported | |
| 20 | +| `v3oidcclientcredentials` | Client Credentials flow | ✅ Supported | |
| 21 | +| `v3oidcaccesstoken` | Reuse existing access token | ✅ Supported | |
| 22 | +| `v3oidcauthcode` | Authorization Code flow | ✅ Supported | |
| 23 | +| `v3oidcdeviceauthz` | Device Authorization flow (RFC 8628) | ⚠️ Requires Python 3.10+ | |
| 24 | + |
| 25 | +## Variables |
| 26 | + |
| 27 | +### Infrastructure Configuration |
| 28 | + |
| 29 | +| Variable | Default | Description | |
| 30 | +|----------|---------|-------------| |
| 31 | +| `cifmw_federation_keycloak_namespace` | `openstack` | Kubernetes namespace for Keycloak | |
| 32 | +| `cifmw_federation_run_osp_cmd_namespace` | `openstack` | Kubernetes namespace for openstackclient | |
| 33 | +| `cifmw_federation_domain` | - | Base domain for service URLs | |
| 34 | + |
| 35 | +### Keycloak Configuration |
| 36 | + |
| 37 | +| Variable | Default | Description | |
| 38 | +|----------|---------|-------------| |
| 39 | +| `cifmw_federation_keycloak_realm` | `openstack` | Primary Keycloak realm name | |
| 40 | +| `cifmw_federation_keycloak_realm2` | `openstack2` | Secondary realm (multirealm mode) | |
| 41 | +| `cifmw_federation_keycloak_admin_username` | `admin` | Keycloak admin username | |
| 42 | +| `cifmw_federation_keycloak_admin_password` | `nomoresecrets` | Keycloak admin password | |
| 43 | +| `cifmw_federation_deploy_multirealm` | `false` | Deploy multiple realms | |
| 44 | + |
| 45 | +### Test Users |
| 46 | + |
| 47 | +| Variable | Default | Description | |
| 48 | +|----------|---------|-------------| |
| 49 | +| `cifmw_federation_keycloak_testuser1_username` | `kctestuser1` | Test user 1 username | |
| 50 | +| `cifmw_federation_keycloak_testuser1_password` | `nomoresecrets1` | Test user 1 password | |
| 51 | +| `cifmw_federation_keycloak_testuser2_username` | `kctestuser2` | Test user 2 username | |
| 52 | +| `cifmw_federation_keycloak_testuser2_password` | `nomoresecrets2` | Test user 2 password | |
| 53 | + |
| 54 | +### Keystone Integration |
| 55 | + |
| 56 | +| Variable | Default | Description | |
| 57 | +|----------|---------|-------------| |
| 58 | +| `cifmw_federation_IdpName` | `kcIDP` | Identity Provider name in Keystone | |
| 59 | +| `cifmw_federation_keystone_domain` | `SSO` | Keystone domain for federated users | |
| 60 | +| `cifmw_federation_mapping_name` | `SSOmap` | Keystone mapping name | |
| 61 | +| `cifmw_federation_project_name` | `SSOproject` | Project for federated users | |
| 62 | +| `cifmw_federation_group_name` | `SSOgroup` | Group for federated users | |
| 63 | + |
| 64 | +### OIDC Client Configuration |
| 65 | + |
| 66 | +| Variable | Default | Description | |
| 67 | +|----------|---------|-------------| |
| 68 | +| `cifmw_federation_keystone_OIDC_ClientID` | `rhoso` | OIDC client ID | |
| 69 | +| `cifmw_federation_keystone_OIDC_ClientSecret` | `COX8bmlKAWn56XCGMrKQJj7dgHNAOl6f` | OIDC client secret | |
| 70 | +| `cifmw_federation_keystone_OIDC_Scope` | `openid email profile` | OIDC scopes | |
| 71 | + |
| 72 | +### Testing Configuration |
| 73 | + |
| 74 | +| Variable | Default | Description | |
| 75 | +|----------|---------|-------------| |
| 76 | +| `cifmw_federation_run_oidc_auth_tests` | `true` | Run comprehensive OIDC auth tests | |
| 77 | + |
| 78 | +## Task Files |
| 79 | + |
| 80 | +### Main Tasks |
| 81 | + |
| 82 | +- `hook_pre_deploy.yml` - Deploys Keycloak before OpenStack |
| 83 | +- `hook_post_deploy.yml` - Configures federation after OpenStack deployment |
| 84 | +- `hook_controlplane_config.yml` - Adds federation config to control plane |
| 85 | + |
| 86 | +### Setup Tasks |
| 87 | + |
| 88 | +- `run_keycloak_setup.yml` - Deploy Keycloak operator and instance |
| 89 | +- `run_keycloak_realm_setup.yml` - Configure Keycloak realm, users, and client |
| 90 | +- `run_keycloak_client_setup.yml` - Enable advanced client features (Service Accounts, Device Auth) |
| 91 | +- `run_openstack_setup.yml` - Configure Keystone IdP and mappings |
| 92 | +- `run_openstack_auth_setup.yml` - Deploy authentication scripts to openstackclient pod |
| 93 | + |
| 94 | +### Test Tasks |
| 95 | + |
| 96 | +- `run_openstack_auth_test.yml` - Basic v3oidcpassword authentication test |
| 97 | +- `run_openstack_oidc_auth_tests.yml` - Comprehensive OIDC authentication test suite |
| 98 | + |
| 99 | +## Authentication Scripts |
| 100 | + |
| 101 | +The following scripts are deployed to `/home/cloud-admin/` in the openstackclient pod: |
| 102 | + |
| 103 | +| Script | Description | |
| 104 | +|--------|-------------| |
| 105 | +| `get-token.sh <user>` | Get token using v3oidcpassword | |
| 106 | +| `oidc-clientcredentials.sh` | Configure v3oidcclientcredentials auth | |
| 107 | +| `oidc-accesstoken.sh <token>` | Configure v3oidcaccesstoken auth | |
| 108 | +| `oidc-authcode.sh <code>` | Configure v3oidcauthcode auth | |
| 109 | +| `get-keycloak-token.sh` | Helper to obtain tokens from Keycloak | |
| 110 | + |
| 111 | +### Example Usage |
| 112 | + |
| 113 | +```bash |
| 114 | +# v3oidcpassword - Password flow |
| 115 | +kubectl exec -n openstack openstackclient -- bash -c \ |
| 116 | + 'source /home/cloud-admin/kctestuser1 && openstack token issue' |
| 117 | + |
| 118 | +# v3oidcclientcredentials - Client Credentials flow |
| 119 | +kubectl exec -n openstack openstackclient -- bash -c \ |
| 120 | + 'source /home/cloud-admin/oidc-clientcredentials.sh && openstack token issue' |
| 121 | + |
| 122 | +# v3oidcaccesstoken - Access Token flow |
| 123 | +ACCESS_TOKEN=$(/home/cloud-admin/get-keycloak-token.sh access_token kctestuser1 nomoresecrets1) |
| 124 | +kubectl exec -n openstack openstackclient -- bash -c \ |
| 125 | + "source /home/cloud-admin/oidc-accesstoken.sh '$ACCESS_TOKEN' && openstack token issue" |
| 126 | + |
| 127 | +# v3oidcauthcode - Authorization Code flow |
| 128 | +AUTH_CODE=$(/home/cloud-admin/get-keycloak-token.sh auth_code kctestuser1 nomoresecrets1) |
| 129 | +kubectl exec -n openstack openstackclient -- bash -c \ |
| 130 | + "source /home/cloud-admin/oidc-authcode.sh '$AUTH_CODE' && openstack token issue" |
| 131 | +``` |
| 132 | + |
| 133 | +## Test Execution |
| 134 | + |
| 135 | +The comprehensive OIDC authentication tests are automatically run during the `hook_post_deploy.yml` phase when `cifmw_federation_run_oidc_auth_tests` is `true` (default). |
| 136 | + |
| 137 | +To run the tests manually: |
| 138 | + |
| 139 | +```yaml |
| 140 | +- name: Run OIDC authentication tests |
| 141 | + ansible.builtin.include_role: |
| 142 | + name: federation |
| 143 | + tasks_from: run_openstack_oidc_auth_tests.yml |
| 144 | +``` |
| 145 | +
|
| 146 | +## Notes |
| 147 | +
|
| 148 | +- **Device Authorization Flow**: The `v3oidcdeviceauthz` plugin requires keystoneauth1 with Python 3.10+ support. OSP18 ships with Python 3.9 and does not include this plugin. |
| 149 | +- **Multirealm**: CLI-based OIDC authentication testing only works in single realm mode. Multirealm federation is supported for Horizon-based authentication. |
| 150 | +- **Keycloak Client**: The role automatically enables Service Accounts and Device Authorization on the Keycloak client to support all authentication methods. |
0 commit comments