Compare commits

1 Commits

Author SHA1 Message Date
2b1ef775b4 Merge branch 'develop' 2026-07-27 18:00:06 +02:00
11 changed files with 7 additions and 127 deletions

View File

@@ -72,5 +72,5 @@ CMD ["php-fpm"]
# ---- 4. Nginx (static assets + reverse proxy to php-fpm) ---- # ---- 4. Nginx (static assets + reverse proxy to php-fpm) ----
# #
FROM nginx:1.27-alpine AS nginx FROM nginx:1.27-alpine AS nginx
COPY --from=app /var/www/html/public /var/www/html/public COPY --from=frontend /app/public /var/www/html/public
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf

View File

@@ -15,17 +15,6 @@ return Application::configure(basePath: dirname(__DIR__))
) )
->withMiddleware(function (Middleware $middleware): void { ->withMiddleware(function (Middleware $middleware): void {
$middleware->web(append: [SetLocale::class]); $middleware->web(append: [SetLocale::class]);
// Detrás de Traefik/nginx (Dokploy): la IP del proxy inmediato (el
// contenedor nginx) es dinámica, así que confiamos en cualquier origen
// para que Laravel respete X-Forwarded-Proto y genere URLs/assets https.
$middleware->trustProxies(
at: '*',
headers: Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO,
);
}) })
->withExceptions(function (Exceptions $exceptions): void { ->withExceptions(function (Exceptions $exceptions): void {
$exceptions->shouldRenderJsonWhen( $exceptions->shouldRenderJsonWhen(

View File

@@ -1,41 +1,5 @@
name: oauth-iam name: oauth-iam
x-app-env: &app-env
APP_NAME: ${APP_NAME}
APP_ENV: ${APP_ENV}
APP_KEY: ${APP_KEY}
APP_DEBUG: ${APP_DEBUG}
APP_URL: ${APP_URL}
APP_LOCALE: ${APP_LOCALE}
APP_FALLBACK_LOCALE: ${APP_FALLBACK_LOCALE}
APP_FAKER_LOCALE: ${APP_FAKER_LOCALE}
LOG_CHANNEL: ${LOG_CHANNEL}
LOG_STACK: ${LOG_STACK}
LOG_LEVEL: ${LOG_LEVEL}
DB_CONNECTION: ${DB_CONNECTION}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_DATABASE: ${DB_DATABASE}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
SESSION_DRIVER: ${SESSION_DRIVER}
SESSION_LIFETIME: ${SESSION_LIFETIME}
SESSION_ENCRYPT: ${SESSION_ENCRYPT}
SESSION_SECURE_COOKIE: ${SESSION_SECURE_COOKIE}
SESSION_DOMAIN: ${SESSION_DOMAIN}
CACHE_STORE: ${CACHE_STORE}
QUEUE_CONNECTION: ${QUEUE_CONNECTION}
REDIS_CLIENT: ${REDIS_CLIENT}
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
REDIS_PASSWORD: ${REDIS_PASSWORD}
FILESYSTEM_DISK: ${FILESYSTEM_DISK}
MAIL_MAILER: ${MAIL_MAILER}
MAIL_FROM_ADDRESS: ${MAIL_FROM_ADDRESS}
MAIL_FROM_NAME: ${MAIL_FROM_NAME}
L5_SWAGGER_GENERATE_ALWAYS: ${L5_SWAGGER_GENERATE_ALWAYS}
VITE_APP_NAME: ${VITE_APP_NAME}
services: services:
app: app:
build: build:
@@ -44,8 +8,8 @@ services:
image: oauth-iam-app:latest image: oauth-iam-app:latest
restart: unless-stopped restart: unless-stopped
environment: environment:
<<: *app-env
CONTAINER_ROLE: app CONTAINER_ROLE: app
env_file: .env.production
volumes: volumes:
- app_storage:/var/www/html/storage - app_storage:/var/www/html/storage
depends_on: depends_on:
@@ -67,7 +31,7 @@ services:
image: oauth-iam-app:latest image: oauth-iam-app:latest
restart: unless-stopped restart: unless-stopped
command: php artisan queue:work redis --sleep=3 --tries=3 --max-time=3600 command: php artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
environment: *app-env env_file: .env
volumes: volumes:
- app_storage:/var/www/html/storage - app_storage:/var/www/html/storage
depends_on: depends_on:
@@ -83,7 +47,7 @@ services:
image: oauth-iam-app:latest image: oauth-iam-app:latest
restart: unless-stopped restart: unless-stopped
command: php artisan schedule:work command: php artisan schedule:work
environment: *app-env env_file: .env.production
volumes: volumes:
- app_storage:/var/www/html/storage - app_storage:/var/www/html/storage
depends_on: depends_on:
@@ -97,6 +61,9 @@ services:
context: . context: .
target: nginx target: nginx
restart: unless-stopped restart: unless-stopped
ports:
- "80:80"
# - "443:443"
volumes: volumes:
- ./docker/nginx/certs:/etc/nginx/certs:ro - ./docker/nginx/certs:/etc/nginx/certs:ro
depends_on: depends_on:

View File

@@ -28,7 +28,6 @@ server {
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
fastcgi_param HTTP_AUTHORIZATION $http_authorization;
fastcgi_read_timeout 60; fastcgi_read_timeout 60;
fastcgi_hide_header X-Powered-By; fastcgi_hide_header X-Powered-By;
} }
@@ -64,7 +63,6 @@ server {
# fastcgi_index index.php; # fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name; # fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
# include fastcgi_params; # include fastcgi_params;
# fastcgi_param HTTP_AUTHORIZATION $http_authorization;
# fastcgi_read_timeout 60; # fastcgi_read_timeout 60;
# } # }
# } # }

View File

@@ -14,9 +14,6 @@ if [ "$CONTAINER_ROLE" = "app" ]; then
echo "Aplicando migraciones..." echo "Aplicando migraciones..."
su-exec www-data php artisan migrate --force su-exec www-data php artisan migrate --force
echo "Comprobando el cliente de Personal Access Tokens..."
su-exec www-data php artisan passport:ensure-personal-client
echo "Cacheando configuración, rutas y vistas..." echo "Cacheando configuración, rutas y vistas..."
su-exec www-data php artisan config:cache su-exec www-data php artisan config:cache
su-exec www-data php artisan route:cache su-exec www-data php artisan route:cache

View File

@@ -23,7 +23,6 @@ const ca: MessageSchema = {
edit: 'Editar', edit: 'Editar',
delete: 'Esborrar', delete: 'Esborrar',
none: '(cap)', none: '(cap)',
unexpectedError: "Alguna cosa ha fallat. Torna-ho a provar d'aquí a una estona.",
}, },
login: { login: {
title: 'Entrar', title: 'Entrar',

View File

@@ -23,7 +23,6 @@ const en: MessageSchema = {
edit: 'Edit', edit: 'Edit',
delete: 'Delete', delete: 'Delete',
none: '(none)', none: '(none)',
unexpectedError: 'Something went wrong. Please try again in a moment.',
}, },
login: { login: {
title: 'Sign in', title: 'Sign in',

View File

@@ -21,7 +21,6 @@ const es = {
edit: 'Editar', edit: 'Editar',
delete: 'Borrar', delete: 'Borrar',
none: '(ninguno)', none: '(ninguno)',
unexpectedError: 'Algo salió mal. Probá de nuevo en un momento.',
}, },
login: { login: {
title: 'Ingresar', title: 'Ingresar',

View File

@@ -14,7 +14,6 @@ const newToken = ref<string | null>(null);
const form = reactive<{ name: string; scopes: string[] }>({ name: '', scopes: [] }); const form = reactive<{ name: string; scopes: string[] }>({ name: '', scopes: [] });
const errors = ref<Record<string, string[]>>({}); const errors = ref<Record<string, string[]>>({});
const failed = ref(false);
async function load(): Promise<void> { async function load(): Promise<void> {
loading.value = true; loading.value = true;
@@ -30,7 +29,6 @@ async function load(): Promise<void> {
async function create(): Promise<void> { async function create(): Promise<void> {
creating.value = true; creating.value = true;
errors.value = {}; errors.value = {};
failed.value = false;
newToken.value = null; newToken.value = null;
try { try {
@@ -41,8 +39,6 @@ async function create(): Promise<void> {
await load(); await load();
} catch (e: any) { } catch (e: any) {
errors.value = e.response?.data?.errors ?? {}; errors.value = e.response?.data?.errors ?? {};
// Sin errores de validación (p. ej. un 500): avisar en vez de no hacer nada.
failed.value = !e.response?.data?.errors;
} finally { } finally {
creating.value = false; creating.value = false;
} }
@@ -88,8 +84,6 @@ onMounted(load);
</div> </div>
</div> </div>
<p v-if="failed" class="field__error">{{ t('common.unexpectedError') }}</p>
<div> <div>
<button type="submit" :disabled="creating" class="btn btn--primary"> <button type="submit" :disabled="creating" class="btn btn--primary">
{{ creating ? t('common.creating') : t('tokens.create') }} {{ creating ? t('common.creating') : t('tokens.create') }}

View File

@@ -2,23 +2,7 @@
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Laravel\Passport\ClientRepository;
Artisan::command('inspire', function () { Artisan::command('inspire', function () {
$this->comment(Inspiring::quote()); $this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote'); })->purpose('Display an inspiring quote');
// Sin este cliente, Passport no puede emitir Personal Access Tokens (createToken lanza
// "Personal access client not found"). Idempotente: lo ejecuta el entrypoint en cada
// arranque, porque en producción no se corre el seeder.
Artisan::command('passport:ensure-personal-client', function (ClientRepository $clients) {
$provider = config('auth.guards.api.provider');
try {
$clients->personalAccessClient($provider);
$this->info('Personal access client: ya existe.');
} catch (RuntimeException) {
$clients->createPersonalAccessGrantClient('Personal Access Client', $provider);
$this->info('Personal access client: creado.');
}
})->purpose('Crea el cliente de Personal Access Tokens si no existe');

View File

@@ -1,46 +0,0 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Passport\Client;
use Tests\TestCase;
class PersonalAccessTokenTest extends TestCase
{
use RefreshDatabase;
private function personalClients(): int
{
return Client::query()->get()
->filter(fn (Client $client) => $client->hasGrantType('personal_access'))
->count();
}
public function test_ensure_command_creates_the_personal_access_client_once(): void
{
$this->assertSame(0, $this->personalClients());
$this->artisan('passport:ensure-personal-client')->assertSuccessful();
$this->artisan('passport:ensure-personal-client')->assertSuccessful();
$this->assertSame(1, $this->personalClients());
}
public function test_users_can_create_personal_access_tokens_once_the_client_exists(): void
{
$this->artisan('passport:ensure-personal-client')->assertSuccessful();
$user = User::factory()->approved()->create();
$response = $this->actingAs($user)->postJson('/web-api/personal-access-tokens', [
'name' => 'MCP TaskStream',
'scopes' => ['users:read'],
]);
$response->assertCreated()->assertJsonStructure(['access_token']);
$this->actingAs($user)->getJson('/web-api/personal-access-tokens')
->assertOk()
->assertJsonFragment(['name' => 'MCP TaskStream']);
}
}