Skip to content

Laravel config does not respect the order Auth Guards is registered #55165

@steffanhalv

Description

@steffanhalv

Laravel Version

11.43.0

PHP Version

8.3.17

Database Driver & Version

MySQL 8.2

Description

Bug

When defining guards after migrating from Laravel 10 to 11, the config does no longer respect the order it was defined.

This creates trouble for us as Laravel Nova Impersonation selects auth guard based on the ordering of the auth guards where session driver is set & provider is user, and web is automatically moved to the top of the array.

Solution

Laravel should respect the ordering it was defined, it should also be possible to unregister the web guard.
Also Laravel Nova should not 'guess' the auth guard like this, so I post an issue there as well.

Related issue: #50934

Steps To Reproduce

config/auth.php

'guards' => [
        'api' => [
            'driver' => 'jwt',
            'provider' => 'customer',
        ],

        'nova' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
    ]

Result

"guards": {
  "web":{
    "driver":"session",
    "provider":"users"
  },
  "api":{
    "driver":"jwt",
    "provider":"customer"
  },
  "nova":{
    "driver":"session",
    "provider":"users"
  },
}

Related Laravel Nova issue: laravel/nova-issues#6796

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions