Skip to content
rw3iss Auth

SessionBridgeFactory

class rw3iss\AuthServer\Laravel\Bridge\SessionBridgeFactory src/Bridge/SessionBridgeFactory.php ↗

Builds a {@see SessionBridge} per named instance, so an app with several session user-types (e.g. staff web + customer customer) federates each to the auth-server without hand-constructing a bridge in every controller.

Instances are declared under vauth.bridge.instances (keyed by name, which defaults to the session guard); any key an instance omits falls back to the base vauth.bridge config. The single-bridge app(SessionBridge::class) path is unchanged — this is purely additive for the multi-guard case.

$bridge = app(SessionBridgeFactory::class)->for(‘customer’); $user = $bridge->loginWithPassword($email, $password);

Methods

__construct()

function __construct(
private readonly Container $container,
private readonly array $instances,
private readonly array $defaults,
)

Parameters

  • $instancesarray<string, array<string, mixed>> · vauth.bridge.instances
  • $defaultsarray<string, mixed> · base vauth.bridge config

Annotations

  • @var array<string, SessionBridge> / private array $cache = []; /*

for()

function for(string $name): SessionBridge

The bridge for a named instance (cached). Falls back to the base vauth.bridge config for any unset key; an instance’s guard defaults to its own name when not given. An unknown name builds against the defaults under that guard name — handy for guard-name-as-instance setups.

names()

function names(): array

Declared instance names (from config).

has()

function has(string $name): bool

Whether a named instance is declared in config.

build()

function build(array $cfg): SessionBridge

Parameters

  • $cfgarray<string, mixed>

makeResolver()

function makeResolver(array $cfg): ResolvesShadowUser

Build the resolver for an instance: a bound custom resolver class-string, else a configured {@see EmailShadowUserResolver}. Mirrors the default single-bridge resolver binding in the service provider.

Parameters

  • $cfgarray<string, mixed>