Skip to content

Commit a07c602

Browse files
Merge pull request #98 from leifj/signed-assertions
make sign_assertion and sign_response configurable
2 parents fe93173 + 9c0aa53 commit a07c602

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

doc/README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ provider will be preserved, and when using a OAuth or OpenID Connect backend, th
221221
**Example**
222222

223223
config:
224-
config: [...]
224+
idp_config: [...]
225225
acr_mapping:
226226
"": default-LoA
227227
"https://accounts.google.com": LoA1
@@ -237,7 +237,7 @@ with entity id `"sp-entity-id1"`:
237237

238238
```yaml
239239
config:
240-
config: [...]
240+
idp_config: [...]
241241
custom_attribute_release:
242242
idp-entity-id1
243243
sp-entity-id1:
@@ -249,11 +249,34 @@ as the key in the dict. For instance in order to exclude givenName for any sp or
249249
250250
```yaml
251251
config:
252-
config: [...]
252+
idp_config: [...]
253253
custom_attribute_release:
254254
"default":
255255
"":
256256
exclude: ["givenName"]
257+
258+
#### Policy
259+
260+
Some settings related to how a SAML response is formed can be overriden on a per-instance or a per-SP
261+
basis. This example summarizes the most common settings (hopefully self-explanatory) with their defaults:
262+
263+
```yaml
264+
config:
265+
idp_config:
266+
service:
267+
idp:
268+
policy:
269+
default:
270+
sign_response: True
271+
sign_assertion: False
272+
sign_alg: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
273+
digest_alg: "http://www.w3.org/2001/04/xmlenc#sha256"
274+
<sp entityID>:
275+
...
276+
277+
Overrides per SP entityID is possible by using the entityID as a key instead of the "default" key
278+
in the yaml structure. The most specific key takes presedence. If no policy overrides are provided
279+
the defaults above are used.
257280
258281
259282
#### Backend
@@ -267,7 +290,7 @@ The SAML backend can indicate which *Name ID* format it wants by specifying the
267290

268291
```yaml
269292
config:
270-
config:
293+
sp_config:
271294
service:
272295
sp:
273296
name_id_format: urn:oasis:names:tc:SAML:2.0:nameid-format:transient
@@ -279,7 +302,7 @@ parameter `disco_srv`, must be specified if the metadata given to the backend mo
279302

280303
```yaml
281304
config:
282-
config: [...]
305+
sp_config: [...]
283306
disco_srv: http://disco.example.com
284307
```
285308

src/satosa/frontends/saml2.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,28 @@ def _handle_authn_response(self, context, internal_response, idp):
287287

288288
satosa_logging(logger, logging.DEBUG, "returning attributes %s" % json.dumps(ava), context.state)
289289

290+
# assume saml2int defaults: sign response but not the assertion & allow override
291+
sign_assertion = False
292+
try:
293+
sign_assertion = self.config['idp_config']['service']['idp']['policy']['default']['sign_assertion']
294+
sign_assertion = self.config['idp_config']['service']['idp']['policy'][resp_args['sp_entity_id']]['sign_assertion']
295+
except (KeyError, AttributeError, ValueError):
296+
pass
297+
298+
sign_response = True
299+
try:
300+
sign_response = self.config['idp_config']['service']['idp']['policy']['default']['sign_response']
301+
sign_response = self.config['idp_config']['service']['idp']['policy'][resp_args['sp_entity_id']]['sign_response']
302+
except (KeyError, AttributeError, ValueError):
303+
pass
304+
290305
# Construct arguments for method create_authn_response on IdP Server instance
291306
args = {
292307
'identity' : ava,
293308
'name_id' : name_id,
294309
'authn' : auth_info,
295-
'sign_response' : True
310+
'sign_response' : sign_response,
311+
'sign_assertion': sign_assertion
296312
}
297313

298314
# Add the SP details

0 commit comments

Comments
 (0)