PrincipalStore

org.llm4s.rag.permissions.PrincipalStore

Storage for principal ID mappings.

Maps external identifiers (email addresses, group names) to internal integer IDs that are efficient for database queries.

Design:

  • User IDs are positive integers (auto-incremented from SERIAL)
  • Group IDs are negative integers (from a separate sequence)
  • External IDs are prefixed with type: "user:john@example.com", "group:admins"

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def count(principalType: String): Result[Long]

Count principals of a given type.

Count principals of a given type.

Value parameters

principalType

Either "user" or "group"

Attributes

Returns

Count of principals

def delete(external: ExternalPrincipal): Result[Unit]

Delete a principal mapping.

Delete a principal mapping.

Note: This does not remove the principal from any collection permissions or document readable_by lists. Those should be cleaned up separately.

Value parameters

external

The external principal identifier

Attributes

Returns

Success or error

Reverse lookup: get external ID for a principal ID.

Reverse lookup: get external ID for a principal ID.

Value parameters

id

The internal principal ID

Attributes

Returns

The external principal if found, None otherwise

Get or create a principal ID for an external identifier.

Get or create a principal ID for an external identifier.

If the external ID already exists, returns the existing ID. Otherwise, creates a new ID (positive for users, negative for groups).

Value parameters

external

The external principal identifier

Attributes

Returns

The internal principal ID

Batch get or create for multiple principals.

Batch get or create for multiple principals.

More efficient than individual calls for bulk operations.

Value parameters

externals

The external principal identifiers

Attributes

Returns

Map from external principal to internal ID

def list(principalType: String, limit: Int, offset: Int): Result[Seq[ExternalPrincipal]]

List all principals of a given type.

List all principals of a given type.

Value parameters

limit

Maximum number to return

offset

Number to skip

principalType

Either "user" or "group"

Attributes

Returns

List of external principals

def lookup(external: ExternalPrincipal): Result[Option[PrincipalId]]

Lookup principal by external ID without creating.

Lookup principal by external ID without creating.

Value parameters

external

The external principal identifier

Attributes

Returns

The internal ID if found, None otherwise

Lookup multiple principals by external IDs.

Lookup multiple principals by external IDs.

Only returns mappings for principals that exist.

Value parameters

externals

The external principal identifiers

Attributes

Returns

Map from external principal to internal ID (only for existing principals)

Concrete methods

def exists(external: ExternalPrincipal): Result[Boolean]

Check if a principal exists.

Check if a principal exists.

Value parameters

external

The external principal identifier

Attributes

Returns

True if exists, false otherwise