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

Aberta
#15,069 0 comentários 1 reação 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@ChipNeedham já está trabalhando nisso.

Desde 23/7/2026.

  • #15070 de @ChipNeedham — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
laravel, php

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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)

Linguagem predominante
PHP
Estrelas
4.9k
Forks
647
Merge médio
1d 45min
PRs com merge (30d)
221

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de statamic/cms

Todas as issues de statamic/cms

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.