|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
IAuthorizer that authenticates via a signed Context::token. More...
#include <session_auth.hpp>
Public Types | |
| using | Policy |
| Optional per-request policy over verified claims. | |
Public Member Functions | |
| SigningAuthorizer (std::string secret, MacFunction mac=hmacSha256, Clock clock=systemClockMs, Policy policy={}) | |
| Constructs the authorizer. | |
| bool | authorize (const Context &ctx, std::string_view modelType, std::string_view actionType) const override |
Allows the call iff ctx carries a valid token the policy admits. | |
| std::optional< std::string > | authenticate (const Context &ctx) const override |
| Returns the verified principal so the server can make it authoritative. | |
| Admission | admit (const Context &ctx, std::string_view modelType, std::string_view actionType) const override |
Verifies ctx's token once, then asks authenticate and authorize as the default admit does. | |
| Public Member Functions inherited from morph::session::IAuthorizer | |
| virtual bool | authorizeInstance (const Context &ctx, std::string_view modelType, std::string_view actionType, std::uint64_t modelId, std::string_view ownerPrincipal) const |
| Optional per-**instance** authorization hook — the multi-tenant gate. | |
| virtual bool | authorizeRegister (const Context &ctx, std::string_view modelType) const |
| Optional gate on model creation — bounds who may create an instance. | |
IAuthorizer that authenticates via a signed Context::token.
authorize returns true only for a token with a valid signature and unexpired claims (and, if a policy is supplied, one the policy admits). authenticate returns the verified principal so RemoteServer makes it authoritative. Install it on the server:
Definition at line 523 of file session_auth.hpp.
Optional per-request policy over verified claims.
Receives the verified token plus the target ids; return false to deny. The action id is empty for the instances, schemas and deregister envelopes, and the model type id is empty for deregister – see IAuthorizer::authorize's own doc comment for why, and handle those cases explicitly rather than letting them reach a default arm. The default (empty) admits any validly-signed, unexpired token.
Definition at line 533 of file session_auth.hpp.
|
inlineexplicit |
Constructs the authorizer.
| secret | Shared secret used to verify tokens. |
| mac | MAC primitive; defaults to hmacSha256. Forwarded into this authorizer's TokenVerifier and invoked for its whole lifetime, so anything the callable refers to must outlive it. |
| clock | Time source (ms since epoch) for expiry; defaults to system time. Stored and invoked for this authorizer's whole lifetime, so anything the callable refers to must outlive it. |
| policy | Optional per-request policy over verified claims. Stored and invoked on the same terms as clock. |
Definition at line 567 of file session_auth.hpp.
|
inlinenodiscardoverridevirtual |
Allows the call iff ctx carries a valid token the policy admits.
| ctx | Per-call session (its token is verified). |
| modelType | Target model type id (passed to the policy). |
| actionType | Target action type id (passed to the policy). |
Implements morph::session::IAuthorizer.
Definition at line 577 of file session_auth.hpp.
|
inlinenodiscardoverridevirtual |
Returns the verified principal so the server can make it authoritative.
| ctx | Per-call session (its token is verified). |
Reimplemented from morph::session::IAuthorizer.
Definition at line 590 of file session_auth.hpp.
|
inlinenodiscardoverridevirtual |
Verifies ctx's token once, then asks authenticate and authorize as the default admit does.
Both are still called through the vtable, so a subclass that overrides either keeps its own decision: a carve-out that admits a call without a token, or a rule that refuses more than the token does. While this call runs, SigningAuthorizer's own authenticate and authorize answer from the one verification instead of verifying again, so a token is judged against one clock reading. Nothing outlives the call.
| ctx | Per-call session (its token is verified). |
| modelType | Target model type id (passed to authorize). |
| actionType | Target action type id (passed to authorize). |
Reimplemented from morph::session::IAuthorizer.
Definition at line 612 of file session_auth.hpp.