pygamlastan.profiles¶
Web Browser SSO for both the SP and IdP sides. See the
Service Provider integration and Identity Provider integration guides.
Errors raise pygamlastan.SamlProfileError.
Service Provider¶
- class pygamlastan.profiles.AuthnRequestOptions(sp_entity_id, acs_url=None, acs_index=None, protocol_binding=None, force_authn=None, is_passive=None, name_id_format=None, allow_create=True, sp_name_qualifier=None, authn_context_class_refs=None, authn_context_comparison=None, provider_name=None, destination=None, proxy_count=None, requester_ids=None, attribute_consuming_service_index=None, extensions=None)¶
Inputs to
create_authn_request().authn_context_comparisonis one of"exact","minimum","maximum","better".
- pygamlastan.profiles.create_authn_request(options: AuthnRequestOptions) pygamlastan.core.AuthnRequest¶
Build an (unsigned)
AuthnRequestfromoptions.
- pygamlastan.profiles.process_response(response, config, sp_entity_id, acs_url, expected_idp_entity_id, expected_request_id=None, verified_signed_ids=None, now=None, replay_cache=None, persistent_id_store=None, unsafe_no_replay_cache=False, unsafe_no_persistent_id_store=False) AuthnResult¶
Validate a
pygamlastan.core.Responseand extract the identity. Passverified_signed_idsfrom a trustedpygamlastan.crypto.SamlVerifierto enforce signed assertions, and areplay_cacheto detect assertion replay.replay_cacheis required by default; passunsafe_no_replay_cache=Trueonly for legacy unsafe processing. If persistent NameID uniqueness is enabled, persistent NameID responses also requirepersistent_id_storeunless explicitly waived. Raisespygamlastan.SamlProfileErroron any validation failure.
- pygamlastan.profiles.process_response_verified(response_xml, verifier, config, sp_entity_id, acs_url, expected_idp_entity_id, expected_request_id=None, now=None, replay_cache=None, persistent_id_store=None, unsafe_no_replay_cache=False, unsafe_no_persistent_id_store=False) AuthnResult¶
The safe, preferred SP entry point. It performs XML-DSig verification with
verifierover the exactresponse_xmlbytes and feeds only the cryptographically verified reference IDs into validation - so the caller cannot assert “this was signed” without real crypto, closing the auth-bypass-by-mis-integration gap that hand-passingverified_signed_idstoprocess_response()leaves open. Raisespygamlastan.SamlCryptoErrorif the signature is missing or invalid, andpygamlastan.SamlProfileErroron any validation failure.replay_cacheis required by default (seeprocess_response()for theunsafe_*waivers and thepersistent_id_storerequirement).
Identity Provider¶
- pygamlastan.profiles.process_authn_request(request, sp_metadata=None, unsafe_allow_missing_metadata=False) ProcessedAuthnRequest¶
Distil an incoming
AuthnRequestinto the fields needed to build a response.sp_metadata(apygamlastan.metadata.EntityDescriptor) is required by default so the ACS endpoint is resolved against trusted metadata. Passunsafe_allow_missing_metadata=Trueonly for legacy unsafe processing.
- class pygamlastan.profiles.ProcessedAuthnRequest¶
request_id,sp_entity_id,acs_url,acs_binding,force_authn,is_passive,requested_name_id_format,allow_create,requested_authn_context_class_refs,attribute_consuming_service_index.
- class pygamlastan.profiles.ResponseOptions(idp_entity_id, sp_entity_id, acs_url, assertion_lifetime_seconds=300, in_response_to=None, session_index=None, session_not_on_or_after=None, authn_context_class_ref=None, client_address=None, attributes=None)¶
Inputs to
create_response().attributesis a list ofpygamlastan.core.Attribute.
- pygamlastan.profiles.create_response(options: ResponseOptions, principal_name_id, now=None) pygamlastan.core.Response¶
Build a
Responsecarrying an assertion forprincipal_name_id(apygamlastan.core.NameId).
- pygamlastan.profiles.create_unsolicited_response(idp_entity_id, sp_entity_id, acs_url, principal_name_id, attributes=None, authn_context_class_ref=None, assertion_lifetime_seconds=300, session_index=None, session_not_on_or_after=None, client_address=None, now=None) pygamlastan.core.Response¶
Build an IdP-initiated (unsolicited)
Responsewith noInResponseTo.