Skip to content

Commit

Permalink
Merge pull request #2 from herpaderpaldent/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
herpaderpaldent authored Jun 22, 2021
2 parents 1c0dfb1 + 55835af commit 51d8868
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 51 deletions.
16 changes: 0 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,5 @@ services:
depends_on:
- app
- mariadb
networks:
- backend

### websocket ################################################
websocket:
build: .docker/cron
restart: always
volumes:
- ${CODE}:/var/www
ports:
- 6001:6001
depends_on:
- app
- mariadb
environment:
CONTAINER_ROLE: websocket
networks:
- backend
10 changes: 5 additions & 5 deletions src/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
DB_DATABASE=oauth
DB_USERNAME=default
DB_PASSWORD=secret

BROADCAST_DRIVER=log
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
Expand Down
6 changes: 4 additions & 2 deletions src/app/Http/Controllers/AuthorizationCodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
use App\Events\AuthorizationGranted;
use App\Models\Client;
use App\Models\Token;
use Illuminate\Http\Client\HttpClientException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Inertia\Inertia;

class AuthorizationCodeController
{
Expand Down Expand Up @@ -67,14 +68,15 @@ public function authorize(Request $request)

broadcast(new AuthorizationGranted($client->client_id, array_merge(['method' => 'GET', 'url' => $redirect_url], $redirect_data)));

return redirect()->to($redirect_url);
return Inertia::location($redirect_url);
}

public function grant(Request $request)
{
$validated_data = $request->validate([
'client_id' => ['required', 'exists:clients,client_id'],
'client_secret' => ['required', 'exists:clients,client_secret'],
'grant_type' => ['required', 'string', Rule::in(['authorization_code'])],
'code' => ['required', 'string']
]);

Expand Down
2 changes: 1 addition & 1 deletion src/app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TrustProxies extends Middleware
*
* @var array|string|null
*/
protected $proxies;
protected $proxies = '*';

/**
* The headers that should be used to detect proxies.
Expand Down
39 changes: 20 additions & 19 deletions src/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions src/config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
//'useTLS' => true,
'encrypted' => true,
'host' => 'websocket'/*'172.21.0.6'*/, // must be the websocket host
'port' => 6001,
'scheme' => 'http'
'useTLS' => true,
],
],

Expand Down
9 changes: 9 additions & 0 deletions src/resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ window.Pusher = require('pusher-js');
forceTLS: true
});*/

/*
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'your-pusher-key',
Expand All @@ -37,3 +38,11 @@ window.Echo = new Echo({
forceTLS: false,
disableStats: true,
});
*/

window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
forceTLS: true
});
12 changes: 9 additions & 3 deletions src/tests/Feature/AuthorizationCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ public function authorizationGrant() {
$response = $this->actingAs($user)
->post(route('authorize.authorization-code'), [
'client_id' => $client->client_id
])->assertRedirect();
]);

$this->assertEquals(409, $response->status());

//dd($response->headers->get('x-inertia-location'));

$return_url = $response->headers->get('x-inertia-location');

$return_url = $response->headers->get('location');
$url_arr = parse_url($return_url);
$query = $url_arr['query'];

Expand All @@ -96,7 +101,8 @@ public function authorizationGrant() {
$response = $this->post('/api/authorization-code/token', [
'client_id' => $client->client_id,
'client_secret' => $client->client_secret,
'code' => $code
'code' => $code,
'grant_type' => 'authorization_code'
])->assertJson(fn(AssertableJson $json) => $json
->has('access_token')
->has('token_type')
Expand Down

0 comments on commit 51d8868

Please sign in to comment.