12 std::unordered_map<std::string, std::shared_ptr<ccf::AuthnPolicy>>;
21 ccf::user_cert_auth_policy);
25 ccf::member_cert_auth_policy);
29 ccf::any_cert_auth_policy);
36 ccf::user_cose_sign1_auth_policy);
45 static inline std::shared_ptr<ccf::AuthnPolicy> get_policy_by_name(
46 const std::string& name)
48 auto& policies = auth_policies_by_name();
49 auto it = policies.find(name);
50 if (it == policies.end())
59 static inline constexpr char const* get_policy_name_from_ident(
const T*)
61 if constexpr (std::is_same_v<T, ccf::UserCertAuthnIdentity>)
65 else if constexpr (std::is_same_v<T, ccf::MemberCertAuthnIdentity>)
69 else if constexpr (std::is_same_v<T, ccf::AnyCertAuthnIdentity>)
73 else if constexpr (std::is_same_v<T, ccf::JwtAuthnIdentity>)
77 else if constexpr (std::is_same_v<T, ccf::UserCOSESign1AuthnIdentity>)
81 else if constexpr (std::is_same_v<T, ccf::MemberCOSESign1AuthnIdentity>)
85 else if constexpr (std::is_same_v<T, ccf::EmptyAuthnIdentity>)
95 static inline void instantiate_authn_policies(
98 for (
const auto& policy_desc : endpoint.properties.authn_policies)
100 if (policy_desc.is_string())
102 const auto policy_name = policy_desc.get<std::string>();
103 auto policy = get_policy_by_name(policy_name);
104 if (policy ==
nullptr)
106 throw std::logic_error(
107 fmt::format(
"Unknown auth policy: {}", policy_name));
113 if (policy_desc.is_object())
115 const auto it = policy_desc.find(
"all_of");
116 if (it != policy_desc.end())
118 if (it.value().is_array())
120 std::vector<std::shared_ptr<ccf::AuthnPolicy>>
121 constituent_policies;
122 for (
const auto& val : it.value())
124 if (!val.is_string())
126 constituent_policies.clear();
130 const auto policy_name = val.get<std::string>();
131 auto policy = get_policy_by_name(policy_name);
132 if (policy ==
nullptr)
134 throw std::logic_error(
135 fmt::format(
"Unknown auth policy: {}", policy_name));
137 constituent_policies.push_back(std::move(policy));
140 if (!constituent_policies.empty())
143 std::make_shared<ccf::AllOfAuthnPolicy>(
144 constituent_policies));
152 throw std::logic_error(fmt::format(
153 "Unsupported auth policy. Policies must be either a string, or an "
154 "object containing an \"all_of\" key with list-of-strings value. "
155 "Unsupported value: {}",
156 policy_desc.dump()));
static constexpr auto SECURITY_SCHEME_NAME
Definition cert_auth.h:130
static constexpr auto SECURITY_SCHEME_NAME
Definition empty_auth.h:17
static constexpr auto SECURITY_SCHEME_NAME
Definition jwt_auth.h:34
static constexpr auto SECURITY_SCHEME_NAME
Definition cose_auth.h:121
static constexpr auto SECURITY_SCHEME_NAME
Definition cert_auth.h:69
static constexpr auto SECURITY_SCHEME_NAME
Definition cose_auth.h:190
static constexpr auto SECURITY_SCHEME_NAME
Definition cert_auth.h:35
Definition app_interface.h:14
std::unordered_map< std::string, std::shared_ptr< ccf::AuthnPolicy > > NamedAuthPolicies
Definition js.h:12
Definition endpoint.h:198
AuthnPolicies authn_policies
Definition endpoint.h:231