PgPrincipalStore

org.llm4s.rag.permissions.pg.PgPrincipalStore
final class PgPrincipalStore(getConnection: () => Connection) extends PrincipalStore

PostgreSQL implementation of PrincipalStore.

Uses the llm4s_principals table to map external identifiers to internal integer IDs:

  • User IDs are positive (from SERIAL auto-increment)
  • Group IDs are negative (from llm4s_group_id_seq sequence)

Value parameters

getConnection

Function to obtain a database connection

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override 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

Definition Classes
override 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

Definition Classes
override def getExternalId(id: PrincipalId): Result[Option[ExternalPrincipal]]

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

Definition Classes
override def getOrCreate(external: ExternalPrincipal): Result[PrincipalId]

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

Definition Classes

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

Definition Classes
override 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

Definition Classes
override 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

Definition Classes
override def lookupBatch(externals: Seq[ExternalPrincipal]): Result[Map[ExternalPrincipal, PrincipalId]]

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)

Definition Classes

Inherited 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

Inherited from:
PrincipalStore