|
| 1 | +# Configuration |
| 2 | + |
| 3 | +This guide summarizes key configuration topics for the OIDC module. |
| 4 | +It complements the inline comments in `config/module_oidc.php`. |
| 5 | + |
| 6 | +- Caching protocol artifacts |
| 7 | +- Relying Party (RP) administration UI |
| 8 | +- Cron integration |
| 9 | +- Endpoint locations and well-known URLs |
| 10 | +- Key rollover |
| 11 | +- Apache Authorization header note |
| 12 | +- Private scopes |
| 13 | +- Attribute translation |
| 14 | +- Auth Proc filters (OIDC) |
| 15 | +- Client registration permissions |
| 16 | + |
| 17 | +## Caching protocol artifacts |
| 18 | + |
| 19 | +The configured database is the primary storage for protocol artifacts: |
| 20 | +access tokens, authorization codes, refresh tokens, clients, and user |
| 21 | +records. In production, you should also configure a cache in front of the |
| 22 | +DB to improve performance during traffic spikes. |
| 23 | + |
| 24 | +Caching uses Symfony Cache, so any compatible adapter can be used. See the |
| 25 | +`module_oidc.php` configuration file for adapter selection and parameters. |
| 26 | + |
| 27 | +## Relying Party (RP) administration |
| 28 | + |
| 29 | +The module provides a UI to manage clients (create, read, update, delete). |
| 30 | +After you create the database schema, go to the SimpleSAMLphp admin area: |
| 31 | + |
| 32 | +- OIDC > Client Registry |
| 33 | + |
| 34 | +Notes: |
| 35 | +- Clients can be public or confidential. |
| 36 | +- Public clients using Authorization Code flow must send PKCE parameters. |
| 37 | +- Client ID and secret are generated; use the "show" button to reveal. |
| 38 | + |
| 39 | +## Cron integration |
| 40 | + |
| 41 | +Enable and configure the SimpleSAMLphp cron module to purge expired tokens: |
| 42 | + |
| 43 | +- https://simplesamlphp.org/docs/stable/cron/cron.html |
| 44 | + |
| 45 | +## Endpoint locations and well-known URLs |
| 46 | + |
| 47 | +After deployment, visit the SimpleSAMLphp admin area: |
| 48 | + |
| 49 | +- OIDC > Protocol / Federation Settings |
| 50 | + |
| 51 | +There you can see discovery URLs. Typical discovery endpoints are: |
| 52 | + |
| 53 | +- OpenID Connect Discovery: |
| 54 | + https://yourserver/simplesaml/module.php/oidc/.well-known/openid-configuration |
| 55 | +- OpenID Federation configuration: |
| 56 | + https://yourserver/simplesaml/module.php/oidc/.well-known/openid-federation |
| 57 | + |
| 58 | +You may publish these as ".well-known" URLs at the web root using your |
| 59 | +web server. For example, for `openid-configuration`: |
| 60 | + |
| 61 | +nginx: |
| 62 | + |
| 63 | +```nginx |
| 64 | +location = /.well-known/openid-configuration { |
| 65 | + rewrite ^(.*)$ /simplesaml/module.php/oidc/.well-known/openid-configuration break; |
| 66 | + proxy_pass https://localhost; |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +Apache: |
| 71 | + |
| 72 | +```apache |
| 73 | +RewriteEngine On |
| 74 | +RewriteRule ^/.well-known/openid-configuration(.*) \ |
| 75 | + /simplesaml/module.php/oidc/.well-known/openid-configuration$1 [PT] |
| 76 | +``` |
| 77 | + |
| 78 | +## Key rollover |
| 79 | + |
| 80 | +You can configure an additional key pair to publish via JWKS endpoints or |
| 81 | +properties. This lets RPs pre-fetch the new public key before you switch |
| 82 | +signing to the new private key. Once RPs have cached the new JWKS, you can |
| 83 | +perform the key switch. |
| 84 | + |
| 85 | +## Apache Authorization header note |
| 86 | + |
| 87 | +Apache may strip the `Authorization` header (Bearer) from requests, a known |
| 88 | +issue: https://github.com/symfony/symfony/issues/19693 |
| 89 | + |
| 90 | +Although the module includes a fallback, it has performance implications. |
| 91 | +Configure Apache to preserve the header using one of these snippets: |
| 92 | + |
| 93 | +```apache |
| 94 | +RewriteEngine On |
| 95 | +RewriteCond %{HTTP:Authorization} .+ |
| 96 | +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] |
| 97 | +``` |
| 98 | + |
| 99 | +or |
| 100 | + |
| 101 | +```apache |
| 102 | +SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 |
| 103 | +``` |
| 104 | + |
| 105 | +If not set, you will see warnings about this in the logs. |
| 106 | + |
| 107 | +## Private scopes |
| 108 | + |
| 109 | +The module supports the standard scopes: `openid`, `email`, `address`, |
| 110 | +`phone`, and `profile`. You can add private scopes in `module_oidc.php`: |
| 111 | + |
| 112 | +```php |
| 113 | +<?php |
| 114 | + |
| 115 | +$config = [ |
| 116 | + \SimpleSAML\Module\oidc\ModuleConfig::OPTION_AUTH_CUSTOM_SCOPES => [ |
| 117 | + 'private' => [ |
| 118 | + 'description' => 'private scope', |
| 119 | + 'claim_name_prefix' => '', |
| 120 | + 'are_multiple_claim_values_allowed' => false, |
| 121 | + 'attributes' => ['national_document_id'], |
| 122 | + ], |
| 123 | + ], |
| 124 | +]; |
| 125 | +``` |
| 126 | + |
| 127 | +## Attribute translation |
| 128 | + |
| 129 | +Default SAML-to-OIDC claim mapping follows the REFEDS guidance: |
| 130 | +https://wiki.refeds.org/display/GROUPS/Mapping+SAML+attributes+to+OIDC+Claims |
| 131 | + |
| 132 | +You can change or extend this mapping in `module_oidc.php`. Example: |
| 133 | + |
| 134 | +```php |
| 135 | +<?php |
| 136 | + |
| 137 | +$config = [ |
| 138 | + \SimpleSAML\Module\oidc\ModuleConfig::OPTION_AUTH_SAML_TO_OIDC_TRANSLATE_TABLE => [ |
| 139 | + // Overwrite default mapping |
| 140 | + 'sub' => [ |
| 141 | + 'uid', |
| 142 | + 'eduPersonPrincipalName', |
| 143 | + 'eduPersonTargetedID', |
| 144 | + 'eduPersonUniqueId', |
| 145 | + ], |
| 146 | + // Remove default mapping by setting an empty array |
| 147 | + 'family_name' => [], |
| 148 | + |
| 149 | + // New claim created from SAML attribute |
| 150 | + 'national_document_id' => [ |
| 151 | + 'schacPersonalUniqueId', |
| 152 | + ], |
| 153 | + ], |
| 154 | +]; |
| 155 | +``` |
| 156 | + |
| 157 | +## Auth Proc filters (OIDC) |
| 158 | + |
| 159 | +Standard SAML Auth Proc Filters do not run during OIDC authN because not |
| 160 | +all SAML entities are present (like a Service Provider). Instead, use the |
| 161 | +`authproc.oidc` configuration option to define filters specific to OIDC. |
| 162 | + |
| 163 | +The OIDC authN state does not include all keys present in SAML authN. |
| 164 | +Available SAML-like keys include: |
| 165 | + |
| 166 | +- ['Attributes'] |
| 167 | +- ['Authority'] |
| 168 | +- ['AuthnInstant'] |
| 169 | +- ['Expire'] |
| 170 | + |
| 171 | +Source and Destination entity IDs correspond to OP issuer and Client ID: |
| 172 | + |
| 173 | +- ['Source']['entityid'] → OP issuer ID |
| 174 | +- ['Destination']['entityid'] → RP (client) ID |
| 175 | + |
| 176 | +Additional OIDC data in the state: |
| 177 | + |
| 178 | +- ['Oidc']['OpenIdProviderMetadata'] |
| 179 | +- ['Oidc']['RelyingPartyMetadata'] |
| 180 | +- ['Oidc']['AuthorizationRequestParameters'] |
| 181 | + |
| 182 | +Example filter configuration: |
| 183 | + |
| 184 | +```php |
| 185 | +<?php |
| 186 | + |
| 187 | +$config = [ |
| 188 | + \SimpleSAML\Module\oidc\ModuleConfig::OPTION_AUTH_PROCESSING_FILTERS => [ |
| 189 | + 50 => [ |
| 190 | + 'class' => 'core:AttributeAdd', |
| 191 | + 'groups' => ['users', 'members'], |
| 192 | + ], |
| 193 | + ], |
| 194 | +]; |
| 195 | +``` |
| 196 | + |
| 197 | +## Client registration permissions |
| 198 | + |
| 199 | +You can allow users to register their own clients. Control this via the |
| 200 | +`permissions` setting in `module_oidc.php`. |
| 201 | + |
| 202 | +Permissions expose functionality to specific users. In the following |
| 203 | +example, a user's `eduPersonEntitlement` is examined. To perform an action |
| 204 | +requiring the `client` permission (register/edit/delete a client) the user |
| 205 | +needs one of the listed entitlements. |
| 206 | + |
| 207 | +```php |
| 208 | +<?php |
| 209 | + |
| 210 | +$config = [ |
| 211 | + \SimpleSAML\Module\oidc\ModuleConfig::OPTION_ADMIN_UI_PERMISSIONS => [ |
| 212 | + 'attribute' => 'eduPersonEntitlement', |
| 213 | + 'client' => ['urn:example:oidc:manage:client'], |
| 214 | + ], |
| 215 | +]; |
| 216 | +``` |
| 217 | + |
| 218 | +Users can visit the following link for administration: |
| 219 | + |
| 220 | +- https://example.com/simplesaml/module.php/oidc/clients/ |
0 commit comments