Skip to content

Add support to change database connection #118

@kevindierkx

Description

@kevindierkx

Since #113 got rejected I'm opening this issue to discuss a potential addition to change database connections.

Passport currently uses the default database connection configured in the database.php config file.

This doesn't work for my use case. I have 2 applications 1 for all the front-end stuff ie. issuing tokens displaying the authorization screen etc. the second is purely an API. The default connection for these applications are different, therefore when using passport the authorization process will break because passport can't reach my oauth tables in 1 of the two applications.

I use this setup to separate my database tables across different databases and to separate my application logic to keep things flexible.

To support these kind of setups laravel/passport would require the database connection name to be configurable.

lucadegasperi/oauth2-server-laravel supports this by using the connection() method. It is possible to use the same method in laravel/passport, but it would become a bit messy when working with both eloquent model repositories and bridge repositories talking directly to the DB query builder.

I would suggest using either eloquent model repositories everywhere like #113 introduced or remove the eloquent model repositories altogether and used the bridge repositories primarily. Lastly we could use a static method to set the connection name during registration.

@taylorotwell I'm wondering if this fits the general idea of the package.

I'm open for suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions