Security/ApiAuthenticationEntryPoint.php

synaplan · backend/src/Security/ApiAuthenticationEntryPoint.php · php · Apache-2.0
auth

Provides a JSON 401 response for stateless API authentication in Symfony.

// Source: https://github.com/metadist/synaplan | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
<?php

namespace App\Security;

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;

/**
 * Authentication entry point for the stateless JSON API firewalls
 * (`api` and `openai_compat`).
 *
 * Without a custom entry point, Symfony's security ExceptionListener turns
 * an anonymous request to a protected route into an uncaught
 * `HttpException` 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key