8000 [13.x] Remove redundant auth code columns by hafezdivandari · Pull Request #1752 · laravel/passport · GitHub
[go: up one dir, main page]

Skip to content

[13.x] Remove redundant auth code columns #1752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account r 8000 elated emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ Passport's `oauth_personal_access_clients` table has been redundant and unnecess

In addition, the `Laravel\Passport\PersonalAccessClient` model, `Passport::$personalAccessClientModel` property, `Passport::usePersonalAccessClientModel()`, `Passport::personalAccessClientModel()`, and `Passport::personalAccessClient()` methods have been removed.

### Redundant Columns Removal

PR: https://github.com/laravel/passport/pull/1752

The `user_id`, `client_id` and `scopes` columns of the Passport's `oauth_auth_codes` table have been removed. Therefore, you may create a migration that drops these columns:

Schema::table('oauth_auth_codes', function (Blueprint $table) {
$table->dropColumn(['user_id', 'client_id', 'scopes']);
});

## Upgrading To 12.0 From 11.x

### Migration Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public function up(): void
{
Schema::create('oauth_auth_codes', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
Expand Down
10 changes: 0 additions & 10 deletions src/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ class AuthCode extends Model
*/
protected $keyType = 'string';

/**
* Get the client that owns the authentication code.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function client()
{
return $this->belongsTo(Passport::clientModel());
}

/**
* Get the current connection name for the model.
*
Expand Down
5 changes: 0 additions & 5 deletions src/Bridge/AuthCodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

class AuthCodeRepository implements AuthCodeRepositoryInterface
{
use FormatsScopesForStorage;

/**
* {@inheritdoc}
*/
Expand All @@ -25,9 +23,6 @@ public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity): voi
{
$attributes = [
'id' => $authCodeEntity->getIdentifier(),
'user_id' => $authCodeEntity->getUserIdentifier(),
'client_id' => $authCodeEntity->getClient()->getIdentifier(),
'scopes' => $this->formatScopesForStorage($authCodeEntity->getScopes()),
'revoked' => false,
'expires_at' => $authCodeEntity->getExpiryDateTime(),
];
Expand Down
10 changes: 0 additions & 10 deletions src/Bridge/FormatsScopesForStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@

trait FormatsScopesForStorage
{
/**
* Format the given scopes for storage.
*
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
*/
public function formatScopesForStorage(array $scopes): string
{
return json_encode($this->scopesToArray($scopes));
}

/**
* Get an array of scope identifiers for storage.
*
Expand Down
10 changes: 0 additions & 10 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ public function user()
);
}

/**
* Get all of the authentication codes for the client.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function authCodes()
{
return $this->hasMany(Passport::authCodeModel(), 'client_id');
}

/**
* Get all of the tokens that belong to the client.
*
Expand Down
1 change: 0 additions & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ protected function configureUuids()
Passport::setClientUuids(true);

$this->replaceInFile(config_path('passport.php'), '\'client_uuids\' => false', '\'client_uuids\' => true');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_auth_codes_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_access_tokens_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_clients_table.php'), '$table->bigIncrements(\'id\');', '$table->uuid(\'id\')->primary();');
}
Expand Down
0