Module: Supabase::Rails::Web::AuthClientFactory
- Defined in:
- lib/supabase/rails/web/auth_client_factory.rb
Overview
Constructs one ‘Supabase::Auth::Client` per request, cached in `request.env` so every helper that touches Supabase Auth within a single request shares the same instance (and therefore the same `RequestScopedStorage`).
The client is wired with the invariants documented in FR-W6 / FR-W10:
* `storage:` — per-request `RequestScopedStorage`
* `auto_refresh_token:` — `false` (no Timer threads in workers;
refresh is inline via US-006)
* `flow_type:` — `"pkce"` (required for OAuth)
* `persist_session:` — `true` (storage is request-scoped, so
"persist" means "within this request")
Constant Summary collapse
- ENV_KEY =
"supabase.rails.auth_client"
Class Method Summary collapse
Class Method Details
.build(request, env: nil, supabase_options: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/supabase/rails/web/auth_client_factory.rb', line 28 def build(request, env: nil, supabase_options: nil) cached = request.env[ENV_KEY] return cached unless cached.nil? request.env[ENV_KEY] = build_client( request, env: env, supabase_options: ) end |