refactor: distinguish passport password client and personal access token client configuration (#5105)

This commit is contained in:
Alexis Saettler
2021-04-25 19:05:46 +02:00
committed by GitHub
parent d0132c9938
commit 33e0952ca4
6 changed files with 30 additions and 16 deletions
+2 -2
View File
@@ -134,8 +134,8 @@ MFA_ENABLED=true
DAV_ENABLED=true
# CLIENT ID and SECRET used for OAuth authentication
PASSPORT_PERSONAL_ACCESS_CLIENT_ID=
PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET=
PASSPORT_PASSWORD_GRANT_CLIENT_ID=
PASSPORT_PASSWORD_GRANT_CLIENT_SECRET=
# Allow to access general statistics about your instance through a public API
# call
@@ -194,8 +194,8 @@ class OAuthController extends Controller
/** @var \Illuminate\Http\Response */
$response = app(Kernel::class)->handle(Request::create($url, 'POST', [
'grant_type' => $data['grantType'],
'client_id' => config('passport.personal_access_client.id'),
'client_secret' => config('passport.personal_access_client.secret'),
'client_id' => config('passport.password_grant_client.id'),
'client_secret' => config('passport.password_grant_client.secret'),
'username' => $data['username'],
'password' => $data['password'],
'scope' => '',
+16 -2
View File
@@ -44,8 +44,22 @@ $passports = [
*/
'personal_access_client' => [
'id' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_ID', env('MOBILE_CLIENT_ID')),
'secret' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET', env('MOBILE_CLIENT_SECRET')),
'id' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_ID'),
'secret' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET'),
],
/*
|--------------------------------------------------------------------------
| Password Grant Client
|--------------------------------------------------------------------------
|
| Password grant client used for oauth login, and mobile application.
|
*/
'password_grant_client' => [
'id' => env('PASSPORT_PASSWORD_GRANT_CLIENT_ID', env('MOBILE_CLIENT_ID')),
'secret' => env('PASSPORT_PASSWORD_GRANT_CLIENT_SECRET', env('MOBILE_CLIENT_SECRET')),
],
/*
+2 -2
View File
@@ -300,8 +300,8 @@ Client secret: zsfOHGnEbadlBP8kLsjOV8hMpHAxb0oAhenfmSqq
- Copy the two values into two new environment variables of your `.env` file:
- The value of `Client ID` in a `PASSPORT_PERSONAL_ACCESS_CLIENT_ID` variable
- The value of `Client secret` in a `PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET` variable
- The value of `Client ID` in a `PASSPORT_PASSWORD_GRANT_CLIENT_ID` variable
- The value of `Client secret` in a `PASSPORT_PASSWORD_GRANT_CLIENT_SECRET` variable
- OAuth login can be access on `http://localhost/oauth/login`.
+2 -2
View File
@@ -97,8 +97,8 @@ Client secret: zsfOHGnEbadlBP8kLsjOV8hMpHAxb0oAhenfmSqq
```
* Copy the two values into two new environment variable of your `.env` file:
- The value of client ID in a `PASSPORT_PERSONAL_ACCESS_CLIENT_ID` variable
- The value of client secret in a `PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET` variable
- The value of client ID in a `PASSPORT_PASSWORD_GRANT_CLIENT_ID` variable
- The value of client secret in a `PASSPORT_PASSWORD_GRANT_CLIENT_SECRET` variable
## Limitations
+6 -6
View File
@@ -42,8 +42,8 @@ class AuthControllerTest extends TestCase
);
$this->setEnvironmentValue([
'PASSPORT_PERSONAL_ACCESS_CLIENT_ID' => $client->id,
'PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET' => $client->secret,
'PASSPORT_PASSWORD_GRANT_CLIENT_ID' => $client->id,
'PASSPORT_PASSWORD_GRANT_CLIENT_SECRET' => $client->secret,
]);
$userPassword = 'password';
@@ -79,8 +79,8 @@ class AuthControllerTest extends TestCase
);
$this->setEnvironmentValue([
'PASSPORT_PERSONAL_ACCESS_CLIENT_ID' => $client->id,
'PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET' => $client->secret,
'PASSPORT_PASSWORD_GRANT_CLIENT_ID' => $client->id,
'PASSPORT_PASSWORD_GRANT_CLIENT_SECRET' => $client->secret,
]);
$userPassword = 'password';
@@ -135,8 +135,8 @@ class AuthControllerTest extends TestCase
);
$this->setEnvironmentValue([
'PASSPORT_PERSONAL_ACCESS_CLIENT_ID' => $client->id,
'PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET' => $client->secret,
'PASSPORT_PASSWORD_GRANT_CLIENT_ID' => $client->id,
'PASSPORT_PASSWORD_GRANT_CLIENT_SECRET' => $client->secret,
]);
$userPassword = 'password';