OAuth provider connections aren't persisted per user-repository driver — falls back to a local file even when statamic.users.repository is eloquent

Abierto
#15,069 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ChipNeedham ya está trabajando en esto.

Desde el 23/7/2026.

  • #15070 de @ChipNeedham — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
laravel, php

Línea de trabajo

Start with src/OAuth/Provider.php to understand how getIds() and setIds() currently persist provider mappings, then trace how OAuth\Manager builds providers and how the Eloquent user repository is selected. The issue proposes Eloquent-backed connections when that repository is active; check linked pull request #15070 for work already in progress. Done means OAuth connections persist through the configured Eloquent repository rather than relying on a local file.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

database oauth
Description

Statamic\OAuth\Provider persists the mapping between a provider account (e.g. a Google sub) and a Statamic user via getIds()/setIds(), which read/write a plain PHP file at storage_path("statamic/oauth/{$this->name}.php") (src/OAuth/Provider.php). This happens unconditionally — regardless of which user repository driver is configured.

That's a reasonable default for the flat-file user repository, where there's no database to lean on. But when config('statamic.users.repository') is eloquent, users/roles/groups already live in the database via Statamic\Auth\Eloquent\User/UserRepository. OAuth connections are the one piece of auth-related state still stuck on local disk in that setup.

In practice, storage_path() isn't durable in a lot of environments an Eloquent-driven app would run in — ephemeral compute, multiple app instances behind a load balancer, deploy pipelines that don't preserve arbitrary storage/ subpaths across releases. When that file is missing or not visible to the instance handling a request, findUser() returns null, handleProviderCallback() falls through to createUser(), discovers the email already taken, throws OAuthEmailExistsException, and the user is silently redirected to the unauthorized page — no exception logged, no visible error.

Suggested fix

Extend the existing driver-aware pattern (already used for users/roles/groups) to OAuth connections: when the eloquent repository is active, OAuth\Manager builds providers backed by an Eloquent-persisted connections table instead of the file.

We've built and tested this as a PR — happy to have it adjusted to fit core's preferred conventions.

Version

statamic/cms v6.26.0 (reproduced against latest 6.x as of this report too)

Lenguaje dominante
PHP
Estrellas
4.9k
Forks
647
Merge medio
1 d 45 min
PR fusionados (30 d)
221

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de statamic/cms

Todos los issues de statamic/cms

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.