RtSecurityContext
Namespace: Meshmakers.Octo.Runtime.Contracts
Identity of the caller a repository session acts for. Carried on IOctoSession so the engine can stamp RtEntity.RtCreatedBy and, in later stages, enforce data-level permissions on reads and writes.
public record RtSecurityContext : IEquatable<RtSecurityContext>
Inheritance Object → RtSecurityContext
Implements IEquatable<RtSecurityContext>
Fields
System
The system context: internal callers (pipelines, blueprint apply, migrations, background jobs). System sessions stamp no creator and bypass data-level permission checks.
public static RtSecurityContext System;
Properties
SubjectId
Subject id of the caller (user sub claim or client id); null for the system context.
public string SubjectId { get; set; }
Property Value
Roles
Role names of the caller, as issued in the token's role claims.
public IReadOnlyCollection<string> Roles { get; set; }
Property Value
IsSystem
True for internal callers acting without an end-user identity.
public bool IsSystem { get; set; }
Property Value
PrincipalKind
What kind of principal the caller is (signed-in user or client-credentials service). The service that
opens the session derives it from the token; RtPrincipalKind.Unknown when it does not know.
Only types with a writeAccess block look at it, and they refuse RtPrincipalKind.Unknown
(fail closed); unrestricted types ignore it.
public RtPrincipalKind PrincipalKind { get; set; }
Property Value
WriteChannel
The trusted in-process write channel of the session, e.g. System.Ai/KnowledgeTools, matched
against the channels of a type's writeAccess block. Set only by service code that opens a session
for its own guarded write path (RtSecurityContext.WithWriteChannel(String)); it must never be taken from a token, a header
or any other caller input. null for an ordinary session.
public string WriteChannel { get; set; }
Property Value
Constructors
RtSecurityContext()
public RtSecurityContext()
Methods
ForUser(String, IEnumerable<String>)
Creates a context for an authenticated end user or client principal.
public static RtSecurityContext ForUser(string subjectId, IEnumerable<string> roles)
Parameters
subjectId String
Subject id of the caller
roles IEnumerable<String>
Role names from the caller's token
Returns
ForUser(String, IEnumerable<String>, RtPrincipalKind)
Creates a context for an authenticated end user or client principal whose kind is known.
public static RtSecurityContext ForUser(string subjectId, IEnumerable<string> roles, RtPrincipalKind principalKind)
Parameters
subjectId String
Subject id of the caller
roles IEnumerable<String>
Role names from the caller's token
principalKind RtPrincipalKind
Whether the caller is a signed-in user or a client-credentials service
Returns
WithWriteChannel(String)
Returns a copy of this context that writes on the trusted in-process channel writeChannel
. Call it only from service code that opens the session for its own guarded write path; never with a
value from caller input.
public RtSecurityContext WithWriteChannel(string writeChannel)
Parameters
writeChannel String
The channel, <namespace>/<name>