Class: Safire::Protocols::UdapSignedMetadataValidator Private
- Inherits:
-
Object
- Object
- Safire::Protocols::UdapSignedMetadataValidator
- Includes:
- URIValidation
- Defined in:
- lib/safire/protocols/udap_signed_metadata_validator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Validates the signed_metadata JWT included in a UDAP server discovery response
per UDAP Security STU2 §Signed Metadata Elements.
This is an internal class used by Udap and UdapMetadata. Do not instantiate it directly.
Constant Summary collapse
- ALLOWED_ALGORITHMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[RS256].freeze
- MAX_VALIDITY_SECONDS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
365 * 24 * 3600
- REQUIRED_ENDPOINT_CLAIMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[token_endpoint registration_endpoint].freeze
- ENDPOINT_CLAIMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
(REQUIRED_ENDPOINT_CLAIMS + %w[authorization_endpoint]).freeze
Instance Method Summary collapse
-
#initialize(signed_metadata_jwt, unsigned_metadata) ⇒ UdapSignedMetadataValidator
constructor
private
A new instance of UdapSignedMetadataValidator.
-
#signed_endpoint_claims(base_url:, trusted_anchors: [], crls: [], revocation_checker: nil, verify_chain: true) ⇒ Hash?
private
Validates the signed metadata JWT and returns the signed endpoint claims to merge over the unsigned discovery values.
-
#valid?(base_url:, trusted_anchors: [], crls: [], revocation_checker: nil, verify_chain: true) ⇒ Boolean
private
Returns
truewhen #signed_endpoint_claims succeeds.
Constructor Details
#initialize(signed_metadata_jwt, unsigned_metadata) ⇒ UdapSignedMetadataValidator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of UdapSignedMetadataValidator.
25 26 27 28 |
# File 'lib/safire/protocols/udap_signed_metadata_validator.rb', line 25 def initialize(, ) @jwt = @unsigned = .respond_to?(:to_h) ? .to_h.stringify_keys : {} end |
Instance Method Details
#signed_endpoint_claims(base_url:, trusted_anchors: [], crls: [], revocation_checker: nil, verify_chain: true) ⇒ Hash?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validates the signed metadata JWT and returns the signed endpoint claims to merge over the unsigned discovery values.
Each validation failure is logged as a warning without raising, except for
malformed certificate DER in x5c, which raises Errors::CertificateError
because the input is unparseable rather than merely non-conformant.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/safire/protocols/udap_signed_metadata_validator.rb', line 44 def signed_endpoint_claims(base_url:, trusted_anchors: [], crls: [], revocation_checker: nil, verify_chain: true) decoded = decode_and_validate_jwt return unless decoded payload, header = decoded leaf_cert = parse_leaf_cert(header['x5c'].first) trust_policy = { trusted_anchors:, crls:, revocation_checker:, verify_chain: } return unless signature_and_chain_valid?(header, leaf_cert, trust_policy) return unless claims_valid?(payload, base_url, leaf_cert) extract_endpoint_claims(payload) end |
#valid?(base_url:, trusted_anchors: [], crls: [], revocation_checker: nil, verify_chain: true) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true when #signed_endpoint_claims succeeds.
66 67 68 |
# File 'lib/safire/protocols/udap_signed_metadata_validator.rb', line 66 def valid?(base_url:, trusted_anchors: [], crls: [], revocation_checker: nil, verify_chain: true) signed_endpoint_claims(base_url:, trusted_anchors:, crls:, revocation_checker:, verify_chain:).present? end |