diff --git a/composer.json b/composer.json
index fb36078..4a03eb7 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
- "name": "designmynight/laravel-mongodb-passport",
+ "name": "sysvale/laravel-mongodb-passport",
"description": "A package to allow laravel/passport use with jenssegers/laravel-mongodb",
- "homepage": "https://github.com/designmynight/laravel-mongodb-passport",
+ "homepage": "https://github.com/Sysvale/laravel-mongodb-passport",
"license": "MIT",
"keywords": [
"laravel",
@@ -10,17 +10,17 @@
"laravel-passport",
"mongodb",
"passport",
- "designmynight"
+ "sysvale"
],
"require": {
"php": ">=7.1",
"illuminate/support": "^5.5 || ^6.0",
- "jenssegers/mongodb": "3.3.* || 3.4.* || 3.5.* || 3.6.*",
- "laravel/passport": "6.0.* || 7.0.* || 7.4.* || 7.5.* || ^8.0 || ^9.0"
+ "jenssegers/mongodb": "3.3.* || 3.4.* || 3.5.* || 3.6.* || 3.8.*",
+ "laravel/passport": "6.0.* || 7.0.* || 7.4.* || 7.5.* || ^8.0 || ^9.0 || ^10"
},
"autoload": {
"psr-4": {
- "DesignMyNight\\Mongodb\\": "src"
+ "Sysvale\\Mongodb\\": "src"
}
},
"authors": [
@@ -28,12 +28,16 @@
"name": "DesignMyNight",
"email": "support@designmynight.com",
"role": "Support"
+ },
+ {
+ "name": "Geidson",
+ "email": "geidson@sysvale.com"
}
],
"extra": {
"laravel": {
"providers": [
- "DesignMyNight\\Mongodb\\MongodbPassportServiceProvider"
+ "Sysvale\\Mongodb\\MongodbPassportServiceProvider"
]
}
}
diff --git a/src/Console/ClientCommand.php b/src/Console/ClientCommand.php
new file mode 100644
index 0000000..697f838
--- /dev/null
+++ b/src/Console/ClientCommand.php
@@ -0,0 +1,118 @@
+option('name') ?: $this->ask(
+ 'What should we name the personal access client?',
+ config('app.name').' Personal Access Client'
+ );
+
+ $client = $clients->createPersonalAccessClient(
+ null, $name, 'http://localhost'
+ );
+
+ $this->info('Personal access client created successfully.');
+
+ $this->patchedOutputClientDetails($client);
+ }
+
+ /**
+ * Create a new password grant client.
+ *
+ * @param \Laravel\Passport\ClientRepository $clients
+ * @return void
+ */
+ protected function createPasswordClient(ClientRepository $clients)
+ {
+ $name = $this->option('name') ?: $this->ask(
+ 'What should we name the password grant client?',
+ config('app.name').' Password Grant Client'
+ );
+
+ $client = $clients->createPasswordGrantClient(
+ null, $name, 'http://localhost'
+ );
+
+ $this->info('Password grant client created successfully.');
+
+ $this->patchedOutputClientDetails($client);
+ }
+
+ /**
+ * Create a client credentials grant client.
+ *
+ * @param \Laravel\Passport\ClientRepository $clients
+ * @return void
+ */
+ protected function createClientCredentialsClient(ClientRepository $clients)
+ {
+ $name = $this->option('name') ?: $this->ask(
+ 'What should we name the client?',
+ config('app.name').' ClientCredentials Grant Client'
+ );
+
+ $client = $clients->create(
+ null, $name, ''
+ );
+
+ $this->info('New client created successfully.');
+
+ $this->patchedOutputClientDetails($client);
+ }
+
+ /**
+ * Create a authorization code client.
+ *
+ * @param \Laravel\Passport\ClientRepository $clients
+ * @return void
+ */
+ protected function createAuthCodeClient(ClientRepository $clients)
+ {
+ $userId = $this->option('user_id') ?: $this->ask(
+ 'Which user ID should the client be assigned to?'
+ );
+
+ $name = $this->option('name') ?: $this->ask(
+ 'What should we name the client?'
+ );
+
+ $redirect = $this->option('redirect_uri') ?: $this->ask(
+ 'Where should we redirect the request after authorization?',
+ url('/auth/callback')
+ );
+
+ $client = $clients->create(
+ $userId, $name, $redirect, false, false, ! $this->option('public')
+ );
+
+ $this->info('New client created successfully.');
+
+ $this->patchedOutputClientDetails($client);
+ }
+
+ /**
+ * Output the client's ID and secret key.
+ *
+ * @param \Laravel\Passport\Client $client
+ * @return void
+ */
+ protected function patchedOutputClientDetails(Client $client)
+ {
+ $this->line('Client ID: '.$client->id);
+ $this->line('Client secret: '.$client->secret);
+ }
+}
diff --git a/src/MongodbPassportServiceProvider.php b/src/MongodbPassportServiceProvider.php
index 37723a3..947d886 100644
--- a/src/MongodbPassportServiceProvider.php
+++ b/src/MongodbPassportServiceProvider.php
@@ -4,19 +4,20 @@
use Illuminate\Support\ServiceProvider;
use DesignMyNight\Mongodb\Passport\AuthCode;
+use DesignMyNight\Mongodb\Console\ClientCommand;
use DesignMyNight\Mongodb\Passport\Bridge\RefreshTokenRepository;
use DesignMyNight\Mongodb\Passport\Client;
use DesignMyNight\Mongodb\Passport\PersonalAccessClient;
-use DesignMyNight\Mongodb\Passport\RefreshToken;
use DesignMyNight\Mongodb\Passport\Token;
use Laravel\Passport\Bridge\RefreshTokenRepository as PassportRefreshTokenRepository;
+use Laravel\Passport\Console\ClientCommand as PassportClientCommand;
use Laravel\Passport\Passport;
class MongodbPassportServiceProvider extends ServiceProvider
{
/**
- * @return void
- */
+ * @return void
+ */
public function register()
{
Passport::useAuthCodeModel(AuthCode::class);
@@ -27,5 +28,9 @@ public function register()
$this->app->bind(PassportRefreshTokenRepository::class, function () {
return $this->app->make(RefreshTokenRepository::class);
});
+
+ $this->app->extend(PassportClientCommand::class, function () {
+ return new ClientCommand();
+ });
}
}