Skip to content
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 related emails.

Already on GitHub? Sign in to your account

3.0 #138

Closed
wants to merge 4 commits into from
Closed

3.0 #138

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
6 changes: 4 additions & 2 deletions src/AppStore/src/Command/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ public function __invoke(): int
public function createNamespace(string $path, string $name): string
{
$pluginPath = Str::replace(Plugin::PLUGIN_PATH . '/', '', $path);
[$orgName] = explode('/', $pluginPath);
list($orgName) = explode('/', $pluginPath);
return 'Plugin\\' . Str::studly($orgName) . '\\' . Str::studly($name);
}

public function createMineJson(string $path, string $name, PluginTypeEnum $pluginType): void
{
$pluginPath = Str::replace(Plugin::PLUGIN_PATH . '/', '', $path);

$output = new \stdClass();
$output->name = $name;
$output->name = $pluginPath ?? $name;
$output->version = '1.0.0';
$output->type = $pluginType->value;
$output->description = $this->input->getOption('description') ?: 'This is a sample plugin';
Expand Down
4 changes: 3 additions & 1 deletion src/Jwt/AbstractJwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct(
private readonly array $config,
private readonly CacheManager $cacheManager,
private readonly Clock $clock,
private readonly AccessTokenConstraint $accessTokenConstraint,
private readonly RefreshTokenConstraint $refreshTokenConstraint
) {}

Expand Down Expand Up @@ -72,7 +73,8 @@ public function parserRefreshToken(string $refreshToken): UnencryptedToken
$this->clock,
$this->clock->now()->diff($this->getRefreshExpireAt($this->clock->now()))
),
$this->getBlackListConstraint()
$this->getBlackListConstraint(),
$this->accessTokenConstraint
);
}

Expand Down
27 changes: 27 additions & 0 deletions src/Jwt/AccessTokenConstraint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);
/**
* This file is part of MineAdmin.
*
* @link https://www.mineadmin.com
* @document https://doc.mineadmin.com
* @contact [email protected]
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
*/

namespace Mine\Jwt;

use Lcobucci\JWT\Token;
use Lcobucci\JWT\Validation\Constraint;
use Lcobucci\JWT\Validation\ConstraintViolation;

class AccessTokenConstraint implements Constraint
{
public function assert(Token $token): void
{
if (! $token->isRelatedTo('refresh')) {
throw ConstraintViolation::error('Token is not a refresh token', $this);
}
}
}
Loading