Skip to main content

Crate oidfed_metadata_policy

Crate oidfed_metadata_policy 

Source
Expand description

§OpenID Federation Metadata Policy

This crate implements metadata policy operations for OpenID Federation as specified in OpenID Federation 1.0.

It provides functionality to:

  • Merge metadata policies from Trust Anchors and Intermediate Authorities
  • Apply metadata policies to entity metadata
  • Resolve metadata according to policy constraints

§Example

use serde_json::json;

let metadata = json!({
    "openid_relying_party": {
        "application_type": "web",
        "grant_types": ["authorization_code", "implicit"]
    }
});

let full_policy = json!({
    "metadata_policy": {},
    "metadata": {
        "openid_relying_party": {
            "application_type": "native"
        }
    }
});

let result = oidfed_metadata_policy::apply_policy_document_on_metadata(
    full_policy.as_object().unwrap(),
    metadata.as_object().unwrap()
).unwrap();

assert_eq!(result["openid_relying_party"]["application_type"], "native");
assert_eq!(result["openid_relying_party"]["grant_types"], json!(["authorization_code", "implicit"]));

Functions§

apply_policy_document_on_metadata
Applies a full policy document on the raw metadata of a given entity.
apply_policy_on_metadata
Applies a metadata policy to metadata for a single entity type.
check_equal
Checks if two JSON values are equal using unordered set comparison.
get_hashset_from_only_names
Extracts only the names (keys) from a JSON value into a HashSet.
get_hashset_from_values
Converts a JSON value into a HashSet of values.
get_ordered_array
Returns an ordered array by merging items from Trust Anchor and Intermediate Authority.
intersection_of
Computes the intersection of two JSON values as sets.
is_subset_of
Checks if the first value is a subset of the second value.
is_superset_of
Checks if the first value is a superset of the second value.
merge_one_type_policy
Merges metadata policies for a single entity type from Trust Anchor and Intermediate Authority.
merge_policies
Merges a Trust Anchor’s (TA) policy on top of an Intermediate Authority’s (IA) policy according to the OpenID Federation policy merging rules.
resolve_metadata_policy
Resolves metadata according to a given policy.