Principal.h header
#include <ew/core/Principal.h>
Namespace ew::core
Principal class
class ew::core::Principal
Who is asking, and what they can be shown.
Deliberately a value rather than an interface: a policy question must be answerable without reaching back into UI or session state, so libs/core can ask it.
Members
ew::core::policy::Principal::Principal()=default
Creates the local user – the default asker, allowed everything.
ew::core::policy::Principal::Principal(PrincipalKind kind)
Creates a principal of kind.
PrincipalKind ew::core::policy::Principal::kind() const
What sort of asker this is.
const std::set< QString > & ew::core::policy::Principal::audiences() const
The audiences a Reader sees through. Empty for every other kind, and for a reader who has chosen no audience – which is the unrestricted view, not the blind one.
static Principal ew::core::policy::Principal::reader(std::set< QString > audiences)
Creates a reader restricted to audiences (the ids they may see content through).
Enumerations
enum class PrincipalKind { LocalUser, Ai, Plugin, Reader }
Who is asking. NOT an account – the product has none and must keep working without any.
These are the four askers the product already distinguishes today, discovered by reading what its existing checks are keyed on rather than invented: aiExcluded withholds content from AI features, audience visibility hides it from readers, and plugins run third-party code. Naming them makes three ad-hoc policies into one question.
Functions
std::optional< PrincipalKind > ew::core::policy::principalKindFromToken(QStringView token)
Parses a principal kind from its token; std::nullopt if unrecognized.
QString ew::core::policy::toToken(PrincipalKind kind)
Returns the stable serialization token for kind.